在eclipse中替换新的规则集的方法

本文介绍如何在Eclipse中替换Checkstyle和PMD规则集,以及如何更新代码格式化模板,帮助开发者遵循统一的代码风格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:41251868; mso-list-type:hybrid; mso-list-template-ids:368586766 -885864562 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-text:%1、; mso-level-tab-stop:18.0pt; mso-level-number-position:left; margin-left:18.0pt; text-indent:-18.0pt;} @list l1 {mso-list-id:790708620; mso-list-type:hybrid; mso-list-template-ids:-486922460 794881982 -72042314 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-number-format:japanese-counting; mso-level-text:%1、; mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt;} @list l1:level2 {mso-level-text:%2、; mso-level-tab-stop:39.0pt; mso-level-number-position:left; margin-left:39.0pt; text-indent:-18.0pt;} @list l2 {mso-list-id:1604606459; mso-list-type:hybrid; mso-list-template-ids:717644204 110400524 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l2:level1 {mso-level-start-at:3; mso-level-text:%1、; mso-level-tab-stop:39.0pt; mso-level-number-position:left; margin-left:39.0pt; text-indent:-18.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

eclipse 中替换新的规则集的方法

一、 替换 checkstyle 规则集

1、  eclipse 中, ”window à preferences” ,并在左侧树状列表中选中 checkstyle 选项,弹出如下窗口。

2、  点击 ”new” 按钮,弹出如下窗口:

其中:

Type :选择 External Configuration File

Name :可以自由为将要导入的规则集起一个名字。

Location :要导入的规则集的位置,在我们的 eclipse 软件中有一个 MyRuleSet 文件夹,里面有最新的规则集 checkstyle_ruleset_minimal.xml ,选中即可。

3、  点击“ OK ”,则原来的 preferences 窗口的 Globle Check Configuration 框中会增加一个选项,如下图所示。

4、  选中该规则集,并点击“ set as Default ”,在该规则集后的“ default ”选项中会有个对勾,说明该规则集已经变成默认规则集,如下图。

5 、点击“ OK ”,结束。

 

二、 替换 PMD 规则集

1、  eclipse 中, ”window à preferences” ,弹出如下窗口。

2 、在左侧树状列表中选中 ”PMD à RulesConfiguration” 选项卡,弹出如下窗口。

 

3、  点击“ clear all ”,清空原有的规则,如下图所示。

4、  并点击“ import rule set ”,弹出如下框,点击“ browse ”按钮,参考 checkstyle 的方法,在 MyRuleSet 文件夹中找到最新的 PMD 规则集 pmd_ruleset_minimal.xml ,如下图。

5、  点击“ OK ”,导入规则集之后的窗口如下图所示。

6 、点击“ OK ”,结束。

三、 替换代码格式化模板(包括 Formatter Code Templates

1 Formatter Code Templates 规则存放位置在 eclipse/CodeFormat 目录下

2 Formatter

 

 

 

 

 

3 CodeTemplates

 

选中即可。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值