phpmd icon indicating copy to clipboard operation
phpmd copied to clipboard

New Ruleset: Object Calisthenics/Solid rules

Open beberlei opened this issue 13 years ago • 1 comments

  • [ ] Check for Law Of Demeter violations (how to detect fluent interfaces?)
  • [ ] Check for more then one nested scope per method
  • [x] Usage of else keyword is discouraged
  • [x] Usage of boolean flags in method arguments hints at SRP violation.
  • [x] Retrieving dependencies through static access (singletons, ...) violates Dependency Inversion Principle
  • [ ] Multiple instanceof statements in a method/scope hint at violation of open-closed principle
  • [ ] Interface with more than N methods violates Interface segregation principle
  • [ ] new Statement in constructor

beberlei avatar Jan 28 '13 17:01 beberlei

I think that Law of Demeter might be very good inspection. Not sure I understood your question about "How to detect fluent interfaces", can you explain a little bit more?

Formally, Law of Demeter for class C and it's method m() should be described by following rules: m() can only call and have access too:

  1. itself
  2. members of C(including objects of other classes).
  3. parameters of m()
  4. any object and variables created within m()
  5. global variables accessible by C in scope of m()

If you want, I could try to help with this particular rule, just let me know where the best place for this rule would be.

sergekukharev avatar Jun 02 '14 12:06 sergekukharev