Hi Vladimir,
thanks for a post, sorry for late reply to you.
Your ideas are in right direction.
Some comments on your post:
> provide suggestions to fix the violations automatically ......
Checkstyle is library , it is not a IDE plugin, so automation of fix we should ask to implement IDE's plugins.
--------------------
So lets focus on what Checkstyle could do to ease developer's life to fix its violations:
1) accumulate violations in one violation message
2) somehow show what is expected
"1)" point is kind of reasonable.
"2)" point is not that obvious from reporting point of view:
a) message could not be multi-line string, in other case all checkstyle reports and viewers will be broken. Good example from life codding is Exception stack trace in log file and how log viewers manage to show it correctly - it doers not work .
b) Reporting huge amount of imports as one line - is unreadable. Beware that list of 30-40 imports is well spread in real code.
~/java/git/checkstyle/checkstyle [master ↓·1|✔] $ grep -R -c 'import ' . | grep -e '\.java\:[2-9][0-9]'
./contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ClassFileSetCheck.java:23
./contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ReferenceVisitor.java:21
./src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportTest.java:20
./src/main/java/com/puppycrawl/tools/checkstyle/Checker.java:28
./src/main/java/com/puppycrawl/tools/checkstyle/gui/ParseTreeInfoPanel.java:25
./src/main/java/com/puppycrawl/tools/checkstyle/gui/FileDrop.java:21
./src/main/java/com/puppycrawl/tools/checkstyle/gui/JTreeTable.java:26
./src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java:28
So printDesiredOrder is not a good name and concept, as Checkstyle should bind message to certain token in file, and checkstyle does not know where message will be printed (console, DB, HTML, in-memory container, IDE hint , ...... ).
We need to look at this as "accumulation of order violation", report on first import token and now we need to think how to report even in single line as user could read this. .... I open for proposals.
I could make a hint to similar problem in
CustomOrderDeclarationCheck, in that check we report a order violation on each element but we print what type of element is expected.
Example: "49:5: Method definition in wrong order. Expected 'GetterSetter(.*)' then 'Method(.*)' ".
truth is somewhere there .....
PS and out-of-context:
I still remember about your other PRs, just do not have time to review them attentively, sorry.
thanks,
Roman Ivanov