Red Gate forums :: View topic - Code Metrics Warning In Assembly
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Code Metrics Warning In Assembly

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
martincostello



Joined: 13 Sep 2011
Posts: 14
Location: London, UK

PostPosted: Tue Feb 14, 2012 6:08 pm    Post subject: Code Metrics Warning In Assembly Reply with quote

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
Back to top
View user's profile Send private message
martincostello



Joined: 13 Sep 2011
Posts: 14
Location: London, UK

PostPosted: Tue Feb 14, 2012 6:09 pm    Post subject: Reply with quote

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

Regards,
Martin
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6641

PostPosted: Thu Feb 16, 2012 11:23 am    Post subject: Reply with quote

Hi Martin,

I have logged this issue as a feature request: SA-1396. We can let you know if it's being dealt with.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group