Using sonarLint to analyze code in IDEA

1、

Configure the SonarLint plugin

( 1) Open IDEA, click File → Setting → O ther Settings in order, and find the two tabs of SonarLint ;
( 2) In the SonarLint General Seeting configuration tab, click the " + " icon to add a new server configuration, and enter a configuration name that is easy to use and distinguish in the configuration name, such as: dev-EAM ; in choose a connection type , select the link as needed method ( sonarCloud , sonarQube , we choose the latter one), enter the server ip and port ( EAM project is http://10.10.10.138:9000 ) and click NEXT;
(3) Select " Login /Password" for Authentication type , enter the user name and password in the corresponding text box ( the user name is all spelled out, and the password is 123456) , click NEXT, and then click FINISH ;
(4) Configure the project information in the SonarLint Project Seeting configuration tab, check Enable binding to remote SonarQube server , select the service link just configured in the Bind to server drop-down box, and click Search in list in the SonarQube project option to select the corresponding , click OK ;
(5) After completing the above four steps, the configuration of the plug-in server is completed.
(6) You can see the SonarLint icon in the lower right corner of IDEA , click the icon to open the code analysis report tab, where you can see the code analysis results;

2. Use Sonar for code analysis

(1) Right-click on the project that needs to be analyzed, and select: AnaLyze > AnaLyze with SonarLint (or click the AnaLyze All Project Files icon in the SonarLint report tab), click Preceed in the pop-up dialog box, and wait for the project code analysis to be completed;
(2) After the code analysis is completed, the code analysis results will be displayed in the "SonarQube Report" tab, which can be expanded to a single file to display each issue in the file, click a result, and you can see it in the Rule tab on the right For a detailed description of the problem, double-click a record to quickly jump to the location of the code corresponding to the result;
(3) The SonarLint plug-in automatically performs code inspection by default, but in order to ensure the real-time and validity of the code inspection results, we analyze the code after completing a certain amount of code.

TIPS:
1. Since elasticsearch is added to version 6.6, it cannot be started as root user.
Because of security issues, elasticsearch does not allow the root user to run directly, so create a new user and start with a new user
Since sonar needs to be started with a new user, all the resources that sonar needs to use must belong to the new user (including jdk, which will be discussed in pit 3), otherwise there will be permission problems
chown -R elsearch /usr/local/sonarqube-7.0  // Assign sonar resources to user elsearch
chgrp -R elsearch /usr/local /sonarqube-7.0  // Assign sonar resources to group elsearch
chown -R elsearch /usr/java // Assign jdk resources to user elsearch  
chgrp -R elsearch /usr/local /java  // Assign jdk resources to group elsearch

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326244860&siteId=291194637