Android code quality tool integration (CheckStyle, FindBugs, Infer, PMD, Android Lint)
1. Introduction to code inspection tools:
image.png
Code inspection tools help us improve code quality by scanning source code, checking code style and identifying errors in code.
Common Android code check plugins include:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- name function analysis method -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- check code style checkstyle, variables, comments findbugs analysis code code defects, Infer Code defects, null Pointers, etc. Infer code defects, null Pointers, etc. Layout analysis, such as static source code -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --Copy the code
2. Demonstration of continuous integration environment
2.1 Jenkins integration
http://172.22.80.8:8080/job/qingqi_serialport_tool~CHECK/
2.2 Display of inspection results
image.png
2.3 Email Notification Display
image.png
3. How to use and integrate into CI
Grade provides plugins for code checking tools such as CheckStyle, FindBugs, and PMD.
The following uses the Checkstyle tool as an example to illustrate an integration process:
3.1 Engineering Structure
The scripts are stored in the scripts folder
\
image.png
Checkstyle. gradle Gradle script configuration, key here
Huawei_checkstyle. XML Rule configuration file
Suppressions. XML rule configuration file
3.2 Writing the Grade script
The checkstyle.gradle file contains the following contents
\
image.png
3.3 Enable it on the Android Module
Add the following to build.gradle under the main project Module of your app:
apply from: '.. /scripts/checkstyle/checkstyle.gradle'Copy the code
3.4 Checking
./gradlew clean check
Copy the code
4. Improvement of R&D process
The simplicity is:
Developer push to repository – > Git repository trigger notification – > Jenkins trigger build – > produce reports – > fix defects
\
image.png
Reference 5.
Checkstyle: www.jianshu.com/p/0b70a7928… PMD example: www.jianshu.com/p/5fe23ed8d… Android Lint: www.jianshu.com/p/e0de4c1bc… Infer: www.jianshu.com/p/2d5cd6304…