chiyutianyi / p3c

Alibaba Java Coding Guidelines pmd implements and IDE plugin

Home Page:https://github.com/alibaba/p3c/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

P3C

License Quality Gate Status p3c-cmd

idea plugin idea plugin(p3c-common)

Notice 声明

This Third-party maintenance(TPM) here is forked from original alibaba/p3c

Follows Apache license described in license

Sources can be found https://github.com/XenoAmess/p3c

Releases can be found at https://plugins.jetbrains.com/plugin/14109-alibaba-java-coding-guidelines-xenoamess-tpm-

This TPM aims to help maintain alibaba/p3c, fix bugs, and add improvements, as the original developer is too busy to handle them.

This TPM is NOT created, or maintained, or controlled by any alibaba employee, in other words it is a TPM, but not an official branch.

TPM maintainer XenoAmess have no knowledge with eclipse plugin development.

TPM maintainer XenoAmess suggest you only create pr for module idea-plugin and p3c-pmd, unless you really have a strong reason.

Features 特性

  1. This TPM can always run on latest Jetbrains-idea release/EAP.

    本第三方维护版会在任何 Jetbrains-idea release 或者EAP更新时保证可用。

  2. This TPM will always use as latest dependencies as possible.

    本第三方维护版会使用尽可能新的依赖版本。

  3. This TPM implements a mechanism for configuring black-list/white-list for rules/classes

    本第三方维护版实现有一套配置系统,可以对源码类/规则进行黑名单/白名单过滤。

  4. This TPM does NOT fully obey p3c rules. Especially for the rule who disable deprecated functions. Maintainer XenoAmess will make sure they are usable, but have no enough time to eliminate every deprecated functions.

    本第三方维护版不完全遵循p3c,尤其是关于禁止使用deprecated函数的规则。 维护者XenoAmess会保证函数可用,但是没有充裕的时间保证消灭每一个deprecated函数。

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:

Introduction 介绍

The project consists of 3 parts:

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.

Config Mechanism 配置机制

see

documents

说明

About

Alibaba Java Coding Guidelines pmd implements and IDE plugin

https://github.com/alibaba/p3c/wiki

License:Apache License 2.0


Languages

Language:Java 60.7%Language:Kotlin 38.9%Language:Batchfile 0.3%Language:FreeMarker 0.0%Language:CSS 0.0%