violations gradle plugin
v3.0.2
위반을위한 Gradle 플러그인입니다. 이를위한 Maven 플러그인도 있습니다.
| 버전 | 자바 버전 |
|---|---|
| 버전 <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 ║
╚════════════╧══════╧══════╧═══════╧═══════╝지원되는 보고서의 예는 여기에서 확인할 수 있습니다.
많은 파서가 구현되었습니다. 일부 파서는 여러 기자 로부터 출력을 구문 분석 할 수 있습니다.
| 보고자 | 파서 | 메모 |
|---|---|---|
| 팔 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 | |
| Cloudformation Linter | JUNIT | cfn-lint . -f junit --output-file report-junit.xml |
| 코드 클리트 | CODECLIMATE | |
| 코데 나크 | CODENARC | |
| 은폐 | COVERITY | |
| 다트 | MACHINE | dart analyze --format=machine 사용합니다 |
| 종속성 검사 | SARIF | --format SARIF 사용 |
| Detekt | CHECKSTYLE | --output-format xml . |
| docfx | DOCFX | |
| 독사시 | 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와 같은 형식. |
| Golangci-Lint | CHECKSTYLE | --out-format=checkstyle . |
| GoogleErrorProne | GOOGLEERRORPRONE | |
| Hadolint | CHECKSTYLE | -f checkstyle 과 함께 |
| iar | IAR | --no_wrap_diagnostics 와 함께 |
| 미루다 | PMD | 페이스 북 추론. --pmd-xml 로. |
| 자코코 | JACOCO | |
| JCREPORT | JCREPORT | |
| Jshint | JSLINT | --reporter=jslint 또는 reckStyle Parser with --reporter=checkstyle |
| 주니트 | JUNIT | 그것은 실패 만 포함합니다. |
| ktlint | CHECKSTYLE | |
| klocwork | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | Kotlin Gradle 플러그인의 출력. |
| Kotlinmaven | KOTLINMAVEN | Kotlin Maven 플러그인의 출력. |
| 보풀 | LINT | 다른 라이터에서 사용하는 일반적인 XML 형식. |
| msbuildlog | MSBULDLOG | -fileLogger 사용 .*msbuild\.log$ pattern 또는 -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic |
| MSCPP | MSCPP | |
| 맥 카베 | FLAKE8 | |
| Mypy | MYPY | |
| NULLAWAY | GOOGLEERRORPRONE | Google 오류가 발생하기 쉬운 형식. |
| pclint | PCLINT | Jenkins 경고 플러그인과 동일한 출력 형식을 사용하는 PC-Lint, 여기에서 세부 사항 |
| PHPC | CHECKSTYLE | phpcs api.php --report=checkstyle . |
| phppmd | PMD | phpmd api.php xml ruleset.xml |
| PMD | PMD | |
| pep8 | FLAKE8 | |
| 뇌파 | PERLCRITIC | |
| 피트 | PITEST | |
| 프로토 린트 | PROTOLINT | |
| 꼭두각시 린트 | CLANG | -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| pydocstyle | PYDOCSTYLE | |
| Pyflakes | FLAKE8 | |
| 파일린트 | PYLINT | pylint --output-format=parseable . |
| resharper | RESHARPER | |
| 루비 콥 | CLANG | rubycop -f clang file.rb |
| 사리프 | SARIF | v2.x. Microsoft Visual C#은 ErrorLog="BuildErrors.sarif,version=2" 로 생성 할 수 있습니다. |
| SBTSCALAC | SBTSCALAC | |
| 스칼라 스타일 | CHECKSTYLE | |
| SEMGREP | SEMGREP | --json 과 함께. |
| 유인원 | 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 | |
| Swiftlint | CHECKSTYLE | --reporter checkstyle 과 함께. |
| tslint | CHECKSTYLE | -t checkstyle 과 함께 |
| Valgrind | VALGRIND | --xml=yes |
| xmllint | XMLLINT | |
| xunit | XUNIT | 그것은 실패 만 포함합니다. |
| yamllint | YAMLLINT | -f parsable |
| zptlint | ZPTLINT |
52 개의 파서와 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