codecop / Law-of-Demeter-Playground

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Law Of Demeter Playground with PMD Check

This is an Apache Maven project. Run mvn test to run your tests. JUnit is provided as dependency.

Constraint

Law Of Demeter: Principle of Least Knowledge.

Checking Code for Compliance

PMD contains a rule LawOfDemeter to check code for compliance with Law Of Demeter. This project is set up to check the code using the Maven PMD Plugin on each mvn test. You can also check the rules on their own with mvn pmd:check. By using the Maven Shell the time to run the check can be reduced by 50%.

In Eclipse, use Run As/Maven build... and see the violations in the Console: Eclipse Run Configuration

In IntelliJ IDEA, use Maven Projects/Plugins/pmd/pmd:check and see the violations in the Console: IDEA Run Configuration

Limitations of Checking Code

Obviously code analysis cannot find everything.

You can use // NOPMD line comments and @SuppressWarnings("PMD.LawOfDemeter") annotations to suppress false positives. Use your good judgement. The goal is to follow the law, not to suppress it.

License

This work is licensed under a 3-Clause BSD License, see LICENSE in repository.

About

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Java 93.6%Language:Shell 3.6%Language:Batchfile 2.8%