Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alibaba/p3c
Alibaba Java Coding Guidelines pmd implements and IDE plugin
https://github.com/alibaba/p3c
Last synced: 3 days ago
JSON representation
Alibaba Java Coding Guidelines pmd implements and IDE plugin
- Host: GitHub
- URL: https://github.com/alibaba/p3c
- Owner: alibaba
- License: apache-2.0
- Created: 2017-06-23T06:15:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T08:22:02.000Z (4 months ago)
- Last Synced: 2024-10-29T10:54:56.312Z (about 1 month ago)
- Language: Kotlin
- Homepage: https://github.com/alibaba/p3c/wiki
- Size: 25.8 MB
- Stars: 30,446
- Watchers: 1,309
- Forks: 8,066
- Open Issues: 184
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
- awesome - alibaba/p3c - Alibaba Java Coding Guidelines pmd implements and IDE plugin (Kotlin)
- awesome-kotlin - p3c - Alibaba Java Coding Guidelines pmd implements and IDE plugin (Libraries)
- my-awesome - alibaba/p3c - 08 star:30.5k fork:8.1k Alibaba Java Coding Guidelines pmd implements and IDE plugin (Kotlin)
- awesome-java - p3c
- Awesome-GitHub-Repo - p3c - Java 代码规约扫描插件,IntelliJ IDEA 搜索这款插件安装,时刻监控你写的代码规不规范。[<img src="https://tva1.sinaimg.cn/large/008i3skNly1gxlhtmg11mj305k05k746.jpg" alt="微信" width="18px" height="18px" />](https://mp.weixin.qq.com/s?__biz=MzUxNjg4NDEzNA%3D%3D&chksm=f9a22984ced5a092b79362bb18932e8895ed01dba198513522bf50bec33c1458dd29805bd4da&idx=1&mid=2247498317&scene=21&sn=8d67a6067e8a30d2bc6548c3756621ad#wechat_redirect) (大厂开源 / 阿里开源)
- awesome-java-zh - p3c - 提供阿里巴巴的PMD、IDEA和Eclipse的编码指南。 (项目 / 代码分析)
- awesome-starts - alibaba/p3c - Alibaba Java Coding Guidelines pmd implements and IDE plugin (Kotlin)
- awesome-made-by-chinese - p3c
- awesome-java - p3c - Provides Alibaba's coding guidelines for PMD, IDEA and Eclipse. (Projects / Code Analysis)
- awesome-hacking-lists - alibaba/p3c - Alibaba Java Coding Guidelines pmd implements and IDE plugin (Kotlin)
- StarryDivineSky - alibaba/p3c
README
# P3C
最新版本:黄山版(2022.2.3发布)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
## Preface
> We are pleased to present Alibaba Java Coding Guidelines which consolidates the best programming practices over the years from Alibaba Group's technical teams. A vast number of Java programming teams impose demanding requirements on code quality across projects as we encourage reuse and better understanding of each other's programs. We have seen many programming problems in the past. For example, defective database table structures and index designs may cause software architecture flaws and performance risks. Another example is confusing code structures being difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address these kinds of problems, we developed this document for Java developers at Alibaba.
For more information please refer the *Alibaba Java Coding Guidelines*:
- 中文版: 直接下载上方的PDF文件(黄山版)
- English Version: *[Alibaba Java Coding Guidelines](https://alibaba.github.io/Alibaba-Java-Coding-Guidelines)*## Introduction
The project consists of 3 parts:
- [PMD implementations](p3c-pmd)
- [IntelliJ IDEA plugin](idea-plugin)
- [Eclipse plugin](eclipse-plugin)## Rules
Forty-nine rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. Four rules are implemented within IDE plugins (IDEA and Eclipse) as follows:- ``[Mandatory]`` Using a deprecated class or method is prohibited.
Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is.
- ``[Mandatory]`` An overridden method from an interface or abstract class must be marked with @Override annotation.
Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately.
- ``[Mandatory]`` A static field or method should be directly referred by its class name instead of its corresponding object name.- ``[Mandatory]`` The usage of hashCode and equals should follow:
1. Override hashCode if equals is overridden.
2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set.
3. These two methods must be overridden if self-defined object is used as the key of Map.
Note: String can be used as the key of Map since these two methods have been rewritten.