-
Notifications
You must be signed in to change notification settings - Fork 486
Description
Hello Spotless maintainers,
I'm a new potential contributor and I've been exploring the features of Spotless and comparing them to other code quality tools like checkstyle. I'm very impressed with the focus on automated formatting and I would like to propose a new FormatterStep for Java.
The proposed feature would automatically expand star imports (e.g., import java.util.*
) into explicit, individual class imports (e.g., import java.util.List;
). This aligns well with the Spotless philosophy of automatically fixing common style violations.
Motivation:
Many style guides and tools (like Checkstyle's AvoidStarImport check) recommend against star imports for reasons of clarity and avoiding potential naming conflicts.
Implementing this as a FormatterStep would give users a seamless way to enforce this style rule, turning a linter check into an automated fix.
Example of the proposed change:
Before:
import java.util.*;
public class MyClass {
List<String> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
}
After:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MyClass {
List<String> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
}
I believe this feature would be a valuable addition to Spotless. I am interested in implementing this and submitting a pull request if team thinks it's a worthwhile feature.
Please let me know if this is a feature you would be open to.