violations gradle plugin
v3.0.2
Ceci est un plugin Gradle pour les violations lib. Il y a aussi un plugin Maven pour cela.
| Version | Version java |
|---|---|
| Version <2.0.0 | 8 |
| 2.0.0 <= version | 11 |
Publié sur Plugins.gradle.org.
Il peut analyser les résultats de l'analyse du code statique et:
Vous pouvez également le faire avec un outil de ligne de commande.
Un extrait de la sortie peut ressembler à ceci:
...
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 ║
╚════════════╧══════╧══════╧═══════╧═══════╝Un exemple de rapports pris en charge est disponible ici.
Un certain nombre d' analyseurs ont été mis en œuvre. Certains analyseurs peuvent analyser la production de plusieurs journalistes .
| Journaliste | Analyseur | Notes |
|---|---|---|
| ARM-GCC | CLANG | |
| Androidlint | ANDROIDLINT | |
| Plus-plus | ANSIBLELATER | Avec le format json |
| ANSIBLELINT | FLAKE8 | Avec -p |
| Bandit | CLANG | Avec bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}" |
| Bruit | CLANG | |
| DPC | CPD | |
| Cppcheck | CPPCHECK | Avec cppcheck test.cpp --output-file=cppcheck.xml --xml |
| Cpplint | CPPLINT | |
| Csslint | CSSLINT | |
| Camion | CHECKSTYLE | |
| Cloudformation Linter | JUNIT | cfn-lint . -f junit --output-file report-junit.xml |
| Codeclimat | CODECLIMATE | |
| Codenarc | CODENARC | |
| Couverture | COVERITY | |
| Dard | MACHINE | Avec dart analyze --format=machine |
| Vérification de la dépendance | SARIF | Utilisation --format SARIF |
| Desekt | CHECKSTYLE | Avec --output-format xml . |
| Docfx | DOCFX | |
| Doxygène | CLANG | |
| Erb | CLANG | Avec 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 | Avec format: 'checkstyle' . |
| Findbugs | FINDBUGS | |
| Floke8 | FLAKE8 | |
| Fxcop | FXCOP | |
| GCC | CLANG | |
| GHS | GHS | |
| Gendarme | GENDARME | |
| Reporter générique | GENERIC | Créera une seule violation avec tout le contenu comme message. |
| Golint | GOLINT | |
| Govet | GOLINT | Même format que Golint. |
| Golangci-lint | CHECKSTYLE | Avec --out-format=checkstyle . |
| Googleerrorprone | GOOGLEERRORPRONE | |
| Hadolint | CHECKSTYLE | Avec -f checkstyle |
| Iar | IAR | Avec --no_wrap_diagnostics |
| Déduire | PMD | Facebook inférer. Avec --pmd-xml . |
| Jacoco | JACOCO | |
| Jcreport | JCREPORT | |
| Jshint | JSLINT | Avec --reporter=jslint ou l'analyseur de chreasstyle avec --reporter=checkstyle |
| Junite | JUNIT | Il ne contient que les échecs. |
| Ktlint | CHECKSTYLE | |
| Travail kloc | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | Sortie du plugin Kotlin Gradle. |
| Kotlinmaven | KOTLINMAVEN | Sortie du plugin Kotlin Maven. |
| Peluche | LINT | Un format XML commun, utilisé par différents linceurs. |
| Msbuildlog | MSBULDLOG | Avec -fileLogger use .*msbuild\.log$ as Match ou -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic pour un nom de fichier de sortie personnalisé |
| MSCPP | MSCPP | |
| Mccabe | FLAKE8 | |
| Mypy | MYPY | |
| Nullaway | GOOGLEERRORPRONE | Même format que Google Error sujette. |
| Pclint | PCLINT | PC-lint utilisant le même format de sortie que le plugin Jenkins Warnings, détails ici |
| Phpc | CHECKSTYLE | Avec phpcs api.php --report=checkstyle . |
| PHPPMD | PMD | Avec phpmd api.php xml ruleset.xml . |
| PMD | PMD | |
| Pep8 | FLAKE8 | |
| Perlcritique | PERLCRITIC | |
| Le plus pitoyable | PITEST | |
| Protolint | PROTOLINT | |
| Marionnet-lint | CLANG | Avec -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| Pydocstyle | PYDOCSTYLE | |
| Pyflakes | FLAKE8 | |
| Pylint | PYLINT | Avec pylint --output-format=parseable . |
| Reharper | RESHARPER | |
| Rugycope | CLANG | Avec rubycop -f clang file.rb |
| Sarif | SARIF | v2.x. Microsoft Visual C # peut le générer avec ErrorLog="BuildErrors.sarif,version=2" . |
| Sbtscalac | SBTSCALAC | |
| Scalastyle | CHECKSTYLE | |
| Semgrep | SEMGREP | Avec --json . |
| Simien | SIMIAN | |
| Sonar | SONAR | Avec mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json . Supprimé en 7.7, voir Sonar-11670 mais peut être récupéré avec: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' | jq -f sonar-report-builder.jq > sonar-report.json . |
| Pignon | FINDBUGS | |
| Stylecop | STYLECOP | |
| Swiftlint | CHECKSTYLE | Avec --reporter checkstyle . |
| Tslint | CHECKSTYLE | Avec -t checkstyle |
| Valgrine | VALGRIND | Avec --xml=yes . |
| XMLLINT | XMLLINT | |
| Xunit | XUNIT | Il ne contient que les échecs. |
| Yamllint | YAMLLINT | Avec -f parsable |
| Zptlint | ZPTLINT |
52 analyseurs et 79 journalistes.
Vous manquez un format? Ouvrez un problème ici!
Il y a un exemple en cours d'exécution ici.
Avoir ce qui suit dans le script de construction fera fonctionner le plugin avec ./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