I have a type to define and assign some static readonly fields. I got a violation for Methods too big (LOC)
I would like to know if I have an attribute for method, and used it in the rule (see below). Where is in my source code I need to use this attribute to discard "this and which" method?
Example code:
Sample rule:
Why does NDepend count Static fields as LOC for a method
It is because when you do a static field inline initialization, it adds a line of code to the class constructor. Actually, as soon as you have one static field inline initialization in a class, the C# compiler creates a static constructor for your class. So if you have N static field inline initialization, you have a method (the class constructor) that has N Lines of Code.
The large method that NDepend reports here is named
BassAttributeNames..cctor()
. Certainly the easiest way to adapt your code rule to avoid such match is to add the clause:&& !m.IsClassContructor