【Eclipse】【3】checkstyle插件

用途:自动化检查代码是否规范

安装方法:

1,离线安装

(1)下载安装包(http://sourceforge.net/projects/eclipse-cs/

(2)将压缩包中features文件夹和plugins文件夹的复制到eclipse中的根目录中进行覆盖

(3)打开eclipse,Window→Preferences,如果列表中出现了checkstyle的菜单,则表示安装成功了

注:如果启动eclipse时,提示ClassNotFoundException等异常信息,则启动时加上一个“-clean”参数启动即可

2,在线安装

(1)Help → Install New Software → Work with:http://eclipse-cs.sourceforge.net/update 输入后回车 → 底部框框内Select All

注:安装过程中出现警告,直接点OK

导入自己的规则:

(1)Window → Preferences → checkstyle → New... 

(2)Type:External Configuration File;Location:选择文件路径;勾选Protect Checkstyle configuration file → OK

(3)Global check Configurations :选择刚刚导入的文件 → Set as Default

配置:

(1)项目 → 右键 → Properties → Checkstyle → Main → configure... :选择想要用的规范 → Exclude from checking..:选择不用检查的文件 → OK

快捷操作:

(1)项目 → 右键 → Checkstyle → 其中Check Code with Checkstyle为执行代码规范检查

参考博客:

Eclipse中安装和使用CheckStyle - 小明的博客 - CSDN博客
https://blog.csdn.net/qq_36871364/article/details/72472059

原文地址:https://www.cnblogs.com/huashengweilong/p/10808341.html