静的コード分析は、CheckStyle、SpotBugs、PMD、CPDを包み込み、カプセル化されたプラグインに新しい機能と拡張機能を提供し、それらを使用しやすく、最小限の努力でより良い結果を提供します。
箱から出して、あなたが取得するプラグインを適用するだけで:
R.classおよびBuildConfig.class )グレードプラグインポータルにいるので、単純に実行できます。
plugins {
id ' com.monits.staticCodeAnalysis ' version ' 3.1.1 '
}または、できることもできます
buildscript {
repositories {
maven {
url ' https://plugins.gradle.org/m2/ '
}
}
dependencies {
classpath ' com.monits:static-code-analysis-plugin:3.1.1 '
}
}
apply plugin : ' com.monits.staticCodeAnalysis 'または、JCenterから直接
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ' com.monits:static-code-analysis-plugin:3.1.1 '
}
}
apply plugin : ' com.monits.staticCodeAnalysis ' | プラグインバージョン | Gradleバージョン | Android Gradleプラグインバージョン |
|---|---|---|
| 3.x | 5.6+ | 3.3.0+ |
| 2.6.12 | 2.3最大5.6.x | 1.1.xから3.5.xまで |
バージョン3.0.0の前に、SpotBugsの代わりにFindBugsが使用されていました。
静的コード分析の構成は、DSLのおかげで非常にシンプルで直感的です。設定ファイルを実行して設定するカプセル化されたプラグインを選択できます。これが簡単な例です
staticCodeAnalysis {
spotbugs = true
checkstyle = true
pmd = true
cpd = true
androidLint = true
ignoreErrors = true
// default rules
spotbugsExclude = " $p roject . rootProject . projectDir /config/spotbugs/excludeFilter.xml "
checkstyleRules = ' https://raw.githubusercontent.com/Monits/static-code-analysis-plugin/staging/defaults/checkstyle/checkstyle-cache.xml '
pmdRules = [ ' https://raw.githubusercontent.com/Monits/static-code-analysis-plugin/staging/defaults/pmd/pmd.xml ' ,
' https://raw.githubusercontent.com/Monits/static-code-analysis-plugin/staging/defaults/pmd/pmd-android.xml ' ]
androidLintConfig = ' https://raw.githubusercontent.com/Monits/static-code-analysis-plugin/staging/defaults/android/android-lint.xml '
sourceSetConfig {
test { // or the name of any other sourceset
// use a more relaxed ruleset
checkstyleRules = ' config/checkstyle/test-checkstyle.xml '
spotbugsExclude = ' config/spotbugs/test-spotbugs.xml '
pmdRules = [ ' config/pmd/test-pmd.xml ' ,
' https://raw.githubusercontent.com/Monits/static-code-analysis-plugin/staging/defaults/pmd/pmd-android.xml ' ]
}
}
}デフォルトでは、すべてのプラグインが適用され、エラーはビルドに失敗しません。このリポジトリの最新のデフォルトからルールと除外が取得されます
バージョン3.0.0の前に、SpotBugsの代わりにFindBugsが使用されていました。古いバージョンを使用する場合、DSLは同等ですが、すべてのプロパティにspotbugsの代わりにfindbugsを使用します。
すべてのV2.x FindBugs DSLプロパティは、v3.xのSpotBugsに自動的にマッピングされ、アップグレードが簡単になります
PMD、SpotBugs、CheckStyleが使用するルールは、 sourceSetConfigブロックの下でソースセットごとにオーバーライデンすることができます。
カスタムLINTルールを含めるには、JARをandroidLint依存関係として単純に含めることができます。たとえば、次のことを追加して、MonitsのAndroid Linterを含めることができます。
dependencies {
androidLint ' com.monits:android-linters:1.+ '
}プラグインは次のタスクを追加します。
cpdcheckstyle 、依存します:checkstyleSourcesetnameタスク( checkstyleMain 、 checkstyleTestなど)。spotbugs 、依存します:spotbugsSourcesetnameタスク( spotbugsMain 、 spotbugsTestなど)。pmd 、依存します:pmdSourcesetnameタスク( pmdMain 、 pmdTestなど)。バージョン3.0.0の前に、SpotBugsの代わりにFindBugsが使用されていました。古いfindbugs*タスクはまだ利用可能であり、対応するspotbugs*タスクにマッピングされています
すべてのタスクは、Javaプラグインのcheckタスクの一部として実行されるようにフックされています。
いつもの形や形で自由に貢献してください、私たちはあなたのフィードバックを楽しみにしています!
あなたが報告されていることを再び見ているなら、それは2つのことの1つであると思うべきではないと思う。
すべてのツールには独自の抑制メカニズムがあるため、そのドキュメントを参照する必要があります。
@SupressFBWarnings javadocCopyright 2010-2017 Monits SA
Apacheライセンス、バージョン2.0(「ライセンス」)に基づいてライセンスされています。ライセンスに準拠している場合を除き、この作業を使用することはできません。次のライセンスのコピーを取得できます。
http://www.apache.org/licenses/license-2.0