alibaba / p3c Goto Github PK
View Code? Open in Web Editor NEWAlibaba Java Coding Guidelines pmd implements and IDE plugin
Home Page: https://github.com/alibaba/p3c/wiki
License: Apache License 2.0
Alibaba Java Coding Guidelines pmd implements and IDE plugin
Home Page: https://github.com/alibaba/p3c/wiki
License: Apache License 2.0
如题
如图,“下标为[ list.size() ]的数组元素将被置为 null”,该描述不够精确。
Java Doc中的描述为“If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to null.)”
修改为“下标为从list.size()至数组末尾的全部元素将被置为 null”是不是更合适些呢?
public static final String Car_CA_72 = "红旗CA72";
使用默认的 inspection 修正的结果是 CAR__C_A_72
应该为 CAR_C_A_72
CAR 后面多了一个 _
包含对用户进行简单的增删改查, 完整的单元测试,以及相关的说明.以及如何利用云效平台,做代码开发跟相关测试工作,我可以这段时间可以出一个简单的dome,希望阿里的人给与指正下.共同出一份在云效平台上面使用的帮助说明.谢谢,麻烦你们的,这个要求很无理,但希望得到你们的支持跟帮助.
举一个case:
p3c扫描出如下问题:抽象类Service没有以Abstract或者Base打头命名。我修改了类名为:AbstractService,这时候再次点击“代码扫描建议”不能定位到对应的类。体验不是很好。
建议:在开发者修改了代码之后,立即触发对该类的重新扫描,并自动清理已经修复的问题描述。
建议增加jenkins插件,方便持续集成时自动检测
手动遵守不如在IDE设置好,我按着这个规约和谷歌HTML CSS双空格等规范设置了一个,不过总觉得没有官方出的好,希望官方出设置导出文件。
展开提示(ctrl + f1)里的文字正常显示
请问是环境的原因吗?
(Android Studio 3.0 beta 7, Ubuntu 17.04)
什么时候支持kotlin呢?
用IDEA可以选择某一条条规则不生效或修改级别, 但eclipse里面只能看到条目, 无法设置单条是否生效以及调整级别
另外关于类名大驼峰的检查, 有一些领域模型的保留字, 希望这部分可以自定义添加保留字, 情景比如 : 在类名的命名上会加入公司名的缩写, 这个缩写都是全大写的
命名风格第九条是这样说的
- 【强制】包名统一使用小写,点分隔符之间有且仅有一个自然语义的英语单词。包名统一使用单数形式,但是类名如果有复数含义,类名可以使用复数形式。
但是常量定义第4条是这样说的
- 【推荐】常量的复用层次有五层:跨应用共享常量、应用内共享常量、子工程内共享常量、包内共享常量、类内共享常量。 1) 跨应用共享常量:放置在二方库中,通常是client.jar中的constant目录下。 2) 应用内共享常量:放置在一方库中,通常是modules中的constant目录下。
请问这个modules是指包名吗?
在 @interface 中写的 常量,本身默认含有 public static final 修饰,命名按照常量规范命名,但是规约插件检测为变量,提示 不符合 lowerCamelCase 命名规范
Noncompliant Code Example
System.out.println("My Message"); // Noncompliant
Compliant Solution
logger.log("My Message");
Noncompliant Code Example
try {
/* ... /
} catch(Exception e) {
e.printStackTrace(); // Noncompliant
}
Compliant Solution
try {
/ ... */
} catch(Exception e) {
LOGGER.log("context", e);
}
昨天简单实用了下插件,提交的小建议,参照sonarlint
我的AndroidStudio 安装不上 其他的插件都可以 就这个安装不上
尽量不要在接口里定义变量,如果一定要定义变量,肯定是与接口方法相关,并且是整个应用的基础常量。
这句话有歧义,既然已经说是变量(variable)了,怎么能是基础常量(constant)呢?
Eclipse版本:Version: Neon.2 Release (4.6.2)
JDK:1.8
使用Eclipse扫描结束后,打开扫描结果直接卡死。改用IDEA后一直正常!
其他人是否有类似情况?
电子工业版本社也将在一年后出版孤 参与编写的“码出高效 - 阿里巴巴的Java开发手册详解”这本书。
孤->孤尽
因为有时某些包不是自己负责的
规范很细,但是各个公司对于规范的落地细节不一样,有些细则可以选择忽略,期望支持:rule可配置特性。让使用者选择性地使用rule 。
现在很多企业还是采用MyEclipse 10开发的,而其包含的Eclipse版本是3.7,无法用现在发布的插件
例如一些生成的代码,扫描后一大堆问题...
protobuf 生成的检测出来的问题相当多...还有部分mybatis生成的代码~
能否有个功能排除掉部分包?
还有些是第三方规定的package路径,里面有大写只有一个包名的情况.
VO大多数资料都是Value Object,规约用View Object是为什么呢?参考https://m.runoob.com/design-pattern/data-access-object-pattern.html
挨个点太多了。。
Inteillj 插件
《Effective Java》中写到过
The constant interface pattern is a poor use of interfaces. That a class uses some constants internally is an implementation detail. Implementing a constant interface causes this implementation detail to leak into the class’s exported API. It is of no consequence to the users of a class that the class implements a constant interface. In fact, it may even confuse them. Worse, it represents a commitment: if in a future release the class is modified so that it no longer needs to use the constants, it still must implement the interface to ensure binary compatibility. If a nonfinal class implements a constant interface, all of its subclasses will have their namespaces polluted by the constants in the interface.
package com.alibaba.p3c.idea;下面的两个Constants常量就使用了interface来定义常量,如何看待此类问题?
Some class names that contains IOS,GUI will not match upperCamelCase pattern.
Hope to allow add custom item to CLASS_NAMING_WHITE_LIST.
p3c/p3c-pmd/src/main/resources/namelist.properties
...
ClassNamingShouldBeCamelRule_CLASS_NAMING_WHITE_LIST=["Hbase","HBase","ID"]
应该修改为如下:
List<String> list = new ArrayList<String>();
list.add("1");
list.add("2");
for (String item : list) {
if ("1".equals(item)) {
list.remove(item);
}
}
在IDEA中 对某些代码块/方法/类 设置了 @SuppressWarnings("AliDeprecation")后重新扫描,还是会提示警告.
有没有提供命令行运行方式,比如执行mvn xxx就可以在workspace下生成对应的扫描结果文件
如题
每次都要到类那里右键点一下,很不自动化
插件安装之后,菜单中的中文无法显示,尝试更换字体无效!
我只会用maven 很尴尬
试了下mac 下面的 eclipse oxygen,分析了一个工程之后IDE卡住,CPU120+%,很多JPA在跑,是什么原因呢?
希望能有Netbeans的插件
diamond运算符可以减少代码行长度,让代码看着更整洁。
手册中提到的Java开发规约插件是基于IDE的吗,支持哪些IDE呢?
在此感谢阿里Java技术团队对Java项目的工程性和规范性进行了非常有价值的提炼,帮助国内Java相关从业者和团队不断进步。
感觉每次编译都会自动扫描。
例如使用Executors.newSingleThreadScheduledExecutor
这种没有必要手动创建吧
Myeclipse 2017 进行工程校验的时候,结果是一直累积上去的 , 之前工程的结果一直在缓存在列表中。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.