phpmd
phpmd copied to clipboard
New Ruleset: Object Calisthenics/Solid rules
- [ ] 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
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:
- itself
- members of C(including objects of other classes).
- parameters of m()
- any object and variables created within m()
- 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.