The plugin supports several static analysis tools. The availability of each tool depends on the project the plugin is applied to. Some tools only support Java code, some only Kotlin code, and some only work on Android projects. To be precise:
Tool | Java | Android (Java) |
Kotlin | Android (Kotlin) |
---|---|---|---|---|
Checkstyle |
✅ | ✅ | — | — |
PMD |
✅ | ✅ | — | — |
SpotBugs |
✅ | ✅ | — | — |
Detekt |
— | — | ✅ | ✅ |
Android Lint |
— | ✅️ | — | ✅️ |
KtLint |
— | — | ✅️ | ✅️ |
For additional informations and tips on how to obtain advanced behaviours with the plugin and its tools, please refer to the advanced usage page.
- Enable and disable tools
- Configure the tools
- Example configurations
In order to enable a tool, you just need to add it to the staticAnalysis
closure. To enable all supported tools with their default configurations:
staticAnalysis {
penalty {
// ... (optional)
}
checkstyle {}
pmd {}
spotbugs {}
lintOptions {}
detekt {}
ktlint {}
}
To disable a tool, simply omit its closure from staticAnalysis
. This means that, for example, this will not run any tools:
staticAnalysis {
penalty {
// ...
}
}