Code Metrics Warning In Assembly

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, melvyn.harbour, dom.smith

Code Metrics Warning In Assembly

Postby martincostello » Tue Feb 14, 2012 6:08 pm

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
martincostello
 
Posts: 14
Joined: Tue Sep 13, 2011 12:54 pm
Location: London, UK

Postby martincostello » Tue Feb 14, 2012 6:09 pm

Sorry, forgot to mention I was talking about the [System.Diagnostics.GeneratedCodeAttribute].

Regards,
Martin
martincostello
 
Posts: 14
Joined: Tue Sep 13, 2011 12:54 pm
Location: London, UK

Postby Brian Donahue » Thu Feb 16, 2012 11:23 am

Hi Martin,

I have logged this issue as a feature request: SA-1396. We can let you know if it's being dealt with.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am


Return to SmartAssembly 6

Who is online

Users browsing this forum: No registered users and 1 guest