An open API service indexing awesome lists of open source software.

https://github.com/vitalibo/pmd-java-rules

PMD custom Java rules
https://github.com/vitalibo/pmd-java-rules

java pmd

Last synced: 9 months ago
JSON representation

PMD custom Java rules

Awesome Lists containing this project

README

          

# PMD Java Rules

This project contains rulesets for [PMD](https://pmd.github.io) source code analyzer.

[![Build Status](https://travis-ci.org/vitalibo/pmd-java-rules.svg?branch=master)](https://travis-ci.org/vitalibo/pmd-java-rules)

## Usage
### Maven 3

In order to use PMD with [Maven](https://maven.apache.org), you need add `maven-pmd-plugin` to your `pom.xml` with following configuration:

```xml

6.26.0



org.apache.maven.plugins
maven-pmd-plugin


verify

check
cpd-check





target/generated-sources


https://raw.githubusercontent.com/vitalibo/pmd-java-rules/master/ruleset.xml

true
false
true
${java.version}
${project.build.sourceEncoding}






org.apache.maven.plugins
maven-pmd-plugin
3.13.0


net.sourceforge.pmd
pmd-core
${pmd.version}


net.sourceforge.pmd
pmd-java
${pmd.version}


net.sourceforge.pmd
pmd-javascript
${pmd.version}


net.sourceforge.pmd
pmd-jsp
${pmd.version}


com.github.vitalibo
pmd-java-rules
1.0-SNAPSHOT




```
more details you can find on an [official page](https://pmd.github.io/pmd-6.26.0/pmd_userdocs_tools_maven.html).

If you want to use my custom rules (DependencyInversion, AvoidClassName, etc), you need add dependency on this project:

```xml


com.github.vitalibo
pmd-java-rules
1.0.0


vitalibo-mvnrepo
https://raw.github.com/vitalibo/public-maven-repository/release/

true
always

```

## Rule Reference
### Design
#### DependencyInversion

Priority: High (1)

Rule catches cases where broken dependency inversion principle in onion architecture, namely,
if the class from the core layer has a dependency on the infrastructure layer.

This rule is defined by the following Java class: [com.github.vitalibo.pmd.lang.java.rule.design.DependencyInversionRule](src/main/java/com/github/vitalibo/pmd/lang/java/rule/design/DependencyInversionRule.java)

Example(s):

```java
package com.github.vitalibo.core;

import com.github.vitalibo.core.Bar;
import com.github.vitalibo.infrastructure.Baz; // bad

public class Foo {
}
```

Use this rule by referencing it:

```xml

```

### Code Style
#### AvoidClassName

Priority: High (1)

Configurable naming for classes that must avoid.
This rule reports type declarations which match the regex that applies to class names.
By default, this rule raises when the developer creates generic utils or helpers classes.

This rule is defined by the following Java class: [com.github.vitalibo.pmd.lang.java.rule.codestyle.AvoidClassNameRule](src/main/java/com/github/vitalibo/pmd/lang/java/rule/codestyle/AvoidClassNameRule.java)

Use this rule by referencing it:

```xml



```

#### BlacklistClassUsage

Priority: High (1)

Black-list classes which should not be used in your code.

This rule is defined by the following Java class: [com.github.vitalibo.pmd.lang.java.rule.codestyle.BlacklistClassUsageRule](src/main/java/com/github/vitalibo/pmd/lang/java/rule/codestyle/BlacklistClassUsageRule.java)

Example(s):

```java
import lombok.val; // bad

public class Foo {

public void test() {
val foo = null;
}
}
```

Use this rule by referencing it:

```xml



```