{"id":18678340,"url":"https://github.com/vitalibo/pmd-java-rules","last_synced_at":"2025-10-13T04:39:49.876Z","repository":{"id":101159635,"uuid":"282720954","full_name":"vitalibo/pmd-java-rules","owner":"vitalibo","description":"PMD custom Java rules","archived":false,"fork":false,"pushed_at":"2020-12-15T04:35:24.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-06T20:08:12.883Z","etag":null,"topics":["java","pmd"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitalibo.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-26T19:42:03.000Z","updated_at":"2020-12-15T04:35:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"92b1111a-0663-480b-a48a-a51c8195643e","html_url":"https://github.com/vitalibo/pmd-java-rules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vitalibo/pmd-java-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalibo%2Fpmd-java-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalibo%2Fpmd-java-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalibo%2Fpmd-java-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalibo%2Fpmd-java-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitalibo","download_url":"https://codeload.github.com/vitalibo/pmd-java-rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalibo%2Fpmd-java-rules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013685,"owners_count":26085390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","pmd"],"created_at":"2024-11-07T09:37:17.747Z","updated_at":"2025-10-13T04:39:49.850Z","avatar_url":"https://github.com/vitalibo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PMD Java Rules\n\nThis project contains rulesets for [PMD](https://pmd.github.io) source code analyzer.\n\n[![Build Status](https://travis-ci.org/vitalibo/pmd-java-rules.svg?branch=master)](https://travis-ci.org/vitalibo/pmd-java-rules)\n\n## Usage\n### Maven 3\n\nIn order to use PMD with [Maven](https://maven.apache.org), you need add `maven-pmd-plugin` to your `pom.xml` with following configuration:\n\n```xml\n\u003cproperties\u003e\n    \u003cpmd.version\u003e6.26.0\u003c/pmd.version\u003e\n\u003c/properties\u003e\n\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n            \u003cartifactId\u003emaven-pmd-plugin\u003c/artifactId\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cphase\u003everify\u003c/phase\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003echeck\u003c/goal\u003e\n                        \u003cgoal\u003ecpd-check\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n            \u003cconfiguration\u003e\n                \u003cexcludeRoots\u003e\n                    \u003cexcludeRoot\u003etarget/generated-sources\u003c/excludeRoot\u003e\n                \u003c/excludeRoots\u003e\n                \u003crulesets\u003e\n                    \u003cruleset\u003ehttps://raw.githubusercontent.com/vitalibo/pmd-java-rules/master/ruleset.xml\u003c/ruleset\u003e\n                \u003c/rulesets\u003e\n                \u003cfailOnViolation\u003etrue\u003c/failOnViolation\u003e\n                \u003clinkXRef\u003efalse\u003c/linkXRef\u003e\n                \u003cprintFailingErrors\u003etrue\u003c/printFailingErrors\u003e\n                \u003ctargetJdk\u003e${java.version}\u003c/targetJdk\u003e\n                \u003csourceEncoding\u003e${project.build.sourceEncoding}\u003c/sourceEncoding\u003e\n            \u003c/configuration\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n    \u003cpluginManagement\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n                \u003cartifactId\u003emaven-pmd-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e3.13.0\u003c/version\u003e\n                \u003cdependencies\u003e\n                    \u003cdependency\u003e\n                        \u003cgroupId\u003enet.sourceforge.pmd\u003c/groupId\u003e\n                        \u003cartifactId\u003epmd-core\u003c/artifactId\u003e\n                        \u003cversion\u003e${pmd.version}\u003c/version\u003e\n                    \u003c/dependency\u003e\n                    \u003cdependency\u003e\n                        \u003cgroupId\u003enet.sourceforge.pmd\u003c/groupId\u003e\n                        \u003cartifactId\u003epmd-java\u003c/artifactId\u003e\n                        \u003cversion\u003e${pmd.version}\u003c/version\u003e\n                    \u003c/dependency\u003e\n                    \u003cdependency\u003e\n                        \u003cgroupId\u003enet.sourceforge.pmd\u003c/groupId\u003e\n                        \u003cartifactId\u003epmd-javascript\u003c/artifactId\u003e\n                        \u003cversion\u003e${pmd.version}\u003c/version\u003e\n                    \u003c/dependency\u003e\n                    \u003cdependency\u003e\n                        \u003cgroupId\u003enet.sourceforge.pmd\u003c/groupId\u003e\n                        \u003cartifactId\u003epmd-jsp\u003c/artifactId\u003e\n                        \u003cversion\u003e${pmd.version}\u003c/version\u003e\n                    \u003c/dependency\u003e\n                    \u003cdependency\u003e\n                        \u003cgroupId\u003ecom.github.vitalibo\u003c/groupId\u003e\n                        \u003cartifactId\u003epmd-java-rules\u003c/artifactId\u003e\n                        \u003cversion\u003e1.0-SNAPSHOT\u003c/version\u003e\n                    \u003c/dependency\u003e\n                \u003c/dependencies\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/pluginManagement\u003e\n\u003c/build\u003e\n```\nmore details you can find on an [official page](https://pmd.github.io/pmd-6.26.0/pmd_userdocs_tools_maven.html).\n\nIf you want to use my custom rules (DependencyInversion, AvoidClassName, etc), you need add dependency on this project:\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.vitalibo\u003c/groupId\u003e\n        \u003cartifactId\u003epmd-java-rules\u003c/artifactId\u003e\n        \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003evitalibo-mvnrepo\u003c/id\u003e\n        \u003curl\u003ehttps://raw.github.com/vitalibo/public-maven-repository/release/\u003c/url\u003e\n        \u003csnapshots\u003e\n            \u003cenabled\u003etrue\u003c/enabled\u003e\n            \u003cupdatePolicy\u003ealways\u003c/updatePolicy\u003e\n        \u003c/snapshots\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n## Rule Reference\n### Design\n#### DependencyInversion\n\nPriority: High (1)\n\nRule catches cases where broken dependency inversion principle in onion architecture, namely, \nif the class from the core layer has a dependency on the infrastructure layer.\n\nThis 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)\n\nExample(s):\n\n```java\npackage com.github.vitalibo.core;\n\nimport com.github.vitalibo.core.Bar;\nimport com.github.vitalibo.infrastructure.Baz; // bad\n\npublic class Foo {\n}\n```\n\nUse this rule by referencing it:\n\n```xml\n\u003crule ref=\"vitalibo/java/design.xml/DependencyInversion\" /\u003e\n```\n\n### Code Style\n#### AvoidClassName\n\nPriority: High (1)\n\nConfigurable naming for classes that must avoid.\nThis rule reports type declarations which match the regex that applies to class names.\nBy default, this rule raises when the developer creates generic utils or helpers classes.\n\nThis 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)\n\nUse this rule by referencing it:\n\n```xml\n\u003crule ref=\"vitalibo/java/codestyle.xml/AvoidClassName\"\u003e\n    \u003cproperties\u003e\n        \u003cproperty name=\"pattern\" value=\".*(Utils?|Constants)|Translators?\"/\u003e\n    \u003c/properties\u003e\n\u003c/rule\u003e\n```\n\n#### BlacklistClassUsage\n\nPriority: High (1)\n\nBlack-list classes which should not be used in your code.\n\nThis 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)\n\nExample(s):\n\n```java\nimport lombok.val; // bad\n\npublic class Foo {\n\n    public void test() {\n        val foo = null;\n    }\n}\n```\n\nUse this rule by referencing it:\n\n```xml\n\u003crule ref=\"vitalibo/java/codestyle.xml/BlacklistClassUsage\"\u003e\n    \u003cproperties\u003e\n        \u003cproperty name=\"classes\" value=\"lombok.experimental.UtilityClass|lombok.experimental.var|lombok.var|lombok.val|org.apache.commons|com.google.common|com.google.gson|com.google.inject\"/\u003e\n    \u003c/properties\u003e\n\u003c/rule\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalibo%2Fpmd-java-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitalibo%2Fpmd-java-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalibo%2Fpmd-java-rules/lists"}