Eclipse Checkstyle vs Formatter vs Cleanup?

折月煮酒 提交于 2020-01-07 03:26:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!