checkstyle / checkstyle/checkstyle

RedundantImportCheck does not detect specific and wildcard imports from the same package

Open
#6,450 9 comments 0 reactions 0 assignees View on GitHub
approved
Dominant language
Java
Stars
9.6k
Forks
4.2k
Avg merge
22h 23m
Merged PRs (30d)
232

Description

https://checkstyle.org/config_imports.html#RedundantImport

```
/var/tmp $ javac TestClass.java

/var/tmp $ cat checkstyle.xml



/var/tmp $ cat TestClass.java
import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class TestClass {
private List list = new ArrayList<>();
}

/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-8.17-all.jar -c checkstyle.xml TestClass.java
Starting audit...
Audit done.

```
same behavior is on checkstyle 13.9.0

---------------
Checkstyle reports no errors here

I expect Checkstyle to report violations:

- on line 2 that says that `java.util.ArrayList` import is redundant
- on line 3 that says that `java.util.List` import is redundant

--------------

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.