Top 5 IntelliJ Plugins to Boost Code Quality & Catch Bugs Early
This article reviews five IntelliJ IDEA plugins—Alibaba Java Coding Guidelines, CheckStyle, PMD, FindBugs, and SonarLint—detailing their installation, usage, and strengths for enforcing coding standards, detecting bugs, and improving code quality in Java projects.
Why Code Quality Tools Matter
As systems grow, complexity and hidden risks increase. Code reviews help but are labor‑intensive and error‑prone. Automated static‑analysis plugins reduce review workload and improve code quality continuously.
1. Alibaba Java Coding Guidelines
Overview
Enforces the Alibaba Java coding standards. Scans code and reports violations at three severity levels: Blocker > Critical > Major. Most issues can be auto‑fixed. Provides real‑time inspection while typing.
Rule Categories
OOP conventions
Concurrency handling
Control statements
Naming conventions
Constant definitions
Comment standards
Installation
File > Settings > Plugins > Marketplace→ search "Alibaba Java Coding Guidelines" → install → restart IDE.
Usage
Run scan: Tools > 阿里编码规约 > 编码规约扫描 or right‑click project/file → "编码规约扫描".
Toggle real‑time detection (recommended for powerful machines).
Switch language (Chinese/English).
Results & Toolbar
Results grouped by severity. Toolbar actions: Rerun Inspection, Close, Expand All, Collapse All, Go Pre/Next Problem, Help, Group by Severity, Group by Directory, Filter resolved items, Autoscroll to Source, Export (XML/HTML), Edit Settings.
2. CheckStyle
Overview
Focuses on code formatting and style: naming, Javadoc, whitespace, method length, duplicate code, unused imports. Purely syntactic; almost no bug detection.
Bundles two strict default configs (Sun Checks) that flag even well‑known open‑source projects. Custom config files are usually required.
Installation
File > Settings > Plugins > Marketplace→ search "CheckStyle" → install → restart.
Results
Mostly indentation and formatting warnings; can be deprioritized.
3. PMD
Overview
Targets secure coding rules with data‑flow and path analysis. Stronger than CheckStyle. Supports custom rules. Built‑in rules cover:
Potential bugs : empty try/catch/finally/switch blocks.
Dead code : unused variables, parameters, private methods.
Suboptimal code : String/StringBuffer misuse.
Complex expressions : unnecessary if, for replaceable by while.
Duplicate code : copy‑paste duplicates.
Object creation in loops : avoid instantiating inside loops.
Resource closing : ensure Connection, ResultSet, Statement are closed.
Installation
File > Settings > Plugins > Marketplace→ search "PMDPlugin" → install → restart.
Running
Tools > Run PMDscans whole project.
Right‑click file/editor → "Run PMD" scans selected scope.
Choose Pre Defined (built‑in rule sets) or Custom Rules (imported rule files).
Results
Click an issue to jump to source.
Configuration
File > Settings > Other Settings > PMD→ RuleSets tab to manage custom rule files. Options tab includes Skip TestSource to ignore generated test code.
4. FindBugs
Overview
Specializes in bug detection: runtime errors (null pointers, unclosed resources, incorrect string comparison == vs equals()). Provides quick‑fix suggestions.
Installation
File > Settings > Plugins > Marketplace→ search "FindBugs" → install → restart.
Usage
Right‑click file, package, module, or project → "FindBugs" → analyze.
Results
Click an item to locate the exact code.
Bug Categories
Bad practice – coding anti‑patterns.
Dodgy code – confusing/erroneous constructs.
Internationalization – i18n issues.
Performance – inefficiencies.
Experimental – new detectors.
Malicious code vulnerability – security flaws.
Multithreaded correctness – concurrency bugs.
Correctness – general logic errors.
5. SonarLint
Overview
Operates at a higher level than FindBugs. Checks not only static bugs but also code quality, package/class dependencies, coupling, complexity, duplication – overall project health. Two modes: local plugin (self‑review) and SonarQube server (team review).
Installation
File > Settings > Plugins > Marketplace→ search "SonarLint" → install → restart.
Local Analysis
Right‑click project/file → SonarLint → analyze. Results show issues with suggested fixes.
Server‑Bound Configuration
Configure Sonar server : Add connection → Configuration Name, server URL, Login/Password.
Bind project : Choose server connection → Search in list → select project.
Analyze : Same right‑click flow; optionally enable Perform Sonarlint analysis on commit.
Summary & Recommendations
Coding standards : Use Alibaba Java Coding Guidelines alone.
Bug hunting : Combine PMD, FindBugs, SonarLint for complementary coverage: PMD – strong custom‑rule engine, ideal for project‑specific bug patterns. FindBugs – excellent general bug detector; findings useful for onboarding/training. SonarLint – richer rule set, broader scenario coverage than FindBugs.
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 Architect Handbook
Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.
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.
