Code Metrics Warning In Assembly

martincostellomartincostello Posts: 21
edited February 16, 2012 5:23AM in SmartAssembly
Hi,

We have a TFS instance which builds our software, which is where SmartAssembly gets run from for our production builds.

As part of our custom TFS Build Process Template, we run the Visual Studio Code Metrics PowerTool 10.0 to collect statistics related to Cyclomatic Complexity, Class Coupling and Maintainability. If code exceeds pre-defined thresholds, then warnings are printed to the TFS build log, with the option of failing the build if warnings are found.

When an assembly is processed with SmartAssembly injected code, the processed assembly generates the following three warnings, which all appear to come from the "ErrorReportSender" class:

'SaveObjectInformation(ObjectAndType, FieldInfo) : void' has a Cyclomatic Complexity of 35. Rewrite or refactor to reduce the Cyclomatic Complexity to 25 or less.
'GetReportData() : byte[]' has a Cyclomatic Complexity of 55. Rewrite or refactor to reduce the Cyclomatic Complexity to 25 or less.
'WriteObjects() : void' has a Cyclomatic Complexity of 35. Rewrite or refactor to reduce the Cyclomatic Complexity to 25 or less.


The arguments we pass to the tool are:

metrics.exe <binary paths> /out:<outputfilepath> /successfile /searchgac /ignoreinvalidtargets /ignoregeneratedcode

We specify the /ignoregeneratedcode argument to exclude anything we've not written ourselves, however from looking at the generated assembly using .NET Reflector, it appears that the classes etc. embedded by SmartAssembly don't use this attribute, so the static analysis is including the SmartAssembly injected code in the analysis.

Is it possible to have SmartAssembly mark all of the classes that are injected to our assemblies with this attribute so that we don't get false positives from our code metrics analysis?

Regards,
Martin

Comments

Sign In or Register to comment.