violations gradle plugin
v3.0.2
Este es un complemento de graduación por violaciones lib. También hay un complemento Maven para esto.
| Versión | Versión java |
|---|---|
| Versión <2.0.0 | 8 |
| 2.0.0 <= versión | 11 |
Publicado a plugins.gradle.org.
Puede analizar los resultados del análisis de código estático y:
También puede hacer esto con una herramienta de línea de comandos.
Un fragmento de la salida puede verse así:
...
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 ║
╚════════════╧══════╧══════╧═══════╧═══════╝El ejemplo de informes compatibles están disponibles aquí.
Se han implementado varios analizadores . Algunos analizadores pueden analizar la salida de varios reporteros .
| Reportero | Pasador | Notas |
|---|---|---|
| Brazo | CLANG | |
| Androidlint | ANDROIDLINT | |
| Lateral | ANSIBLELATER | Con formato json |
| Ansiblelint | FLAKE8 | Con -p |
| Bandido | CLANG | Con bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}" |
| Sonido metálico | CLANG | |
| CPD | CPD | |
| CPPCHECK | CPPCHECK | Con cppcheck test.cpp --output-file=cppcheck.xml --xml |
| Pezón | CPPLINT | |
| Csslint | CSSLINT | |
| Estilo de control | CHECKSTYLE | |
| Linter CloudFormation | JUNIT | cfn-lint . -f junit --output-file report-junit.xml |
| Mínimo | CODECLIMATE | |
| CodeNarc | CODENARC | |
| Cobertura | COVERITY | |
| Dardo | MACHINE | Con dart analyze --format=machine |
| Comprobación de dependencia | SARIF | Usando --format SARIF |
| Desanimar | CHECKSTYLE | Con --output-format xml . |
| Docfx | DOCFX | |
| Doxígeno | CLANG | |
| ERB | CLANG | Con 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 | Con format: 'checkstyle' . |
| FindBugs | FINDBUGS | |
| Escamoso | FLAKE8 | |
| Fxcop | FXCOP | |
| GCC | CLANG | |
| GHS | GHS | |
| Gendarme | GENDARME | |
| Reportero genérico | GENERIC | Creará una sola violación con todo el contenido como mensaje. |
| Artilugio | GOLINT | |
| GOBE | GOLINT | El mismo formato que Golint. |
| Golangci-lint | CHECKSTYLE | Con --out-format=checkstyle . |
| GoogleErrorProne | GOOGLEERRORPRONE | |
| Hadolint | CHECKSTYLE | Con -f checkstyle |
| IAR | IAR | Con --no_wrap_diagnostics |
| Inferir | PMD | Facebook inferir. Con --pmd-xml . |
| Jacoco | JACOCO | |
| Jinete | JCREPORT | |
| Trago | JSLINT | Con --reporter=jslint o el analizador de checkStyle con --reporter=checkstyle |
| Junit | JUNIT | Solo contiene las fallas. |
| Ktlint | CHECKSTYLE | |
| Klocwork | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | Salida del complemento Kotlin Gradle. |
| Kotlinmaven | KOTLINMAVEN | Salida del complemento Kotlin Maven. |
| Hilas | LINT | Un formato XML común, utilizado por diferentes revestimientos. |
| Msbuildlog | MSBULDLOG | Con -fileLogger uso .*msbuild\.log$ como patrón o -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic para un nombre de archivo de salida personalizado |
| MSCPP | MSCPP | |
| McCabe | FLAKE8 | |
| Mypy | MYPY | |
| Nullaway | GOOGLEERRORPRONE | El mismo formato que el error de Google propenso. |
| PcLint | PCLINT | PC-Lint utilizando el mismo formato de salida que el complemento de advertencias de Jenkins, detalles aquí |
| PHPCS | CHECKSTYLE | Con phpcs api.php --report=checkstyle . |
| Phppmd | PMD | Con phpmd api.php xml ruleset.xml . |
| PMD | PMD | |
| Pep8 | FLAKE8 | |
| Perlcrítico | PERLCRITIC | |
| Pitest | PITEST | |
| Protolint | PROTOLINT | |
| Títere | CLANG | Con -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| Pydocstyle | PYDOCSTYLE | |
| Pyflakes | FLAKE8 | |
| Pylint | PYLINT | Con pylint --output-format=parseable . |
| Resharper | RESHARPER | |
| Rubicop | CLANG | Con rubycop -f clang file.rb |
| Sarif | SARIF | v2.x. Microsoft Visual C# puede generarlo con ErrorLog="BuildErrors.sarif,version=2" . |
| Sbtscalac | SBTSCALAC | |
| Estilo de escamas | CHECKSTYLE | |
| Semgrep | SEMGREP | Con --json . |
| Simio | SIMIAN | |
| Sonar | SONAR | Con mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json . Eliminado en 7.7, ver sonar-11670 pero se puede recuperar con: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' | jq -f sonar-report-builder.jq > sonar-report.json . |
| Colaboradores | FINDBUGS | |
| Estilecop | STYLECOP | |
| Swiftlint | CHECKSTYLE | Con --reporter checkstyle . |
| Tslint | CHECKSTYLE | Con -t checkstyle |
| Valgrind | VALGRIND | Con --xml=yes . |
| Xmllint | XMLLINT | |
| Xunit | XUNIT | Solo contiene las fallas. |
| Ñame | YAMLLINT | Con -f parsable |
| Zptlint | ZPTLINT |
52 analizadores y 79 reporteros.
¿Te falta un formato? ¡Abra un problema aquí!
Hay un ejemplo de ejecución aquí.
Tener lo siguiente en el script de compilación hará que el complemento se ejecute con ./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