(Apologies if this has been discussed already or is being tracked elsewhere--I couldn't find it in a few minutes of searching.)
Phabricator provides an API for autofixing simple lint issues by providing an original and replacement string, in addition to the line and column number. This can be super useful for fixing tedious issues and, in extreme cases, can even allow you to bypass a second lint check despite some initial failures.
(As an example: here are some of the rules that ESLint can autofix.)
I'm curious if there has even been any discussion of supporting autofix in Checkstyle (i.e., in the output XML, using an error level of autofix and providing said original and replacement text, so that this information can be passed to the Phabricator API).
In a recent hackathon, I was able to fork Checkstyle and add reliable autofix for a number of rules (FinalParameterCheck, FinalLocalVariableCheck, WhitespaceAroundCheck, UnusedImportCheck etc.) as a proof-of-concept. Of course, not every rule is autofixable, though there do seem to be some other viable candidates (ArrayTrailingCommaCheck, NewlineAtEndOfFileCheck, ModifierOrderCheck, etc.).
Look forward to hearing your thoughts.
checkstyle is library it is not a tool with only one usage.
All that is very desirable functionality of IDE plugins(Eclipse, Idea, Netbeans,...), build system plugins(ant, maven, gradle,...) and other extensions (Sonar,......). Please create issues on such projects (all of them maintained by different teams). Some projects most likely already have smth similar as talks about this is going for a while.
We host only CLI and ANT extensions.
If you want to discuss this issue more please be welcome to our mail-list .......
@crm416
I think auto-fixing simple and auto-fixable style issues is a must-have. For example, if I convert a 2-space indentation code base to using 4-space indentation or vice versa, the auto-fixing, even when it is not perfect, is extremely helpful.
I do want to see your proof-of-concept and maybe start using and contributing.
everyone is welcome to start project and make it happen. For now lets host it some where out of main project, we do too much stuff already. As some prototype be ready we can join new project to chekcstyle organization later on.