一、说明
代码规范检查插件p3c,是根据《阿里巴巴Java开发手册》转化而成的自动化插件。
(高级黑:P-3C“Orion”,反潜巡逻机,阿里大概取p3c先进,监测,发现潜在问题的意思)

二、源码地址
https://github.com/alibaba/p3c
阿里巴巴Java开发手册
一、说明
《阿里巴巴Java开发手册》旨在码出高效,码出质量。
二、目的
标准化,正规化,高效协同。
三、下载
阿里代码规范设置
一、eclipse
【https://www.eclipse.org/downloads/】
二、eclipse代码规范
1. 下载
【p3c-formatter】:【https://github.com/alibaba/p3c/tree/master/p3c-formatter】

2. 导入代码格式化样式

3. 导入代码格式文件

三、eclipse插件
1. 下载
【p3c-eclipse-plugin】:【https://p3c.alibaba.com/plugin/eclipse/update】

2. 将【features】及【plugins】复制到eclipse目录,重启eclipse
3. 编写测试文件
[
](javascript:void(0); "复制代码")
<pre style="margin: 0px 0px 0px 22px; white-space: pre-wrap; overflow-wrap: break-word; font-size: 12px !important; font-family: "Courier New" !important;">/** * @author lsysy
- @date 2018/11/13 */
public class Test { public static void main(String[] args) {
String Ba = "Ba"; if ("Ba" == Ba) {
System.out.println(Ba);
}
}
}</pre>

](javascript:void(0); "复制代码")
4. 点击
image
进行阿里编码规约扫描(如果不可用,点击

切换语言,再切换回来,重启即可)

5. 可选(设置eclipse保存时自动格式化)

四、idea
【https://blog.csdn.net/mashuai720/article/details/79389314】
五、idea插件
1. 下载
【p3c-idea-plugin】:【https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines】

【eclipse-code-formatter】:【https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter】

【save-actions-plugin】:【https://plugins.jetbrains.com/plugin/7642-save-actions】

2. 安装

3. 使用

六、idea代码规范
1. 准备

FileHeader
2. 写入文件头注释

3. 导入代码格式化样式(导入eclipse-codestyle.xml)

4. 可选(设置idea保存时自动格式化)

网友评论