问题
I see these 3 features under eclipse. I have an idea about them but I don't know the exact difference between them.
All of them define some type of rule and applies the change. For example :- If you have any unused imports you can remove unused ones based on the settings of either cleanup, formatter or checkstyle. What's the difference between checkstyle, formatter and cleanup?
回答1:
Checkstyle can be used to check for adherence to specific coding standards/conventions. This does not change your code, but only flags lines that are not compliant.
The Formatter is used to make all source code follow specified formatting conventions. It does change your code, e.g. it may indent a certain amount, move brackets to a new line, break long lines, or other such operations.
Cleanup is more generic and may also change your code. It may call e.g. the formatter, organise imports (adding or removing them as necessary), add missing annotations, or remove unused code.
In a nutshell, Checkstyle only checks for rules, but does not modify code, the Formatter modifies source files but only does changes related to formatting, while Cleanup not only changes source files, but may also change code by adding or removing lines.
回答2:
CheckStyle - Its is an example for SCA(Static code analysis) tool. Other SCA tools for Java.
Formatter - Limited to only formatting your source code.
Cleanup - Formatter + Something more(Like removing trailing spaces, sorting member etc)
To know the exact difference between Cleanup and Formatter
. Create new profile for each one of these and check the difference. Refer this.
来源:https://stackoverflow.com/questions/23652606/eclipse-checkstyle-vs-formatter-vs-cleanup