<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Panopticode Blog: Category Metrics</title>
    <link>http://blog.panopticode.org/articles/category/metrics</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>A Beautiful Visualization of Source Repository Activity</title>
      <description>&lt;p&gt;&lt;a href="http://vis.cs.ucdavis.edu/~ogawa/"&gt;Michael Ogawa&lt;/a&gt; has created a mesmerizing animated visualization of the activity within source code repositories named &lt;a href="http://vis.cs.ucdavis.edu/~ogawa/codeswarm/"&gt;code_swarm&lt;/a&gt;. This is truly a case of a picture being worth (at least) a thousand words.  &lt;/p&gt;

&lt;p&gt;Go check it out at &lt;a href="http://vis.cs.ucdavis.edu/~ogawa/codeswarm/"&gt;http://vis.cs.ucdavis.edu/~ogawa/codeswarm/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://vis.cs.ucdavis.edu/~ogawa/codeswarm/postgres-300px.png" /&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 16 Jun 2008 23:07:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:0d9a23e0-9afa-4e0b-8dde-2db7c6402437</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2008/06/16/a-beautiful-visualization-of-source-repository-activity</link>
      <category>Metrics</category>
      <category>Tools</category>
      <category>Metrics</category>
      <category>Activity</category>
      <category>Visualization</category>
    </item>
    <item>
      <title>New Metric: C.R.A.P.</title>
      <description>&lt;p&gt;The good folks at &lt;a href="http://www.agitar.com/"&gt;Agitar&lt;/a&gt; have proposed a new metric, C.R.A.P and an Eclipse plugin &lt;a href="http://www.artima.com/weblogs/viewpost.jsp?thread=215899"&gt;crap4j&lt;/a&gt; for executing it.&lt;/p&gt;

&lt;p&gt;C.R.A.P. combines a method&amp;#8217;s complexity with its coverage to come up with a single number that can help you determine if somebody will say, &lt;em&gt;&amp;#8220;Oh crap!&amp;#8221;&lt;/em&gt; when they have to work with it.  The formula is: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Read their &lt;a href="http://www.artima.com/weblogs/viewpost.jsp?thread=215899"&gt;article&lt;/a&gt; for details on deciding if a system is crappy or not.&lt;/p&gt;

&lt;p&gt;To test the flexibility of Panopticode I decided to implement a C.R.A.P. Supplement.  It took a little over an hour.&lt;/p&gt;

&lt;p&gt;Looking at the results I was pleased to find that only one method in Panopticode exceeds Agitar&amp;#8217;s C.R.A.P. threshold of 30.  Unfortunately that leads me to believe that 30 is too high.  Right now, there is a lot of spike code in Panopticode right now that I consider crappy ;-&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 07 Oct 2007 16:17:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:8a678c8a-0e3f-40c7-8452-cf962ea67344</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2007/10/07/new-metric-c-r-a-p</link>
      <category>Metrics</category>
    </item>
    <item>
      <title>Teaser: Breaking the Build in Panopticode 0.2</title>
      <description>&lt;p&gt;In the &lt;a href="http://blog.panopticode.org/articles/2007/09/12/teaser-creating-ad-hoc-reports-in-panopticode-0-2"&gt;last post&lt;/a&gt; we learned that Panopticode 0.2 will allow us to create arbitrary reports using a SPARQL SELECT query.  Another feature in Panopticode 0.2 is to use a SPARQL ASK query to break the build.&lt;/p&gt;

&lt;p&gt;An ASK query looks very similar to a SELECT but without any elements to return.  If the query matches any data it returns true, otherwise it returns false.&lt;/p&gt;

