Class LawOfDemeterRule

  • All Implemented Interfaces:
    net.sourceforge.pmd.lang.ast.AstVisitor, JavaVisitor, net.sourceforge.pmd.lang.rule.Rule, net.sourceforge.pmd.properties.PropertySource

    public class LawOfDemeterRule
    extends AbstractJavaRule
    This rule can detect possible violations of the Law of Demeter. The Law of Demeter is a simple rule, that says "only talk to friends". It helps to reduce coupling between classes or objects.

    See:

    • Andrew Hunt, David Thomas, and Ward Cunningham. The Pragmatic Programmer. From Journeyman to Master. Addison-Wesley Longman, Amsterdam, October 1999.
    • K.J. Lieberherr and I.M. Holland. Assuring good style for object-oriented programs. Software, IEEE, 6(5):38–48, 1989.
    Author:
    Clément Fournier
    Since:
    5.0
    • Constructor Detail

      • LawOfDemeterRule

        public LawOfDemeterRule()
    • Method Detail

      • apply

        public void apply​(net.sourceforge.pmd.lang.ast.Node target,
                          net.sourceforge.pmd.reporting.RuleContext ctx)
        Specified by:
        apply in interface net.sourceforge.pmd.lang.rule.Rule
        Overrides:
        apply in class AbstractJavaRule