violations gradle plugin
v3.0.2
นี่คือปลั๊กอิน Gradle สำหรับการละเมิด lib นอกจากนี้ยังมีปลั๊กอิน Maven สำหรับสิ่งนี้
| รุ่น | เวอร์ชัน Java |
|---|---|
| เวอร์ชัน <2.0.0 | 8 |
| 2.0.0 <= เวอร์ชัน | 11 |
เผยแพร่ไปยัง plugins.gradle.org
สามารถแยกวิเคราะห์ผลลัพธ์จากการวิเคราะห์รหัสแบบคงที่และ:
คุณสามารถทำได้ด้วยเครื่องมือบรรทัดคำสั่ง
ตัวอย่างของผลลัพธ์อาจมีลักษณะเช่นนี้:
...
se/bjurr/violations/lib/example/OtherClass.java
╔══════════╤════════════╤══════════╤══════╤════════════════════════════════════════════════════╗
║ Reporter │ Rule │ Severity │ Line │ Message ║
╠══════════╪════════════╪══════════╪══════╪════════════════════════════════════════════════════╣
║ Findbugs │ MS_SHOULD_ │ INFO │ 7 │ Field isn ' t final but should be ║
║ │ BE_FINAL │ │ │ ║
║ │ │ │ │ ║
║ │ │ │ │ <p> ║
║ │ │ │ │ This static field public but not final, and ║
║ │ │ │ │ could be changed by malicious code or ║
║ │ │ │ │ by accident from another package. ║
║ │ │ │ │ The field could be made final to avoid ║
║ │ │ │ │ this vulnerability.</p> ║
╟──────────┼────────────┼──────────┼──────┼────────────────────────────────────────────────────╢
║ Findbugs │ NM_FIELD_N │ INFO │ 6 │ Field names should start with a lower case letter ║
║ │ AMING_CONV │ │ │ ║
║ │ ENTION │ │ │ ║
║ │ │ │ │ <p> ║
║ │ │ │ │ Names of fields that are not final should be in mi ║
║ │ │ │ │ xed case with a lowercase first letter and the fir ║
║ │ │ │ │ st letters of subsequent words capitalized. ║
║ │ │ │ │ </p> ║
╚══════════╧════════════╧══════════╧══════╧════════════════════════════════════════════════════╝
Summary of se/bjurr/violations/lib/example/OtherClass.java
╔══════════╤══════╤══════╤═══════╤═══════╗
║ Reporter │ INFO │ WARN │ ERROR │ Total ║
╠══════════╪══════╪══════╪═══════╪═══════╣
║ Findbugs │ 2 │ 0 │ 0 │ 2 ║
╟──────────┼──────┼──────┼───────┼───────╢
║ │ 2 │ 0 │ 0 │ 2 ║
╚══════════╧══════╧══════╧═══════╧═══════╝
Summary
╔════════════╤══════╤══════╤═══════╤═══════╗
║ Reporter │ INFO │ WARN │ ERROR │ Total ║
╠════════════╪══════╪══════╪═══════╪═══════╣
║ Checkstyle │ 4 │ 1 │ 1 │ 6 ║
╟────────────┼──────┼──────┼───────┼───────╢
║ Findbugs │ 2 │ 2 │ 5 │ 9 ║
╟────────────┼──────┼──────┼───────┼───────╢
║ │ 6 │ 3 │ 6 │ 15 ║
╚════════════╧══════╧══════╧═══════╧═══════╝ตัวอย่างรายงานที่รองรับมีอยู่ที่นี่
มีการใช้ พาร์สเซอร์ จำนวนหนึ่งแล้ว ตัวแยกวิเคราะห์ บางตัวสามารถแยกวิเคราะห์ผลลัพธ์จาก นักข่าว หลายคน
| ผู้รายงานข่าว | ตัวแยกวิเคราะห์ | หมายเหตุ |
|---|---|---|
| ARM-GCC | CLANG | |
| Androidlint | ANDROIDLINT | |
| Ansible-Later | ANSIBLELATER | ด้วยรูปแบบ json |
| ansiblelint | FLAKE8 | ด้วย -p |
| โจร | CLANG | ด้วย bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}" |
| เสียงดัง | CLANG | |
| CPD | CPD | |
| CPPCHECK | CPPCHECK | ด้วย cppcheck test.cpp --output-file=cppcheck.xml --xml |
| CPPLINT | CPPLINT | |
| CSSLINT | CSSLINT | |
| CheckStyle | CHECKSTYLE | |
| CloudFormation Linter | JUNIT | cfn-lint . -f junit --output-file report-junit.xml |
| ผู้มีรหัสผ่าน | CODECLIMATE | |
| codenarc | CODENARC | |
| ความครอบคลุม | COVERITY | |
| โผ | MACHINE | ด้วย dart analyze --format=machine |
| ตรวจสอบการพึ่งพา | SARIF | ใช้ --format SARIF |
| ทำให้เสียชีวิต | CHECKSTYLE | ด้วย --output-format xml |
| DOCFX | DOCFX | |
| doxygen | CLANG | |
| ERB | CLANG | ด้วย erb -P -x -T '-' "${it}" | ruby -c 2>&1 >/dev/null | grep '^-' | sed -E 's/^-([a-zA-Z0-9:]+)/${filename}1 ERROR:/p' > erbfiles.out |
| eslint | CHECKSTYLE | ด้วย format: 'checkstyle' |
| findbugs | FINDBUGS | |
| เกล็ด 8 | FLAKE8 | |
| FXCOP | FXCOP | |
| GCC | CLANG | |
| GHS | GHS | |
| ทหาร | GENDARME | |
| นักข่าวทั่วไป | GENERIC | จะสร้างการละเมิดเพียงครั้งเดียวกับเนื้อหาทั้งหมดเป็นข้อความ |
| Golint | GOLINT | |
| รัฐบาล | GOLINT | รูปแบบเดียวกับ Golint |
| Golangci-Lint | CHECKSTYLE | ด้วย --out-format=checkstyle |
| GoogleerrorProne | GOOGLEERRORPRONE | |
| Hadolint | CHECKSTYLE | ด้วย -f checkstyle |
| IAR | IAR | ด้วย --no_wrap_diagnostics |
| อนุมาน | PMD | Facebook อนุมาน ด้วย --pmd-xml |
| จาโคโค | JACOCO | |
| jcreport | JCREPORT | |
| jshint | JSLINT | ด้วย --reporter=jslint หรือตัวแยกวิเคราะห์ checkstyle ด้วย --reporter=checkstyle |
| จูท | JUNIT | มันมีความล้มเหลวเท่านั้น |
| Ktlint | CHECKSTYLE | |
| klocwork | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | เอาต์พุตจากปลั๊กอิน Kotlin Gradle |
| Kotlinmaven | KOTLINMAVEN | เอาต์พุตจากปลั๊กอิน Kotlin Maven |
| ผ้าสำลี | LINT | รูปแบบ XML ทั่วไปที่ใช้โดยผ้าลินินที่แตกต่างกัน |
| msbuildlog | MSBULDLOG | ด้วย -fileLogger ใช้ .*msbuild\.log$ เป็นรูปแบบหรือ -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic สำหรับชื่อไฟล์เอาต์พุตที่กำหนดเอง |
| MSCPP | MSCPP | |
| McCabe | FLAKE8 | |
| mypy | MYPY | |
| วันใหม่ | GOOGLEERRORPRONE | รูปแบบเดียวกับ Google Error มีแนวโน้ม |
| PCLINT | PCLINT | PC-LINT โดยใช้รูปแบบเอาต์พุตเดียวกันกับปลั๊กอินคำเตือนของ Jenkins รายละเอียดที่นี่ |
| PHPCs | CHECKSTYLE | ด้วย phpcs api.php --report=checkstyle |
| PHPPMD | PMD | ด้วย phpmd api.php xml ruleset.xml |
| PMD | PMD | |
| pep8 | FLAKE8 | |
| perlcritic | PERLCRITIC | |
| น่ายินดีที่สุด | PITEST | |
| Protolint | PROTOLINT | |
| หุ่นเชิด | CLANG | ด้วย -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| pydocstyle | PYDOCSTYLE | |
| เพลา | FLAKE8 | |
| ไพลินต์ | PYLINT | ด้วย pylint --output-format=parseable |
| ผู้ปรับเปลี่ยน | RESHARPER | |
| Rubycop | CLANG | ด้วย rubycop -f clang file.rb |
| sarif | SARIF | v2.x. Microsoft Visual C# สามารถสร้างได้ด้วย ErrorLog="BuildErrors.sarif,version=2" |
| Sbtscalac | SBTSCALAC | |
| สตาร์สไทล์ | CHECKSTYLE | |
| เซาะร่อน | SEMGREP | กับ --json . |
| Simian | SIMIAN | |
| โซนาร์ | SONAR | ด้วย mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json ลบออกใน 7.7 ดู sonar-11670 แต่สามารถดึงได้ด้วย: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' | jq -f sonar-report-builder.jq > sonar-report.json |
| สปอตบั๊ก | FINDBUGS | |
| StyleCop | STYLECOP | |
| Swiftlint | CHECKSTYLE | ด้วย --reporter checkstyle |
| Tslint | CHECKSTYLE | ด้วย -t checkstyle |
| ลูกผสม | VALGRIND | ด้วย --xml=yes |
| xmllint | XMLLINT | |
| Xunit | XUNIT | มันมีความล้มเหลวเท่านั้น |
| Yamllint | YAMLLINT | ด้วย -f parsable |
| zptlint | ZPTLINT |
52 Parsers และนักข่าว 79 คน
ไม่มีรูปแบบ? เปิดปัญหาที่นี่!
มีตัวอย่างที่กำลังทำงานอยู่ที่นี่
การมีสิ่งต่อไปนี้ในสคริปต์บิลด์จะทำให้ปลั๊กอินทำงานด้วย ./gradlew build
plugins {
id " se.bjurr.violations.violations-gradle-plugin " version " X "
}
task violations ( type : se.bjurr.violations.gradle.plugin.ViolationsTask ) {
//
// Optional config
//
maxReporterColumnWidth . set( 0 ) // 0 is disabled
maxRuleColumnWidth . set( 10 )
maxSeverityColumnWidth . set( 0 )
maxLineColumnWidth . set( 0 )
maxMessageColumnWidth . set( 50 )
codeClimateFile . set(file( ' code-climate-file.json ' )) // Will create a CodeClimate JSON report.
violationsFile . set(file( ' violations-file.json ' )) // Will create a normalized JSON report.
//
// Global configuration, remove if you dont want to report violations for
// the entire repo.
//
minSeverity . set(se . bjurr . violations . lib . model . SEVERITY . INFO ) // INFO, WARN or ERROR
detailLevel . set( se.bjurr.violations.git.ViolationsReporterDetailLevel . VERBOSE ) // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations . set( 99999999 ) // Will fail the build if total number of found violations is higher
printViolations . set( true ) // Will print violations found in diff
//
// Diff configuration, remove if you dont want to report violations for
// files changed between specific revisions.
//
// diff-properties can be supplied with something like:
//
// ./gradlew violations -i -PdiffFrom=e4de20e -PdiffTo=HEAD
//
// And in Travis, you could add:
//
// script:
// - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./gradlew check -PdiffFrom=$TRAVIS_PULL_REQUEST_BRANCH -PdiffTo=$TRAVIS_BRANCH ; fi'
//
diffFrom . set(project . properties . diffFrom) // Can be empty (ignored), Git-commit or any Git-reference
diffTo . set(project . properties . diffTo) // Same as above
diffMinSeverity . set(se . bjurr . violations . lib . model . SEVERITY . INFO ) // INFO, WARN or ERROR
diffDetailLevel . set( se.bjurr.violations.git.ViolationsReporterDetailLevel . VERBOSE ) // PER_FILE_COMPACT, COMPACT or VERBOSE
diffMaxViolations . set( 99 ) // Will fail the build if number of violations, in the diff within from/to, is higher
diffPrintViolations . set( true ) // Will print violations found in diff
gitRepo . set(file( ' . ' )) // Where to look for Git
//
// This is mandatory regardless of if you want to report violations between
// revisions or the entire repo.
//
// Many more formats available, see: https://github.com/tomasbjerre/violations-lib
violationConfig()
.setFolder(projectDir . path)
.setParser( se.bjurr.violations.lib.reports.Parser . FINDBUGS )
.setPattern( " .*/findbugs/.* \ .xml $ " )
.setReporter( " Findbugs " )
violationConfig()
.setFolder(projectDir . path)
.setParser( se.bjurr.violations.lib.reports.Parser . PMD )
.setPattern( " .*/pmd/.* \ .xml $ " )
.setReporter( " PMD " )
}
check . finalizedBy violations