Improve code level with Sonarqube

Sonarqube is a great tool, it's incredible. I died, I was infected with the Bphone ad. Stop advertising the next code test tool …

Currently, the programmers are often taught many algorithms by the teachers, and the quality of the code and the rules in coding so that they can easily work in the team, easy to maintain, it does not seem to be very important when center. But you should not be too worried because those skills can be learned after going to work, quickly.

Sonarqube is a tool to help programmers check their code well, if there are any errors that violate or risk to violate the principle (general standard), it will help us warn and give suggestions to fix , gradually during the code process I will form a habit and not make mistakes anymore. The settings are also quite simple, this article I guide PHP language offline.

Step 1: Download support packages

Extract all and copy all 3 folders into drive C, remember to rename the folders to sonarqube , sonarqube scanner and sonarqube examples .

Step 2: Download and install jdk if your device is not already installed

Step 3: Go to the folder C: sonarbe windows-x86-64 , find and run the StartSonar.bat file to turn on the sonarqube server. After successfully running, keep the window and not turn off

Note: if the operating system of 32 bit is windows-x86-32 instead of windows-x86-64.

Step 4: Go to folder C: sonar-examples, php php-sonar-runner copy sonar-project.properties file and put it in the root directory of the project that is being tested.

To test the code, you need to edit the sonar-project.properties file in 2 places, first edit the sonar.sources to the path to the file to test, then edit the sonar.language into the language of the project (here I use php).

untitled

Step 5: Go to your browser and type localhost: 9000 , log in with the ID / password admin / admin respectively.

Select Administration , go to System and select Update Center . The next thing to do is find and install the language pack you need to test. Sonarqube has already installed some packages in Installed section, I see no php package yet so I go through the Available tab to find and install php.

After the installation is completed, the server requests a restart, just restart. If you exit and then log back in, you can install the Installed tab again and see that the package has been installed successfully. If not, you need to reset it from the beginning. ).

Step 6: Ok, open the command line and cd to the root directory of the project (where you pasted the file sonar-project.properties earlier). Run the command C: son-scanner bin _ sonar-runner.bat so that the program tests your error. If there is no error in the running process, we have successfully analyzed the error.

Finally go back to localhost: 9000 , go to Issues and select Unresoved Isues . Tada, a list of errors with error attributes like Code Smell, Bug or Vulnerability. Your job is to watch and fix it. The beauty of Sonarqube is that it offers both suggestions to fix these errors, great.

……………………………………. otherwise

untitled1

Just do some projects with this tool, what kind of skills code is also up, when the code is complete and the test does not have any errors then the level has already increased much. Wishing to make coding fun!

ITZone via justfunny

Share the news now