violations gradle plugin
v3.0.2
Dies ist ein Gradle -Plugin für Verstöße LIB. Dafür gibt es auch ein Maven -Plugin.
| Version | Java -Version |
|---|---|
| Version <2.0.0 | 8 |
| 2.0.0 <= Version | 11 |
Veröffentlicht an plugins.gradle.org.
Es kann Ergebnisse aus der statischen Codeanalyse analysieren und:
Sie können dies auch mit einem Befehlszeilen -Tool tun.
Ein Ausschnitt der Ausgabe kann so aussehen:
...
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 ║
╚════════════╧══════╧══════╧═══════╧═══════╝Beispiel für unterstützte Berichte finden Sie hier.
Eine Reihe von Parsers wurde implementiert. Einige Parser können die Ausgabe von mehreren Reportern analysieren.
| Reporter | Parser | Notizen |
|---|---|---|
| ARM-GCC | CLANG | |
| Androidlint | ANDROIDLINT | |
| Ansible-Later | ANSIBLELATER | Mit json -Format |
| Ansiblelint | FLAKE8 | -p |
| Bandit | CLANG | Mit bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}" |
| Klang | CLANG | |
| CPD | CPD | |
| Cppcheck | CPPCHECK | Mit 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 |
| Codeklima | CODECLIMATE | |
| Codenarc | CODENARC | |
| Deckung | COVERITY | |
| Pfeil | MACHINE | Mit dart analyze --format=machine |
| Abhängigkeitsprüfung | SARIF | Verwenden Sie --format SARIF |
| Detekt | CHECKSTYLE | Mit --output-format xml . |
| Docfx | DOCFX | |
| Doxygen | CLANG | |
| Erb | CLANG | Mit 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 | Mit format: 'checkstyle' . |
| Findbugs | FINDBUGS | |
| Flake8 | FLAKE8 | |
| Fxcop | FXCOP | |
| GCC | CLANG | |
| GHS | GHS | |
| Gendarmen | GENDARME | |
| Generischer Reporter | GENERIC | Erstellt einen einzigen Verstoß mit allen Inhalten als Nachricht. |
| Golint | GOLINT | |
| Gift | GOLINT | Gleiches Format wie Golint. |
| Golangci-Lint | CHECKSTYLE | Mit --out-format=checkstyle . |
| GoogleErrorprae | GOOGLEERRORPRONE | |
| Hadolint | CHECKSTYLE | Mit -f checkstyle |
| Iar | IAR | Mit --no_wrap_diagnostics |
| Schließen | PMD | Facebook schließen. Mit --pmd-xml . |
| Jacoco | JACOCO | |
| Jcreport | JCREPORT | |
| JSHINT | JSLINT | Mit --reporter=jslint oder dem CheckStyle -Parser mit --reporter=checkstyle |
| Jung | JUNIT | Es enthält nur die Fehler. |
| Ktlint | CHECKSTYLE | |
| Klocwork | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | Ausgang vom Kotlin Gradle Plugin. |
| KOTLINMAVEN | KOTLINMAVEN | Ausgabe vom Kotlin Maven -Plugin. |
| Fussel | LINT | Ein gemeinsames XML -Format, das von verschiedenen Lintern verwendet wird. |
| MSBUILDLOG | MSBULDLOG | -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic -fileLogger use .*msbuild\.log$ |
| MSCPP | MSCPP | |
| McCabe | FLAKE8 | |
| Mypy | MYPY | |
| Nullaway | GOOGLEERRORPRONE | Gleiches Format wie Google -Fehler anfällt. |
| PCLINT | PCLINT | PC-Lint verwendet das gleiche Ausgangsformat wie das Jenkins Warnings-Plugin, Details hier |
| PHPCS | CHECKSTYLE | Mit phpcs api.php --report=checkstyle . |
| PHPPMD | PMD | Mit phpmd api.php xml ruleset.xml . |
| PMD | PMD | |
| Pep8 | FLAKE8 | |
| Perlcritic | PERLCRITIC | |
| Pitest | PITEST | |
| Protolint | PROTOLINT | |
| Puppenspiel-Lint | CLANG | Mit -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| Pydocstyle | PYDOCSTYLE | |
| Pyflakes | FLAKE8 | |
| Pylint | PYLINT | Mit pylint --output-format=parseable . |
| Resharper | RESHARPER | |
| Rubycop | CLANG | Mit rubycop -f clang file.rb |
| Sarif | SARIF | v2.x. Microsoft Visual C# kann es mit ErrorLog="BuildErrors.sarif,version=2" generieren. |
| Sbtscalac | SBTSCALAC | |
| Skalastyle | CHECKSTYLE | |
| Semgrep | SEMGREP | Mit --json . |
| Simian | SIMIAN | |
| Sonar | SONAR | Mit mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json . In 7.7 entfernt, siehe Sonar-11670, kann aber abgerufen werden mit: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' | jq -f sonar-report-builder.jq > sonar-report.json . |
| Spotbugs | FINDBUGS | |
| Stiftung | STYLECOP | |
| Swiftlint | CHECKSTYLE | Mit --reporter checkstyle . |
| Tslint | CHECKSTYLE | Mit -t checkstyle |
| Valgrind | VALGRIND | Mit --xml=yes . |
| Xmllint | XMLLINT | |
| Xunit | XUNIT | Es enthält nur die Fehler. |
| Yamllint | YAMLLINT | Mit -f parsable |
| Zptlint | ZPTLINT |
52 Parser und 79 Reporter.
Ein Format verpassen? Öffnen Sie hier ein Problem!
Hier gibt es ein laufendes Beispiel.
Wenn Sie Folgendes im Build -Skript haben, wird das Plugin mit ./gradlew build ausgeführt.
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