Overview of Java Code Quality and Eclipse Plugins
This article introduces five key aspects of Java code quality—coding standards, duplicate code, test coverage, dependency analysis, and complexity analysis—and explains how Eclipse plugins such as CheckStyle, PMD/CPD, EclEmma, JDepend, and Metrics can be configured and used to assess and improve each aspect.
The article begins by defining code quality and listing five essential dimensions: coding standards, duplicate code, test coverage, dependency analysis, and complexity analysis.
For coding standards, it recommends using the CheckStyle Eclipse plugin, showing how to install it, run it on a simple POJO class, and interpret common warnings such as missing package-info.java, missing Javadoc, and improper method modifiers.
It then describes how to customize CheckStyle rules by importing an external configuration file (e.g., sun_checks.xml) and adjusting specific checks like package-info, Javadoc sentence termination, and method/property Javadoc requirements.
Regarding duplicate code, the article introduces PMD’s CPD tool, explains how to invoke it via the Eclipse PMD menu, and suggests reviewing detected clones to decide whether to refactor.
For test coverage, it presents the EclEmma plugin, demonstrates running JUnit tests with coverage enabled, and shows how the resulting coverage report highlights untested code areas.
In the dependency analysis section, JDepend is used to generate metrics such as number of classes, abstract classes, afferent/efferent couplings, abstractness, instability, distance, and cycle count, helping developers assess package stability and design quality.
The complexity analysis part covers the Metrics plugin, detailing how to enable it, open the Metrics view, and interpret results such as cyclomatic complexity to identify overly complex code that may need simplification.
Finally, the article concludes that applying these tools and tailoring their rules to a team’s conventions can significantly improve Java code quality, and it recommends combining local checks with continuous‑integration checks (e.g., via Hudson) for ongoing enforcement.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
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.