I'm thinking about to build a tool that spots law of demeter violations in c# code. Obviously, I don't want to reinvent the wheel and build another tool if there is some alternative available, but I had no lucky on searching for such tool specifically for c# code.
There is another topic on stack overflow (here) on the same problem but I think that the solution suggested (e.g. using regex to discover LoD violations) will catch only simple violations. For example, consider the following code (and suppose that a person object already exists):
Wallet wallet = person.Wallet;
DriversLicense license = wallet.DriversLicense;
This is clearly a LoD violation (same as DriversLicense license = person.Wallet.DriversLicense
), but it is harder to detect.
I found some threads about how to check law of demeter violations in c# here and here but no answers for specific tools.
Do you know any tool capable of spotting the kind of LoD violations previously presented in c# code?