Introduction to SonarQube
Sonar is an open source platform for code quality management to manage the quality of source code
In the form of plug-ins, you can support code quality management and testing in more than 20 programming languages, including java,C#,C/C++,PL/SQL,Cobol,JavaScrip,Groovy
Sonar can detect code quality from the following seven dimensions, and as a developer, you need to deal with at least the first five code quality issues.
1. Do not follow code standards
Sonar can standardize code writing through code rule detection tools such as PMD,CheckStyle,Findbugs.
two。 Potential defects
Sonar can detect potential defects through code rule detection tools such as PMD,CheckStyle,Findbugs
3. Poor complexity distribution
Files, classes, methods, etc. will be difficult to change if the complexity is too high, which will make it difficult for developers to understand them.
And without automated unit testing, changes to any component in the program may lead to the need for comprehensive regression testing
4. Repetition
Obviously, the quality of the code that contains a lot of copy and paste in the program is poor, and sonar can show serious repetition in the source code.
5. Insufficient or excessive comments
The lack of comments will worsen the readability of the code, especially when there are inevitable personnel changes, the readability of the program will be greatly reduced.
On the other hand, too many comments will cause developers to spend too much energy on reading comments, which is also against the original intention.
6. Lack of unit testing
Sonar can easily count and display unit test coverage.
7. Bad design.
Through sonar, you can find loops, show the interdependencies between packages and classes, and detect custom schema rules.
Third-party jar packets can be managed through sonar, and LCOM4 can be used to detect the application of individual task rules and detect coupling.