<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rob Chartier ~ Contemplation... : VB.NET</title><link>http://weblogs.asp.net/rchartier/archive/tags/VB.NET/default.aspx</link><description>Tags: VB.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Code Metrics - Complexity &amp; The .NET Framework...</title><link>http://weblogs.asp.net/rchartier/archive/2007/02/14/code-metrics-complexity-the-net-framework.aspx</link><pubDate>Wed, 14 Feb 2007 18:58:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:1670027</guid><dc:creator>Rob Chartier</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/rchartier/rsscomments.aspx?PostID=1670027</wfw:commentRss><comments>http://weblogs.asp.net/rchartier/archive/2007/02/14/code-metrics-complexity-the-net-framework.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;If you have never heard of &lt;a href="http://www.sei.cmu.edu/str/descriptions/cyclomatic_body.html" target="_blank"&gt;&amp;quot;Cyclomatic Complexity&amp;quot; a good place to start is here&lt;/a&gt;. I decided to &lt;a href="http://projectdistributor.net/Releases/Release.aspx?releaseId=326" target="_blank"&gt;grab the Reflector Addin by Peli&lt;/a&gt; which will examine an assembly&amp;#39;s methods and produce a list of code metrics for each given method, one of which is the Cyclomatic Complexity and run it on &amp;quot;mscorlib.dll&amp;quot; and some of the results are actually quite alarming.&lt;/p&gt;&lt;p&gt;Just in this one DLL there are &lt;strong&gt;24 methods that score 50 or higher&lt;/strong&gt;, the highest being DateTimeParse.ParseByFormat() which scores at &lt;strong&gt;98&lt;/strong&gt;.&amp;nbsp; Now if you look at &lt;a href="http://www.sei.cmu.edu/str/descriptions/cyclomatic_body.html#table4" target="_blank"&gt;Table 4 in the article I linked above&lt;/a&gt; you will notice that they state that &lt;strong&gt;&amp;quot;greater than 50 - untetsable program (very hight risk)&amp;quot;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I would love to see the code coverage report on these methods.&amp;nbsp; How much of these top methods are actually being testing?&amp;nbsp; How thorough is their process for getting these &amp;quot;untestable&amp;quot; methods tested.&amp;nbsp; I would also like to see the number of bug reports for each method &amp;gt; 50 in the framework and compare those to those &amp;lt; 50...&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I decided to dig a bit deeper than just mscorlib.dll.&amp;nbsp; Here are some of the things I found...&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.dll&lt;/strong&gt;&amp;nbsp; has &lt;strong&gt;20&lt;/strong&gt; methods &amp;gt; 50 with the &lt;strong&gt;worst at 178&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpRequestCacheValidator.FetchCacheControl(String, Boolean) : Void&amp;nbsp; &lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Data.dll&lt;/strong&gt; has&amp;nbsp; &lt;strong&gt;14&lt;/strong&gt; methods &amp;gt; 50 with the &lt;strong&gt;worst at 118&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BinaryNode.EvalBinaryOp(Int32, ExpressionNode, ExpressionNode, DataRow, DataRowVersion, Int32[]) : Object&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Drawing.dll&lt;/strong&gt; has &lt;strong&gt;NO &lt;/strong&gt;methods &amp;gt; 50, with the &lt;strong&gt;worst at 29&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Icon.Initialize(Int32, Int32) : Void&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Web.dll&lt;/strong&gt; has &lt;strong&gt;19&lt;/strong&gt; methods &amp;gt; 50, with the &lt;strong&gt;worst at 184&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BrowserCapabilitiesFactory.UpProcess(NameValueCollection, HttpBrowserCapabilities) : Boolean&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Windows.Forms.dll&lt;/strong&gt; has &lt;strong&gt;35&lt;/strong&gt; methods &amp;gt; 50, with the &lt;strong&gt;worst at 169&lt;/strong&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataGridView.GetClipboardContent() : DataObject&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Configuration.dll&lt;/strong&gt; has &lt;strong&gt;3&lt;/strong&gt; methods &amp;gt; 50, with &lt;strong&gt;the worst at 89&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigurationElement.DeserializeElement(XmlReader, Boolean) : Void&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Security.dll&lt;/strong&gt; has NO methods &amp;gt; 50, with the worst at&amp;nbsp; 35&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reference.CalculateHashValue(XmlDocument, CanonicalXmlNodeList) : Byte[]&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;and the all time worst method for Cyclomatic Complexity is...&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;System.Xml.dll&lt;/strong&gt; has &lt;strong&gt;15&lt;/strong&gt; methods &amp;gt; 50, with &lt;strong&gt;the worst at 224&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlSchemaInference.InferSimpleType(String, Boolean&amp;amp;) : Int32&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br /&gt;Also, it has 1557 instructions, 31 locals..&lt;br /&gt;&lt;/p&gt;&lt;p&gt;How can anyone test this accurately?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=1670027" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rchartier/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/rchartier/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rchartier/archive/tags/.NET+Framework/default.aspx">.NET Framework</category><category domain="http://weblogs.asp.net/rchartier/archive/tags/VB.NET/default.aspx">VB.NET</category></item></channel></rss>