1, the target
Idea integrates code checking with Sonar so that implementations can check your code before submitting it, rather than submitting it and checking it later.
Sonar can detect code quality from the following seven dimensions, with at least the first five code quality issues you need to deal with as a developer
Sonar can use PMD,CheckStyle,Findbugs and other code rule detection tools to standardize code writing
Sonar can detect potential bugs with code rule checking tools like PMD,CheckStyle,Findbugs, and more
Poor complexity distribution files, classes, methods, etc., will be difficult to change if their complexity is too high, making them difficult for developers to understand, and without automated unit testing, changes to any component of the program will likely result in the need for full regression testing
4, duplication obviously the program contains a lot of copy and paste code is low quality, Sonar can show the source code in the repetition of serious places
5. Too many or too few comments will make code less readable, especially when staff changes inevitably occur. Too many comments will cause developers to spend too much time reading comments, which defeats the purpose
The lack of unit testing Sonar is a handy way to tally up and show unit test coverage
Sonar can find loops, show packages and packages, classes and dependencies between classes, can detect custom architecture rules through SONAR can manage third-party JAR packages, can use LCOM4 to detect the application of single task rules, detect coupling.
2, the premise,
- Sonarqube has been set up
- Jdk8 environment (mine is JDK7, it works fine)
3. Install the plug-in
Set — >Plugins to find the sonarLint plug-in and install it. After the installation, restart IDEA.
4. Configure the project
1) Configure the serverI here is edit form open popover, the first time to add, is the need to add their own use of sonar platform address,The address is usually set up inside the company 2) Choose projects
After the server information is configured above, the corresponding project information will be obtained as follows:Once the configuration is complete, the sonar extension can be seen in the lower left corner of IDEA under the current project environment:
5, run,
The above is only personal experience, if there are mistakes or not fully considered, please feel free to comment.