&lt;p&gt;Rewriting last post&amp;#8217;s SELECT query as an ASK query would look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; PREFIX rdf: &amp;lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;gt;
 PREFIX panopticode: &amp;lt;http://www.panopticode.org/ontologies/panopticode#&amp;gt;
 PREFIX java: &amp;lt;http://www.panopticode.org/ontologies/technology/java#&amp;gt;
 PREFIX emma: &amp;lt;http://www.panopticode.org/ontologies/supplement/emma/1#&amp;gt;
 PREFIX javancss: &amp;lt;http://www.panopticode.org/ontologies/supplement/javancss/1#&amp;gt;

 ASK WHERE
 {
   ?package         rdf:type                       java:Package           .
   ?package         panopticode:name               ?packageName           .
   ?package         java:hasFile                   ?file                  .
   ?file            panopticode:filePath           ?filePath              .
   ?file            java:hasType                   ?class                 .
   ?class           panopticode:name               ?className             .
   ?class           java:hasExecutableMember       ?method                .
   ?method          java:methodSignature           ?methodSignature       .
   ?method          emma:hasLineCoverage           ?lineCoverage          .
   ?method          javancss:cyclomaticComplexity  ?ccn                   .
   ?lineCoverage    emma:coveredPercent            ?lineCoveragePercent   .

   FILTER (?ccn &amp;gt; 1) .
   FILTER (?lineCoveragePercent &amp;lt;= 80.0)
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Panopticode 0.2 will come with an Ant task that automatically breaks the build when an ASK query returns true.&lt;/p&gt;</description>
      <pubDate>Sun, 16 Sep 2007 01:24:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:de421c24-e1cf-4edd-8c13-b7fd5afe9c91</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2007/09/16/teaser-breaking-the-build-in-panopticode-0-2</link>
      <category>Metrics</category>
      <category>RDF</category>
      <category>SPARQL</category>
      <category>Rules</category>
    </item>
    <item>
      <title>Teaser: Creating Ad Hoc Reports in Panopticode 0.2</title>
      <description>&lt;p&gt;In &lt;a href="http://blog.panopticode.org/articles/2007/02/26/metrics-must-be-interpreted-in-context"&gt;Metrics Must be Interpreted In Context&lt;/a&gt; I described one of my preferences when creating rules around metrics.  Namely, that one should not look at metrics independently, but within the context of other metrics.  I described a rule that said unit test line coverage must be greater then 80% for all code with a cyclomatic complexity over 1.  While you could enforce this rule in Panopticode 0.1 by creating a custom report, this is not ideal.  Who wants to write Java code every time you make a new rule?  This will get much easier in Panopticode 0.2.&lt;/p&gt;

&lt;p&gt;Panopticode 0.2 has been re-architected to use &lt;a href="http://www.w3.org/RDF/"&gt;RDF&lt;/a&gt; as it&amp;#8217;s file format and internal data store.  This enables you to write queries using &lt;a href="http://www.w3.org/TR/rdf-sparql-query/"&gt;SPARQL&lt;/a&gt;.  Here is a query to find violators of the rule mentioned above:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; PREFIX rdf: &amp;lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;gt;
 PREFIX panopticode: &amp;lt;http://www.panopticode.org/ontologies/panopticode#&amp;gt;
 PREFIX java: &amp;lt;http://www.panopticode.org/ontologies/technology/java#&amp;gt;
 PREFIX emma: &amp;lt;http://www.panopticode.org/ontologies/supplement/emma/1#&amp;gt;
 PREFIX javancss: &amp;lt;http://www.panopticode.org/ontologies/supplement/javancss/1#&amp;gt;

 SELECT ?packageName ?filePath ?className ?methodSignature ?ccn ?lineCoveragePercent
 WHERE
 {
   ?package         rdf:type                       java:Package           .
   ?package         panopticode:name               ?packageName           .
   ?package         java:hasFile                   ?file                  .
   ?file            panopticode:filePath           ?filePath              .
   ?file            java:hasType                   ?class                 .
   ?class           panopticode:name               ?className             .
   ?class           java:hasExecutableMember       ?method                .
   ?method          java:methodSignature           ?methodSignature       .
   ?method          emma:hasLineCoverage           ?lineCoverage          .
   ?method          javancss:cyclomaticComplexity  ?ccn                   .
   ?lineCoverage    emma:coveredPercent            ?lineCoveragePercent   .

   FILTER (?ccn &amp;gt; 1) .
   FILTER (?lineCoveragePercent &amp;lt;= 80.0)
 }
 ORDER BY DESC(?ccn) ?lineCoveragePercent ?packageName ?filePath ?className ?methodSignature
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Wed, 12 Sep 2007 08:12:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:72a2625c-d6c2-4577-8e16-f701beb97918</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2007/09/12/teaser-creating-ad-hoc-reports-in-panopticode-0-2</link>
      <category>Metrics</category>
      <category>RDF</category>
      <category>SPARQL</category>
    </item>
    <item>
      <title>New Tool: Complexian</title>
      <description>&lt;p&gt;&lt;a href="http://martyandrews.net/]"&gt;Marty Andrews&lt;/a&gt; has just released version 0.12.0 of &lt;a href="http://martyandrews.net/resources/complexian.html"&gt;Complexian&lt;/a&gt;.  This version adds the ability to output to plain or XML files.&lt;/p&gt;

&lt;p&gt;Complexian is a tool for very quickly measuring NPATH and CCN of Java projects.  It will be free for use until the first major release.&lt;/p&gt;

&lt;p&gt;Support for executing Complexian is already in Panopticode&amp;#8217;s Subversion repository and full support will be in release 0.2.&lt;/p&gt;</description>
      <pubDate>Sun, 04 Mar 2007 06:55:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:2e3ecd5b-23f4-4c27-9d1d-b3504946c174</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2007/03/04/new-tool-complexian</link>
      <category>Metrics</category>
      <category>Tools</category>
      <category>Metrics</category>
      <category>Complexity</category>
      <category>Tools</category>
    </item>
    <item>
      <title>Metrics Must be Interpreted In Context</title>
      <description>&lt;p&gt;James Newkirk &lt;a href="http://blogs.msdn.com/jamesnewkirk/archive/2007/02/25/how-to-make-sense-of-code-coverage-metrics.aspx"&gt;points out&lt;/a&gt; that the absolute measurement of code coverage is not a very interesting number by itself, but must be viewed as part of the overall trend of coverage.  He also points out that it is acceptable for some categories of code to have lower, or even zero, test coverage.&lt;/p&gt;

&lt;p&gt;These are examples of one of my fundamental rules of metrics.&lt;/p&gt;

&lt;h2&gt;Rule #1: Metrics Must Be Interpreted In Context&lt;/h2&gt;

&lt;p&gt;A few examples of context are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Within a time series.&lt;/strong&gt;  A code coverage of 20% could be very good if the team is just beginning to add automated tests to a legacy system.  On the other hand a code coverage of 85% could be poor if was at 90% coverage at the last release.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;By category of code.&lt;/strong&gt;  James uses the example of web service wrappers generated by Visual Studio and and views within a Model-View-Presenter pattern.  I agree with James that generated code does not need unit tests.  However, you should be particlarly thorough in testing any code generators you write.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Correlations with other metrics.&lt;/strong&gt;  If pressed to come up with an arbitrary threshold for a metric I like to do it within the context of another metric.  For example, I might say that the unit test line coverage must be greater than 80% for all methods with a cyclomatic complexity greater than one.  A key metric to correlate with is defects.  Code that has proven to be buggy in production should get closer attention.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compared to other projects in your organization.&lt;/strong&gt;  If every other software project at your company has 90% code coverage you had better have a good reason for only having 70%.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a lot more to say on this subject.  Stay Tuned.&lt;/p&gt;</description>
      <pubDate>Mon, 26 Feb 2007 20:38:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:e4b94f3c-b24e-4818-adcf-7a3217d0ac51</guid>
      <author>Julias Shaw</author>
      <link>http://blog.panopticode.org/articles/2007/02/26/metrics-must-be-interpreted-in-context</link>
      <category>Metrics</category>
      <category>Metrics</category>
      <category>CodeCoverage</category>
      <category>Rules</category>
    </item>
  </channel>
</rss>
