Boost Java Code Quality: How to Use SonarLint, SonarQube, and Alibaba Plugin
This article introduces three essential code‑quality tools—SonarLint, SonarQube, and the Alibaba code‑convention plugin—explaining their installation, basic usage, integration with Maven, and how they help developers detect code smells, enforce standards, and quantify quality metrics in Java projects.
Today we recommend three plugins that act as code‑quality detection power‑tools: SonarLint, SonarQube, and the Alibaba code‑convention plugin.
1. SonarLint
SonarLint is a code‑quality detection plugin that helps identify code smells directly in the IDE.
Download & Install
To analyze a single file or project, right‑click → Analyze → Analyze with SonarLint, or select files/folders and use the menu Analyze → Analyze with SonarLint.
You can also disable specific rules:
When custom rules need to be synchronized, bind SonarLint to SonarQube:
View analysis results:
Warnings should not be ignored:
SonarLint provides examples and solutions for each issue, such as preferring LocalDate, LocalTime, LocalDateTime, eliminating duplicate code, avoiding potential NPEs, and reducing nested loops.
With a quality‑check tool, metrics like bug rate and code duplication become quantifiable, enabling custom dashboards for managers.
2. SonarQube
SonarQube is an open‑source code‑quality management platform.
Unzip & Start Locally
unzip sonarqube-7.7.zip
cd sonarqube-7.7
bin/[OS]/sonar.sh consoleAfter a successful start, open http://localhost:9000 and log in with the default admin credentials (admin/admin).
To send analysis results to the server, configure a SonarScanner. See the official documentation.
Example Maven configuration (add to pom.xml):
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
</plugins>
</build>Run analysis with: mvn clean compile sonar:sonar Successful execution shows output like:
Refresh http://localhost:9000 to see the updated dashboard.
In production, data should be persisted to a database; see the installation guide for details.
3. Alibaba Code‑Convention Plugin
The Alibaba Java coding standards are widely used. Install the plugin in IDEA to automatically scan for violations.
After installation, the plugin detects "bad" code and highlights issues.
Example of detection results:
For more details, refer to the original article at cnblogs.com/cjsblog/p/10735800.html .
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
