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
- Host: GitHub
- URL: https://github.com/vitalibo/pmd-java-rules
- Owner: vitalibo
- Created: 2020-07-26T19:42:03.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-15T04:35:24.000Z (over 5 years ago)
- Last Synced: 2025-07-06T20:08:12.883Z (about 1 year ago)
- Topics: java, pmd
- Language: Java
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# PMD Java Rules
This project contains rulesets for [PMD](https://pmd.github.io) source code analyzer.
[](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
```