Duplicate Imports

ID

java.duplicate_imports

Severity

info

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

Java

Tags

code-style, imports

Description

Reports import statements that appear more than once in the same compilation unit.

Rationale

Duplicate imports are harmless to the compiler but indicate sloppy editing. They clutter the import section, make diff reviews noisier than necessary, and suggest that automated import management is not being used. Removing duplicates keeps the file clean and reduces merge-conflict surface.

// Bad - duplicate import
import java.util.List;
import java.util.Map;
import java.util.List; // duplicate

// Good - each import appears once
import java.util.List;
import java.util.Map;

Remediation

Remove the duplicate import statement. Enable your IDE’s "Organize Imports" feature to manage imports automatically.