p3c-pmd

Alibaba Java Coding Guidelines PMD implementations

License

License

Categories

Categories

PMD Application Testing & Monitoring Code Analysis
GroupId

GroupId

io.github.spafka.p3c
ArtifactId

ArtifactId

p3c-pmd
Last Version

Last Version

alibaba.2.0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

p3c-pmd
Alibaba Java Coding Guidelines PMD implementations
Project URL

Project URL

https://github.com/alibaba/p3c
Project Organization

Project Organization

Alibaba Group
Source Code Management

Source Code Management

https://github.com/alibaba/p3c

Download p3c-pmd

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.spafka.p3c/p3c-pmd/ -->
<dependency>
    <groupId>io.github.spafka.p3c</groupId>
    <artifactId>p3c-pmd</artifactId>
    <version>alibaba.2.0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.spafka.p3c/p3c-pmd/
implementation 'io.github.spafka.p3c:p3c-pmd:alibaba.2.0.1.0'
// https://jarcasting.com/artifacts/io.github.spafka.p3c/p3c-pmd/
implementation ("io.github.spafka.p3c:p3c-pmd:alibaba.2.0.1.0")
'io.github.spafka.p3c:p3c-pmd:jar:alibaba.2.0.1.0'
<dependency org="io.github.spafka.p3c" name="p3c-pmd" rev="alibaba.2.0.1.0">
  <artifact name="p3c-pmd" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.spafka.p3c', module='p3c-pmd', version='alibaba.2.0.1.0')
)
libraryDependencies += "io.github.spafka.p3c" % "p3c-pmd" % "alibaba.2.0.1.0"
[io.github.spafka.p3c/p3c-pmd "alibaba.2.0.1.0"]

Dependencies

compile (4)

Group / Artifact Type Version
net.sourceforge.pmd : pmd-java jar 6.15.0
net.sourceforge.pmd : pmd-vm jar 6.15.0
javax.annotation : javax.annotation-api jar 1.3.2
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.50

test (1)

Group / Artifact Type Version
net.sourceforge.pmd : pmd-test jar 6.15.0

Project Modules

There are no modules declared in this project.

P3C

License

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.
io.github.spafka.p3c

Alibaba

Alibaba Open Source

Versions

Version
alibaba.2.0.1.0