This is the 29th day of my participation in Gwen Challenge

SonarQube® is an automated code review tool that detects bugs, bugs, and code smells in your code. It can be integrated with your existing workflow to support continuous code review across project branches and pull requests.

It’s a mask of pain… Haha, the code is scanned according to the rules defined by the tool ~

There are five types of severity and three types

The installation

Download address: www.sonarqube.org/downloads/

Unzip the following files

This version requires JDK >=11

Find the boot mode of the corresponding system and run ~ (run under Windows here, the effect is shown in the picture)

If you see the last two words, the startup is successful

Open the default access address ~

http://localhost:9000/projects

Then enter the password admin/admin to initialize the account

You can go to the following page

So let’s go ahead and create our first project, and let’s test it out here, and select the first manual

The secret key is then generated based on the user name

confirm

Next, select the project management tool

When maven is selected here, it will automatically generate the following line of code, which can then be scanned by executing commands in the project

mvn sonar:sonar \
-Dsonar.projectKey=Springboot-test \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=dd1fc2ff662bb804a490e5c8fbda2fa******7b4b183c6
Copy the code

The first run results are as follows

Once the build scan is complete, the information is displayed on SonarQube

Note here:

In Windows, \ is not allowed to execute multi-line commands as it does under Linux. In Windows, the multi-line separator is ^

Sonarlint can also be configured in IDEA. We searched and installed Sonarlint in the PLUGIN for IDEA

Sonarlint is also very simple to use, you can just scan your current file and display the information (or scan the entire project)

You can also configure the SonarQube under Tools

Test links

The binding

However, this needs to be configured in Maven’s setting… And then every time you submit code or you scan it you upload it… I prefer the maven manual scan upload operation

<profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <! -- Optional URL to server. Default value is http://localhost:9000 -->
            <sonar.host.url>
              http://localhost:9000
            </sonar.host.url>
        </properties>
    </profile>
Copy the code

The last

Welcome friends to discuss the question ~

If you think this article is good, please give it a thumbs-up 😝

Let’s start this unexpected meeting! ~

Welcome to leave a message! Thanks for your support! ヾ(≧▽≦*)o go!!

I’m 4ye. We should… next time. See you soon!! 😆