简体   繁体   English

Eclipse Checkstyle与Formatter与Cleanup?

[英]Eclipse Checkstyle vs Formatter vs Cleanup?

I see these 3 features under eclipse. 我在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? checkstyle,formatter和cleanup有什么区别?

Checkstyle can be used to check for adherence to specific coding standards/conventions. Checkstyle可用于检查是否符合特定的编码标准/惯例。 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. Formatter用于使所有源代码遵循指定的格式约定。 It does change your code, eg 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 eg 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. 简而言之,Checkstyle仅检查规则,而不修改代码,Formatter修改源文件,但仅进行与格式相关的更改,而Cleanup不仅更改源文件,而且还可以通过添加或删除行来更改代码。

CheckStyle - Its is an example for SCA( Static code analysis ) tool. CheckStyle-这是SCA( 静态代码分析 )工具的示例。 Other SCA tools for Java . Java的其他SCA工具。

Formatter - Limited to only formatting your source code. Formatter-仅限于格式化源代码。

Cleanup - Formatter + Something more(Like removing trailing spaces, sorting member etc) 清理-格式化程序+其他功能(例如删除尾随空格,排序成员等)

To know the exact difference between Cleanup and Formatter . 要了解Cleanup and Formatter的确切区别。 Create new profile for each one of these and check the difference. 为其中每个创建新的配置文件,并检查差异。 Refer this . 请参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM