{"id":28262471,"url":"https://github.com/jborgers/pmd-jpinpoint-rules","last_synced_at":"2025-07-08T11:05:56.243Z","repository":{"id":34343400,"uuid":"146762488","full_name":"jborgers/PMD-jPinpoint-rules","owner":"jborgers","description":"PMD rule set for responsible Java and Kotlin coding: performance, sustainability, multi-threading, data mixup and more.","archived":false,"fork":false,"pushed_at":"2025-06-24T06:30:08.000Z","size":2903,"stargazers_count":47,"open_issues_count":37,"forks_count":10,"subscribers_count":3,"default_branch":"pmd7","last_synced_at":"2025-06-24T07:28:51.941Z","etag":null,"topics":["concurrency","data-mixup","java","kotlin","multi-threading","performance","pmd","pmd-plugin","quality-assurance","ruleset","static-code-analysis","sustainability"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jborgers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2018-08-30T14:32:50.000Z","updated_at":"2025-06-24T06:30:09.000Z","dependencies_parsed_at":"2024-02-08T16:53:33.880Z","dependency_job_id":"3f7b77ca-d230-40fc-a0bc-56471511a126","html_url":"https://github.com/jborgers/PMD-jPinpoint-rules","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jborgers/PMD-jPinpoint-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jborgers%2FPMD-jPinpoint-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jborgers%2FPMD-jPinpoint-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jborgers%2FPMD-jPinpoint-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jborgers%2FPMD-jPinpoint-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jborgers","download_url":"https://codeload.github.com/jborgers/PMD-jPinpoint-rules/tar.gz/refs/heads/pmd7","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jborgers%2FPMD-jPinpoint-rules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264257664,"owners_count":23580469,"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","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":["concurrency","data-mixup","java","kotlin","multi-threading","performance","pmd","pmd-plugin","quality-assurance","ruleset","static-code-analysis","sustainability"],"created_at":"2025-05-20T07:11:48.078Z","updated_at":"2025-07-08T11:05:56.238Z","avatar_url":"https://github.com/jborgers.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PMD-jPinpoint-rules\nStatic code checking rules for responsible Java and Kotlin programming built on PMD, sponsored by [Rabobank](https://www.rabobank.com/).\n\nThese rules are on performance, sustainability, multi-threading, data mix-up, and more.\n\n## Purpose\nThe purpose of this project is to create, manage and share these rules, to code better software together: \nbetter software which is faster, uses less resources, has a smaller ecological footprint, is more stable, more confidential, with less effort and lower cost. \nMore general, to promote responsibility by considering the concerns of the user, the environment, the engineer, the community and the company.\n\nWe have distilled these code checks from what we learned in several years of analyzing performance problems and failures found in code, tests and production situations. And the ruleset is growing every month.\n\nWe didn't find these checks in other places, like the standard PMD, FindBugs/Spotbugs, Checkstyle or Sonar rules.\nWe are working with the PMD-team to move some of the jpinpoint rules in the standard rule set, as well as make PMD suitable for Kotlin.\n\n## How to use the rules\n\nRun the jPinpoint rules from the command-line using the PMD tool, from your favorite development\nenvironment with a PMD-plugin, or in SonarQube with the [sonar-pmd-jpinpoint plugin](https://github.com/jborgers/sonar-pmd-jpinpoint) \nnext to the [Sonar pmd plugin](https://github.com/jborgers/sonar-pmd).\n\nDocumentation of the rules are here:\n* [JavaCodePerformance](docs/JavaCodePerformance.md)\n* [JavaDataAccessPerformance](docs/JavaDataAccessPerformance.md)\n* [JavaCodeQuality](docs/JavaCodeQuality.md)\n\n## License\nPMD-jPinpoint-rules is licensed under the [Apache License, Version 2.0](https://github.com/jborgers/pmd-jpinpoint-rules/blob/master/LICENSE.md).\n\n## See also\n- How Bol uses the jPinpoint rules: [How to prevent common performance defects with the jPinpoint PMD rules](https://techlab.bol.com/en/blog/how-to-prevent-common-performance-defects-with-the-jpinpoint-pmd-rules/)\n- Jeroen Borgers presented at J-Fall Virtual: [Fixing your performance and concurrency bugs before they bite you](https://youtu.be/Z_sT38KTRNk)\n- Jeroen Borgers presented at Amsterdam JUG about the why, what and how of these code checking rules: [Performance problem prevention](https://www.meetup.com/nl-NL/Amsterdam-Java-User-Group/events/256497068/)\n| [slides](http://jpinpoint.com/resources/Automated-and-learning-performance-problem-prevention-AMS-JUG.pdf)\n\n# Usage\n\nTo use the ruleset you can install: \n\n- the PMD command line tool from [PMD project at github](https://pmd.github.io/) and/or\n- the PMD-Plugin in your development environment. \n\n## PMD command line tool\n\nAfter installing the tool you can run `pmd.sh` or `pmd.bat` similar to the following\n\n    pmd.sh \\\n        -R PMD-jPinpoint-rules/rulesets/java/jpinpoint-rules.xml \\\n        -d $your-project-src \\\n        -f text\n\n## IntelliJ IDEA with PMD Plugin\n\n- You need version 2024-1+ of IntelliJ. The Community Edition is fine.\n- Install PMD Plugin: \n\n      Settings \u003e Plugins \u003e Browse Repositories \u003e Search 'PMD' \u003e Select 'PMD' \u003e Install \u003e Close \u003e OK \u003e Restart\n\n- Next, configure (add) the ruleset from this repo by URL to always be up-to-date:\n\n      Settings \u003e Tools \u003e PMD \u003e RuleSets \u003e + \u003e Choose RuleSet \u003e drop down \u003e Choose 'jpinpoint-rules' \n\n- Alternatively, download and add your local copy: *[rulesets/java/jpinpoint-rules.xml](https://raw.githubusercontent.com/jborgers/PMD-jPinpoint-rules/refs/heads/pmd7/rulesets/java/jpinpoint-rules.xml)*\n  - remember to download regularly to get up-to-date\n  \n- Options tab: optionally check 'Skip Test Sources' and optionally set your Java version \n\n- You can now perform the code checks using [right-click] on a folder or a file and choose:\n \n      Run PMD \u003e Custom rules \u003e jpinpoint-rules\n\n- If you want a short description on a violation: hover over a violation title to get a popup with a description. \n\n- Documentation on a violation is shown on the right hand side after clicking a violation. More details of the problem and solution are shown with right-clicking 'Details'.\n\n## Eclipse with PMD Plugin\n\nThe Acanda PMD plugin seems to be the best one to use. \n- [Import it into eclipse](http://www.acanda.ch/eclipse-pmd/release/latest).\n- enable PMD through the properties of the project\n- add the ruleset from this project *[rulesets/java/jpinpoint-rules.xml](https://raw.githubusercontent.com/jborgers/PMD-jPinpoint-rules/refs/heads/pmd7/rulesets/java/jpinpoint-rules.xml)*\n\n## SonarQube with Plugins\nIn SonarQube, you need to install [sonar-pmd plugin](https://github.com/jborgers/sonar-pmd) from the marketplace, and [sonar-pmd-jpinpoint plugin](https://github.com/jborgers/sonar-pmd-jpinpoint) for these jpinpoint rules.\n\n# Development\n\nTo start development on the ruleset the PDM tool designer may come in handy. \nDownload it from the [PMD project at github](https://pmd.github.io/) and install it using the instructions on their site.\n\nAfter installation and configuration you can start the designer from the command prompt:\n\n    designer.bat\n   \nor\n\n    ./pmd designer\n\n## Rules and unit tests\n\nThe project can be build using **maven**. The build will perform the **unit tests** which will unit-test \nthe rules. The next paragraph \"Adding new rules\" will describe in more detail where you can find the rule files.\nTo run the unit tests run the following command from the project home directory of:\n\n    mvn clean test  \n    \nor simply:\n\n    ./test\n\n## Adding new rules\n\nYou can add new rules using the steps below. \n\nThe steps basically tell you to create an issue, add documentation and create 3 files. \nAs an example you can copy existing files and change the content according to your needs. Always work along the lines of what already exists.\n\nFor Kotlin: use the paths that contain `/kotlin/` instead of `/java/`.\n\n- create an issue like 'Rule Request: AvoidRecreatingExpensiveThing' with simple compiling examples which can be used as tests. Use this issue reference with check-in.\n- document the pitfall in the proper page and category in docs/ and [regenerate the ToC](https://luciopaiva.com/markdown-toc/)\n- add the Test class in `src/test/java/com/.../perf/lang/java/ruleset/yourruleset/YourRule.java` \nelements from the package structure are used to lookup the rules xml file you add next. \nThe relevant items based on the example given are: lang/**java**/ruleset/**yourruleset** \n- rules go into xml files found in `src/main/resources/category/` in this case \nsrc/main/resources/category/**java**/**yourruleset.xml**. Also add a rule with name `YourRule` \nsince that is what the framework expects.\nFor new rule files (a new category) you will also need to register it in the `categories.properties` file found in the same directory \n(category/java/categories.properties) in this case add `category/java/yourruleset.xml`\n- add the unit test in an xml file in \n`src/test/resources/com/.../perf/lang/java/ruleset/yourruleset/xml/YourRule.xml`. \nPay attention to the package structure which is also dictated by the first java test class!\n\nDepending on what you want to add you may also find it is sufficient to change one or more of the existing files.\nOr to add only a Test class and unit test xml file (steps 1 and 3).\n\n### Conventions for XML Unit test files\n\nFollowing are some conventions and recommendations on how to\nconstruct the unit test files:\n\n- separate test code *(create separate ``\u003ctest-code\u003e`` blocks)*\n- specify test code description *(``\u003ctest-code\u003e\u003cdescription\u003e``)* Start the description with:\n  - **violation:** or\n  - **no violation:**\n- specify number of occurrences *(``\u003ctest-code\u003e\u003cexpected-problems\u003e``)*\n- specify line-numbers *(``\u003ctest-code\u003e\u003cexpected-linenumbers\u003e``)*\n- code *(``\u003ctest-code\u003e\u003ccode\u003e``)* conventions:\n  - use class names like **``Foo``**\n  - use method names like **``bad``** and **``good``**\n  - add comment at the end of bad lines **``//bad``**  \n  - remove useless code and **``import``** statements\n\n### Run Kotlin Unit Tests\n\nWhen running unit tests for Kotlin PMD 7 is needed. Make sure you have access to the PMD jars of the `7.0.0-SNAPSHOT`\nbranch (e.g. mvn install the PMD 7.0.x jars from https://github.com/pmd/pmd). Use the Maven `kotlin-pmd7` profile \nwhen running the Kotlin unit tests.\n\n## Code Style Indentation\n\n- Indentation: Use spaces a.k.a. **Disable Tabs**: *Settings\u003eEditor\u003eCode Style\u003eJava\u003eUse tab character [disable]*\n\n## Contents of the project\n- `rulesets/java/jpinpoint-rules.xml` contains the pmd custom rule definitions\n- `src/main/java/pinpointrules` contains the Java code containing pitfalls for testing the rules. \n- `rulesets-merger` contains the Java code for a ruleset merger tool.  \n\n## Merging rules\n\n- `rulesets-merger/src` contains RulesetMerger.java for merging jpinpoint-rules.\n\n The merger tool can be built with:\n\n    cd rulesets-merger\n    mvn clean install\n\n### Merging from different categories\n\n Run the merger tool as follows:\n\n    cd rulesets-merger\n    mvn exec:java -Dexec.args=\"java\"\n    \n or simply:\n \n    ./merge\n\nor for Kotlin instead of Java:\n\n    ./merge kotlin\n\n It will merge the rules from ``src/main/resources/category/java/*.xml`` to create the jpinpoint-rules.xml file which can be used in your IDE.\n\n### Merging with company specific rules\n\nCompany specific rules are useful for instance for checking the right use of company specific or company-bought frameworks and libraries. \nOr for rules which are candidates for inclusion into jpinpoint rules, yet need to be validated first.\n\n- `rulesets-merger/src` contains RulesetMerger.java for merging jpinpoint-rules with company specific rules. \nCopy rulesets-merger to your company specific rules directory and adjust a few constants at the top to make it work for your company.\n\nThe merge tool runs either for the java or the kotlin rules. Use the first argument to choose: java or kotlin.\n    \n After building, the merger tool can be run with:\n \n    cd rulesets-merger\n    mvn exec:java -Dexec.args=\"java\"\n\nor simply\n\n    ./merge\n\nor for Kotlin instead of Java:\n\n    ./merge kotlin\n\n This will attempt to lookup the PMD-jPinpoint-rules project (next to your own project)\n and merge `rulesets/[java|kotlin]/jpinpoint-rules.xml` together with your rule files (from `src/main/resources/category/[java|kotlin]/*.xml`)     \n The resulting file can be used in your IDE.\n \n It assumes you have the following repositories in directories next to each other:\n \n     PMD-Company-jPinpoint-rules\n     PMD-jPinpoint-rules (optional)\n \n  It can be built and run the same way.\n \n  It will generate two files:\n  \n     company-rules.xml\n     company-jpinpoint-rules.xml\n     \n  These files can be used in your IDE. The former only contains the company specific rules. \n  The latter contains all rules combined and will only be generated if the optional PMD-jPinpoint-rules repo is available.\n \n  You can also do it yourself and specify the external repo to merge with explicitly:\n   \n      cd target\n      java -jar java rulesets-merger-1.0-SNAPSHOT.jar PMD-jPinpoint-rules rulesets/java jpinpoint-rules.xml \n\nor for Kotlin:\n\n      cd target\n      java -jar kotlin rulesets-merger-1.0-SNAPSHOT.jar PMD-jPinpoint-rules rulesets/kotlin jpinpoint-rules.xml \n\n## Tools to create documentation\n1. Confluence export as HTML\n2. [Converting HTML to Markdown](https://domchristie.github.io/turndown/)\n3. [Markdown TOC generator](https://luciopaiva.com/markdown-toc/\n)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjborgers%2Fpmd-jpinpoint-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjborgers%2Fpmd-jpinpoint-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjborgers%2Fpmd-jpinpoint-rules/lists"}