violations gradle plugin
v3.0.2
これは、違反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 | |
| CloudFormation Linter | JUNIT | cfn-lint . -f junit --output-file report-junit.xml |
| CodeClime | CODECLIMATE | |
| codenarc | CODENARC | |
| カバー性 | COVERITY | |
| ダート | MACHINE | dart analyze --format=machine |
| 依存関係チェック | SARIF | --format SARIFを使用します |
| Detekt | CHECKSTYLE | with --output-format xml 。 |
| docfx | DOCFX | |
| ドキシゲン | CLANG | |
| erb | CLANG | with 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 | |
| flake8 | FLAKE8 | |
| fxcop | FXCOP | |
| GCC | CLANG | |
| GHS | GHS | |
| ジェンダーム | GENDARME | |
| ジェネリックレポーター | GENERIC | すべてのコンテンツがメッセージとして1つの違反を作成します。 |
| ゴリント | GOLINT | |
| 政府 | GOLINT | Golintと同じ形式。 |
| Golangci-Lint | CHECKSTYLE | --out-format=checkstyle 。 |
| GoogleErrorProne | GOOGLEERRORPRONE | |
| ハドリント | CHECKSTYLE | -f checkstyleで |
| IAR | IAR | --no_wrap_diagnosticsで |
| 推測 | PMD | Facebookの推論。 --pmd-xmlで。 |
| ジャココ | JACOCO | |
| jcreport | JCREPORT | |
| jshint | JSLINT | --reporter=jslintまたはCheckStyleパーサーをwith --reporter=checkstyle |
| ジュニット | JUNIT | 障害のみが含まれています。 |
| ktlint | CHECKSTYLE | |
| klocwork | KLOCWORK | |
| Kotlingradle | KOTLINGRADLE | Kotlin Gradleプラグインからの出力。 |
| Kotlinmaven | KOTLINMAVEN | Kotlin Mavenプラグインからの出力。 |
| 糸くず | LINT | さまざまなリナーで使用される一般的なXML形式。 |
| msbuildlog | MSBULDLOG | -fileLogger -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic使用.*msbuild\.log$ |
| MSCPP | MSCPP | |
| マッケイブ | FLAKE8 | |
| マイピー | MYPY | |
| nullaway | GOOGLEERRORPRONE | Googleエラーが発生するのと同じ形式。 |
| pclint | PCLINT | PC-LINTジェンキンス警告プラグインと同じ出力形式を使用して、こちらの詳細 |
| 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 | with -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message} |
| Pydocstyle | PYDOCSTYLE | |
| pyflakes | FLAKE8 | |
| ピリント | PYLINT | pylint --output-format=parseableで。 |
| resharper | RESHARPER | |
| rubycop | CLANG | rubycop -f clang file.rb |
| サリフ | SARIF | v2.x. Microsoft Visual C#はErrorLog="BuildErrors.sarif,version=2"で生成できます。 |
| SBTSCALAC | SBTSCALAC | |
| ScalaStyle | CHECKSTYLE | |
| semgrep | 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 。 |
| SpotBugs | FINDBUGS | |
| stylecop | STYLECOP | |
| swiftlint | CHECKSTYLE | --reporter checkstyle付き。 |
| tslint | CHECKSTYLE | -t checkstyle付き |
| Valgrind | VALGRIND | with --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