background
At the Yunqi Conference in Hangzhou on October 14, 2017, the Alibaba coding protocol plug-in was premiered worldwide.
Afterwards, the client asked us to comply with the code, and designated me to implement it.
Install the plug-in, scan the code, a total of 24 categories were checked, and 7806 problems were found. This is a big number!
The project team itself also has development specifications, which also require that these problems be avoided, but it seems to have no effect.
Something must have gone wrong: or did not comply with the specification? Or no code review?
If all is done and there are so many problems, is there a problem with the mechanism itself?
Is the traditional one-paper development specification + requirements + code review really effective?
These questions are very important, but cleaning up the problem is more urgent.
solution
There are two stages: clear first, then standardize.
milestone
- On October 23, 2017, the plan and implementation plan were reviewed and approved
- On November 7, 2017, the rectification was completed
Pipelined
- Check the code before submitting it , integrate the Alibaba coding protocol plug-in into the IDE. Before submitting the code, scan and clear the problem.
- In the continuous integration, the coding protocol check is added . In the recently released version of the Jenkins plugin FireLine Plugin, the Alibaba coding protocol has been implemented.
- Before the release of the version, check the coding protocol as the check item before the release of the version for final verification.
- Related to individual performance , the results of the coding specifications checked during the continuous integration and version release stages are included in the individual performance.
Operating practice
- Using Alibaba encoding protocol plug-in in Android Studio
- Alibaba coding protocol plug-in used in Eclipse
- Using FireLine plugin in jenkins for Alibaba coding protocol check
Using Alibaba encoding protocol plug-in in Android Studio
- Install Alibaba Java Coding Guidelines plugin
- Project right-click> Coding protocol scanning
- Find the Inspection Results tab in the console area to view the results
Alibaba coding protocol plug-in used in Eclipse
- Install Alibaba Java Coding Guidelines plugin, plugin address https://p3c.alibaba.com/plugin/eclipse/update
- Project right-click> Ali coding protocol scanning
- Find the P3C Results tab in the console area to view the results
Using FireLine plugin in jenkins for Alibaba coding protocol check
- Plug-in management> Install FireLine Plugin
- Build> Add build step Execute FireLine
- Post-build operations> Publish HTML reports, HTML Publisher Plugin is required
- View report
- Note: In the new Jenkins version, the HTML Publisher Plugin plug-in will result in the failure to load CSS and click buttons in the opened webpage. It is due to the CSP (Content Security Policy) and can be executed in the Jenkins console:
System.setProperty ("Hudson.model.DirectoryBrowserSupport.CSP", "") to solve this problem.