mmetrics-frames.xsl revision 0
10139N/A<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
10139N/A xmlns:lxslt="http://xml.apache.org/xslt"
10139N/A xmlns:xalan="http://xml.apache.org/xalan"
12219N/A xmlns:redirect="org.apache.xalan.lib.Redirect"
10139N/A exclude-result-prefixes="xalan"
10139N/A extension-element-prefixes="redirect">
10139N/A<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
10139N/A<xsl:decimal-format decimal-separator="." grouping-separator="," />
10139N/A<!--
10139N/A Copyright 2001-2004 The Apache Software Foundation
10139N/A
15291N/A Licensed under the Apache License, Version 2.0 (the "License");
10139N/A you may not use this file except in compliance with the License.
10615N/A You may obtain a copy of the License at
16560N/A
16976N/A http://www.apache.org/licenses/LICENSE-2.0
10139N/A
10139N/A Unless required by applicable law or agreed to in writing, software
10139N/A distributed under the License is distributed on an "AS IS" BASIS,
10139N/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16560N/A See the License for the specific language governing permissions and
10794N/A limitations under the License.
10139N/A
10794N/A-->
12773N/A<!--
12773N/A @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
12773N/A -->
10794N/A<xsl:param name="output.dir" select="'.'"/>
10139N/A
10640N/A<!-- default max value for the metrics -->
10139N/A<xsl:param name="vg.max" select="10"/>
10640N/A<xsl:param name="loc.max" select="1000"/>
10139N/A<xsl:param name="dit.max" select="10"/>
10820N/A<xsl:param name="noa.max" select="250"/>
16105N/A<xsl:param name="nrm.max" select="50"/>
10820N/A<xsl:param name="nlm.max" select="250"/>
16105N/A<xsl:param name="wmc.max" select="250"/>
10820N/A<xsl:param name="rfc.max" select="50"/>
16769N/A<xsl:param name="dac.max" select="10"/>
16769N/A<xsl:param name="fanout.max" select="10"/>
10861N/A<xsl:param name="cbo.max" select="15"/>
13306N/A<xsl:param name="lcom.max" select="10"/>
13379N/A<xsl:param name="nocl.max" select="10"/>
13379N/A
15219N/A
14420N/A<!-- create a tree fragment to speed up processing -->
14503N/A<xsl:variable name="doctree.var">
14503N/A <xsl:element name="classes">
16472N/A <xsl:for-each select=".//class">
16434N/A <xsl:element name="class">
16472N/A <xsl:attribute name="package">
16442N/A <xsl:value-of select="(ancestor::package)[last()]/@name"/>
16690N/A </xsl:attribute>
16690N/A <xsl:copy-of select="@*"/>
10139N/A <xsl:attribute name="name">
10139N/A <xsl:apply-templates select="." mode="class.name"/>
10139N/A </xsl:attribute>
10139N/A <xsl:copy-of select="method"/>
10139N/A </xsl:element>
10139N/A </xsl:for-each>
10139N/A </xsl:element>
10139N/A</xsl:variable>
10139N/A
10139N/A<xsl:variable name="doctree" select="xalan:nodeset($doctree.var)"/>
10139N/A
10139N/A<xsl:template match="metrics">
10139N/A
10139N/A <!-- create the index.html -->
10139N/A <redirect:write file="{$output.dir}/index.html">
10139N/A <xsl:call-template name="index.html"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- create the stylesheet.css -->
10139N/A <redirect:write file="{$output.dir}/stylesheet.css">
10139N/A <xsl:call-template name="stylesheet.css"/>
10139N/A </redirect:write>
10139N/A
10139N/A <redirect:write file="{$output.dir}/metrics-reference.html">
10139N/A <xsl:call-template name="metrics-reference.html"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- create the overview-packages.html at the root -->
10139N/A <redirect:write file="{$output.dir}/overview-summary.html">
10139N/A <xsl:apply-templates select="." mode="overview.packages"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- create the all-packages.html at the root -->
10139N/A <redirect:write file="{$output.dir}/overview-frame.html">
10139N/A <xsl:apply-templates select="." mode="all.packages"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- create the all-classes.html at the root -->
10139N/A <redirect:write file="{$output.dir}/allclasses-frame.html">
10139N/A <xsl:apply-templates select="." mode="all.classes"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- process all packages -->
10139N/A <xsl:apply-templates select=".//package"/>
10139N/A</xsl:template>
10139N/A
10139N/A
10139N/A<xsl:template match="package">
10139N/A <xsl:variable name="package.name" select="@name"/>
10139N/A <xsl:variable name="package.dir">
10139N/A <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="translate($package.name,'.','/')"/></xsl:if>
10139N/A <xsl:if test="$package.name = 'unnamed package'">.</xsl:if>
10139N/A </xsl:variable>
10139N/A <!-- create a classes-list.html in the package directory -->
10139N/A <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
10139N/A <xsl:apply-templates select="." mode="classes.list"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- create a package-summary.html in the package directory -->
10139N/A <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
10139N/A <xsl:apply-templates select="." mode="package.summary"/>
10139N/A </redirect:write>
10139N/A
10139N/A <!-- for each class, creates a @name.html -->
10139N/A <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
10139N/A <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
10139N/A <!--Processing <xsl:value-of select="$class.name"/><xsl:text>&#10;</xsl:text> -->
10794N/A <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
12754N/A <xsl:apply-templates select="." mode="class.details"/>
10139N/A </redirect:write>
10139N/A </xsl:for-each>
10139N/A</xsl:template>
11087N/A
11087N/A<!-- little trick to compute the classname for inner and non inner classes -->
11087N/A<!-- this is all in one line to avoid CRLF in the name -->
16570N/A<xsl:template match="class" mode="class.name">
16998N/A <xsl:if test="parent::class"><xsl:apply-templates select="parent::class" mode="class.name"/>.<xsl:value-of select="@name"/></xsl:if><xsl:if test="not(parent::class)"><xsl:value-of select="@name"/></xsl:if>
16769N/A</xsl:template>
13306N/A
13379N/A
15449N/A<xsl:template name="index.html">
16434N/A<HTML>
16684N/A <HEAD><TITLE>Metrics Results.</TITLE></HEAD>
16690N/A <FRAMESET cols="20%,80%">
16998N/A <FRAMESET rows="30%,70%">
10139N/A <FRAME src="overview-frame.html" name="packageListFrame"/>
10139N/A <FRAME src="allclasses-frame.html" name="classListFrame"/>
10139N/A </FRAMESET>
10139N/A <FRAME src="overview-summary.html" name="classFrame"/>
10139N/A </FRAMESET>
10139N/A <noframes>
10139N/A <H2>Frame Alert</H2>
10139N/A <P>
10139N/A This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
10139N/A </P>
10139N/A </noframes>
10139N/A</HTML>
10139N/A</xsl:template>
10139N/A
10139N/A<!-- this is the stylesheet css to use for nearly everything -->
10139N/A<xsl:template name="metrics-reference.html">
10139N/A<html>
10139N/A<head>
11344N/A<link title="Style" type="text/css" rel="stylesheet" href="stylesheet.css"/>
11344N/A</head>
11344N/A<body style="text-align:justify;">
11344N/A<h2>Metrics Reference</h2>
11344N/A<a href="#V(G)">V(G)</a> |
10139N/A<a href="#LOC">LOC</a> |
10139N/A<a href="#DIT">DIT</a> |
10139N/A<a href="#NOA">NOA</a> |
10139N/A<a href="#NRM">NRM</a> |
11994N/A<a href="#NLM">NLM</a> |
10139N/A<a href="#WMC">WMC</a> |
11994N/A<a href="#RFC">RFC</a> |
12773N/A<a href="#DAC">DAC</a> |
12773N/A<a href="#FANOUT">FANOUT</a> |
12773N/A<a href="#CBO">CBO</a> |
12773N/A<a href="#LCOM">LCOM</a> |
12773N/A<a href="#NOC">NOC</a>
11994N/A
10139N/A<a name="V(G)"/>
10139N/A<h3>Cyclomatic Complexity - V(G)</h3>
10139N/AThis metric was introduced in the 1970s to measure the amount of control
10139N/Aflow complexity or branching complexity in a module such as a
10139N/Asubroutine. It gives the number of paths that may be taken through the
10139N/Acode, and was initially developed to give some measure of the cost of
10139N/Aproducing a test case for the module by executing each path.
10139N/A<p/>
10139N/AMethods with a high cyclomatic complexity tend to be more difficult to
10139N/Aunderstand and maintain. In general the more complex the methods of an
10139N/Aapplication, the more difficult it will be to test it, and this will adversely
10139N/Aaffect its reliability.
10139N/A<p/>
10139N/AV(G) is a measure of the control flow complexity of a method or
10139N/Aconstructor. It counts the number of branches in the body of the method,
10139N/Adefined as:
10139N/A<ul>
10139N/A<li>while statements;</li>
11826N/A<li>if statements;</li>
15528N/A<li>for statements.</li>
11344N/A</ul>
16786N/A
16786N/AThe metric can also be configured to count each case of a switch
10139N/Astatement as well.
10139N/A
10139N/A<a name="LOC"/>
10139N/A<h3>Lines of Code - LOC</h3>
10139N/A
10139N/AThis is perhaps the simplest of all the metrics to define and compute.
10139N/ACounting lines has a long history as a software metric dating from before
10139N/Athe rise of structured programming, and it is still in widespread use today.
10139N/AThe size of a method affects the ease with which it can be understood, its
10139N/Areusability and its maintainability. There are a variety of ways that the size
10139N/Acan be calculated. These include counting all the lines of code, the number
10139N/Aof statements, the blank lines of code, the lines of commentary, and the
10139N/Alines consisting only of syntax such as block delimiters.
10139N/A<p/>
10139N/AThis metric can also be used for sizing other constructs as well, for
10139N/Aexample, the overall size of a Java class or package can be measured by
10139N/Acounting the number of source lines it consists of.
10139N/A<p/>
10139N/ALOC can be used to determine the size of a compilation unit (source file),
10139N/Aclass or interface, method, constructor, or field. It can be configured to
10139N/Aignore:
10139N/A<ul>
10139N/A<li>blank lines;</li>
10139N/A<li>lines consisting only of comments;</li>
10139N/A<li>lines consisting only of opening and closing braces.</li>
10139N/A</ul>
10139N/A
10139N/A<a name="DIT"/>
10139N/A<h3>Depth of Inheritance Hierarchy - DIT</h3>
10139N/A
10139N/AThis metric calculates how far down the inheritance hierarchy a class is
10139N/Adeclared. In Java all classes have java.lang.Object as their ultimate
10139N/Asuperclass, which is defined to have a depth of 1. So a class that
10139N/Aimmediately extends java.lang.Object has a metric value of 2; any of its
10139N/Asubclasses will have a value of 3, and so on.
10139N/A<p/>
10139N/AA class that is deep within the tree inherits more methods and state
10139N/Avariables, thereby increasing its complexity and making it difficult to
10139N/Apredict its behavior. It can be harder to understand a system with many
12402N/Ainheritance layers.
10139N/A<p/>
10139N/ADIT is defined for classes and interfaces:
10139N/A<ul>
10139N/A<li>all interface types have a depth of 1;</li>
10139N/A<li>the class java.lang.Object has a depth of 1;</li>
10139N/A<li>all other classes have a depth of 1 + the depth of their super class.</li>
10139N/A</ul>
10139N/A
10139N/A<a name="NOA"/>
10139N/A<h3>Number of Attributes - NOA</h3>
10139N/A
10139N/AThe number of distinct state variables in a class serves as one measure of
10139N/Aits complexity. The more state a class represents the more difficult it is to
10139N/Amaintain invariants for it. It also hinders comprehensibility and reuse.
10139N/A<p/>
10139N/AIn Java, state can be exposed to subclasses through protected fields, which
10139N/Aentails that the subclass also be aware of and maintain any invariants. This
10139N/Ainterference with the class's data encapsulation can be a source of defects
10139N/Aand hidden dependencies between the state variables.
10139N/A<p/>
10139N/ANOA is defined for classes and interfaces. It counts the number of fields
10139N/Adeclared in the class or interface.
10139N/A
10139N/A<a name="NRM"/>
10139N/A<h3>Number of Remote Methods - NRM</h3>
10139N/A
10139N/ANRM is defined for classes. A remote method call is defined as an
16998N/Ainvocation of a method that is not declared in any of:
16998N/A<ul>
16976N/A<li>the class itself;</li>
16976N/A<li>a class or interface that the class extends or implements;</li>
16977N/A<li>a class or method that extends the class.</li>
16918N/A</ul>
16918N/A
16786N/AThe value is the count of all the remote method calls in all of the methods
16786N/Aand constructors of the class.
16769N/A
16769N/A<a name="NLM"/>
16771N/A<h3>Number of Local Methods - NLM</h3>
16771N/A
16690N/ANLM is defined for classes and interfaces. A local method is defined as a
16690N/Amethod that is declared in the class or interface. NLM can be configured to
16684N/Ainclude the local methods of all of the class's superclasses. Methods with
16684N/Apublic, protected, package and private visibility can be independently
16684N/Acounted by setting configuration parameters.
16676N/A
16676N/A<a name="WMC"/>
16685N/A<h3>Weighted Methods per Class - WMC</h3>
16640N/A
16640N/AIf the number of methods in a class can be determined during the design
16640N/Aand modeling phase of a project, it can be used as a predictor of how
16640N/Amuch time and effort is needed to develop, debug and maintain it. This
16614N/Ametric can be further refined by incorporating a weighting for the
16614N/Acomplexity of each method. The usual weighting is given by the cyclomatic
16614N/Acomplexity of the method.
16614N/A<p/>
16560N/AThe subclasses of a class inherit all of its public and protected methods,
16560N/Aand possibly its package methods as well, so the number of methods a
16560N/Aclass has directly impacts the complexity of its subclasses. Classes with
16560N/Alarge numbers of methods are often specific to a particular application,
16560N/Areducing the ability to reuse them.
16505N/A<p/>
16505N/AThe definition of WMC is based upon NLM, and it provides the same
16486N/Aconfiguration parameters for counting inherited methods and of varying
16486N/Avisibility. The main difference is that NLM always counts each method as 1,
16442N/Awhereas WMC will weight each method. There are two weighting schemes:
16442N/A<ul>
16442N/A<li>V(G) the cyclomatic complexity of the method is used as its weight.
16442N/A Methods from class files are given a V(G) of 1.</li>
16436N/A<li>the arity, or the number of parameters of the method are used to
16436N/A determine the weight.</li>
16436N/A</ul>
16436N/A
16382N/A<a name="RFC"/>
16382N/A<h3>Response For Class - RFC</h3>
16356N/A
16356N/AThe response set of a class is the set of all methods that can be invoked as
16347N/Aa result of a message sent to an object of the class. This includes methods
16347N/Ain the class's inheritance hierarchy and methods that can be invoked on
16347N/Aother objects. The Response For Class metric is defined to be size of the
16155N/Aresponse set for the class. A class which provides a larger response set is
16155N/Aconsidered to be more complex than one with a smaller response set.
16026N/A<p/>
16026N/AOne reason for this is that if a method call on a class can result in a large
15858N/Anumber of different method calls on the target and other classes, then it
15858N/Acan be harder to test the behavior of the class and debug problems. It will
15759N/Atypically require a deeper understanding of the potential interactions that
15759N/Aobjects of the class can have with the rest of the system.
15700N/A<p/>
15700N/ARFC is defined as the sum of NLM and NRM for the class. The local methods
15693N/Ainclude all of the public, protected, package and private methods, but not
15693N/Amethods declared only in a superclass.
15624N/A
15624N/A<a name="DAC"/>
15528N/A<h3>Data Abstraction Coupling - DAC</h3>
15528N/A
15528N/ADAC is defined for classes and interfaces. It counts the number of reference
15528N/Atypes that are used in the field declarations of the class or interface. The
15528N/Acomponent types of arrays are also counted. Any field with a type that is
15472N/Aeither a supertype or a subtype of the class is not counted.
15474N/A
15474N/A<a name="FANOUT"/>
15472N/A<h3>Fan Out - FANOUT</h3>
15472N/A
15449N/AFANOUT is defined for classes and interfaces, constructors and methods. It
15449N/Acounts the number of reference types that are used in:
15448N/A<ul>
15448N/A<li>field declarations;</li>
15301N/A<li>formal parameters and return types;</li>
15301N/A<li>throws declarations;</li>
15291N/A<li>local variables.</li>
15291N/A</ul>
15275N/A
15275N/AThe component types of arrays are also counted. Any type that is either a
15219N/Asupertype or a subtype of the class is not counted.
15219N/A
14503N/A<a name="CBO"/>
14503N/A<h3>Coupling Between Objects - CBO</h3>
14464N/A
14464N/AWhen one object or class uses another object or class they are said to be
14420N/Acoupled. One major source of coupling is that between a superclass and a
14420N/Asubclass. A coupling is also introduced when a method or field in another
14420N/Aclass is accessed, or when an object of another class is passed into or out
14185N/Aof a method invocation. Coupling Between Objects is a measure of the
14185N/Anon-inheritance coupling between two objects.
14123N/A<p/>
14123N/AA high value of coupling reduces the modularity of the class and makes
13925N/Areuse more difficult. The more independent a class is the more likely it is
13925N/Athat it will be possible to reuse it in another part of the system. When a
13932N/Aclass is coupled to another class it becomes sensitive to changes in that
13754N/Aclass, thereby making maintenance for difficult. In addition, a class that is
13754N/Aoverly dependent on other classes can be difficult to understand and test in
13754N/Aisolation.
13644N/A<p/>
13644N/ACBO is defined for classes and interfaces, constructors and methods. It
13644N/Acounts the number of reference types that are used in:
13416N/A<ul>
13416N/A<li>field declarations</li>
13416N/A<li>formal parameters and return types</li>
13379N/A<li>throws declarations</li>
13313N/A<li>local variables</li>
13313N/A</ul>
13300N/A
13300N/AIt also counts:
13300N/A<ul>
13103N/A<li>types from which field and method selections are made</li>
13103N/A</ul>
12988N/A
12988N/AThe component types of arrays are also counted. Any type that is either a
12972N/Asupertype or a subtype of the class is not counted.
12972N/A
12571N/A<a name="LCOM"/>
12571N/A<h3>Lack of Cohesion Of Methods - LCOM</h3>
12488N/A
12571N/AThe cohesion of a class is the degree to which its methods are related to
12466N/Aeach other. It is determined by examining the pattern of state variable
12466N/Aaccesses within the set of methods. If all the methods access the same state
12413N/Avariables then they have high cohesion; if they access disjoint sets of
12413N/Avariables then the cohesion is low. An extreme example of low cohesion
12413N/Awould be if none of the methods accessed any of the state variables.
12402N/A
12402N/AIf a class exhibits low method cohesion it indicates that the design of the
12402N/Aclass has probably been partitioned incorrectly, and could benefit by being
12402N/Asplit into more classes with individually higher cohesion. On the other
12402N/Ahand, a high value of cohesion (a low lack of cohesion) implies that the
12387N/Aclass is well designed. A cohesive class will tend to provide a high degree
12387N/Aof encapsulation, whereas a lack of cohesion decreases encapsulation and
12370N/Aincreases complexity.
12370N/A<p/>
12308N/AAnother form of cohesion that is useful for Java programs is cohesion
12308N/Abetween nested and enclosing classes. A nested class that has very low
12308N/Acohesion with its enclosing class would probably better designed as a peer
12288N/Aclass rather than a nested class.
12288N/A<p/>
12219N/ALCOM is defined for classes. Operationally, LCOM takes each pair of
12219N/Amethods in the class and determines the set of fields they each access. If
12071N/Athey have disjoint sets of field accesses increase the count P by one. If they
12071N/Ashare at least one field access then increase Q by one. After considering
11922N/Aeach pair of methods,
11922N/ALCOM = (P > Q) ? (P - Q) : 0
11828N/A<p/>
11828N/AIndirect access to fields via local methods can be considered by setting a
11826N/Ametric configuration parameter.
11826N/A
11819N/A<a name="NOC"/>
11819N/A<h3>Number Of Classes - NOC</h3>
11416N/A
11416N/AThe overall size of the system can be estimated by calculating the number
11344N/Aof classes it contains. A large system with more classes is more complex
11344N/Athan a smaller one because the number of potential interactions between
11253N/Aobjects is higher. This reduces the comprehensibility of the system which
11253N/Ain turn makes it harder to test, debug and maintain.
11183N/A<p/>
11183N/AIf the number of classes in the system can be projected during the initial
11172N/Adesign phase of the project it can serve as a base for estimating the total
11172N/Aeffort and cost of developing, debugging and maintaining the system.
11120N/A<p/>
11120N/AThe NOC metric can also usefully be applied at the package and class level
11087N/Aas well as the total system.
11087N/A<p/>
11067N/ANOCL is defined for class and interfaces. It counts the number of classes or
11067N/Ainterfaces that are declared. This is usually 1, but nested class declarations
10986N/Awill increase this number.
10986N/A</body>
10980N/A</html>
10980N/A</xsl:template>
10917N/A
10917N/A<!-- this is the stylesheet css to use for nearly everything -->
10903N/A<xsl:template name="stylesheet.css">
10903N/A .bannercell {
10891N/A border: 0px;
10891N/A padding: 0px;
10861N/A }
10861N/A body {
10861N/A margin-left: 10;
10820N/A margin-right: 10;
10820N/A font:normal 80% arial,helvetica,sanserif;
10794N/A background-color:#FFFFFF;
10794N/A color:#000000;
10742N/A }
10742N/A .a td {
10742N/A background: #efefef;
10704N/A }
10704N/A .b td {
10640N/A background: #fff;
10640N/A }
10640N/A th, td {
10613N/A text-align: left;
10615N/A vertical-align: top;
10535N/A }
10535N/A th {
10476N/A font-weight:bold;
10476N/A background: #ccc;
10476N/A color: black;
10436N/A }
10438N/A table, th, td {
10438N/A font-size:100%;
10438N/A border: none
10436N/A }
10436N/A table.log tr td, tr th {
10418N/A
10418N/A }
10418N/A h2 {
10418N/A font-weight:bold;
10418N/A font-size:140%;
10418N/A margin-bottom: 5;
10339N/A }
10339N/A h3 {
10283N/A font-size:100%;
10284N/A font-weight:bold;
10169N/A background: #525D76;
10169N/A color: white;
10139N/A text-decoration: none;
10139N/A padding: 5px;
10139N/A margin-right: 2px;
10139N/A margin-left: 2px;
10139N/A margin-bottom: 0;
10139N/A }
10139N/A .Error {
10139N/A font-weight:bold; color:red;
10139N/A }
10139N/A
10139N/A</xsl:template>
10139N/A
10139N/A<!-- print the metrics of the class -->
10139N/A<xsl:template match="class" mode="class.details">
10139N/A <!--xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/-->
10139N/A <xsl:variable name="package.name" select="@package"/>
10139N/A <HTML>
10139N/A <HEAD>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="$package.name"/>
10139N/A </xsl:call-template>
10139N/A </HEAD>
10139N/A <BODY>
10139N/A <xsl:call-template name="pageHeader"/>
10139N/A
10139N/A <H3>Class <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
10139N/A <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
10139N/A <xsl:call-template name="all.metrics.header"/>
10139N/A <xsl:apply-templates select="." mode="print.metrics"/>
10139N/A </table>
10139N/A
10139N/A <H3>Methods</H3>
10139N/A <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
10139N/A <xsl:call-template name="method.metrics.header"/>
10139N/A <xsl:apply-templates select="method" mode="print.metrics"/>
10139N/A </table>
10139N/A
10139N/A <xsl:call-template name="pageFooter"/>
10139N/A </BODY>
10139N/A </HTML>
10139N/A</xsl:template>
10139N/A
10139N/A
10139N/A<!-- list of classes in a package -->
10139N/A<xsl:template match="package" mode="classes.list">
10139N/A <HTML>
10535N/A <HEAD>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="@name"/>
10139N/A </xsl:call-template>
10139N/A </HEAD>
10139N/A <BODY>
10139N/A <table width="100%">
10139N/A <tr>
10139N/A <td nowrap="nowrap">
10139N/A <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
10139N/A </td>
10139N/A </tr>
10139N/A </table>
10139N/A
10139N/A <H2>Classes</H2>
10139N/A <TABLE WIDTH="100%">
10139N/A <!-- xalan-nodeset:nodeset for Xalan 1.2.2 -->
10139N/A <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
10139N/A <xsl:sort select="@name"/>
10139N/A <tr>
10139N/A <td nowrap="nowrap">
10139N/A <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
10139N/A </td>
10139N/A </tr>
10139N/A </xsl:for-each>
10139N/A </TABLE>
10139N/A </BODY>
10139N/A </HTML>
10139N/A</xsl:template>
10139N/A
10139N/A
10139N/A<!--
10139N/A Creates an all-classes.html file that contains a link to all package-summary.html
10139N/A on each class.
10139N/A-->
10139N/A<xsl:template match="metrics" mode="all.classes">
10139N/A <html>
10139N/A <head>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="''"/>
10139N/A </xsl:call-template>
10139N/A </head>
10139N/A <body>
10139N/A <h2>Classes</h2>
10139N/A <table width="100%">
10139N/A <xsl:for-each select="$doctree/classes/class">
10139N/A <xsl:sort select="@name"/>
10139N/A <xsl:apply-templates select="." mode="all.classes"/>
10139N/A </xsl:for-each>
10139N/A </table>
10139N/A </body>
10139N/A </html>
10139N/A</xsl:template>
10139N/A
10139N/A<xsl:template match="class" mode="all.classes">
10139N/A <xsl:variable name="package.name" select="@package"/>
10139N/A <xsl:variable name="class.name" select="@name"/>
10139N/A <tr>
10139N/A <td nowrap="nowrap">
10139N/A <a target="classFrame">
10139N/A <xsl:attribute name="href">
10139N/A <xsl:if test="not($package.name='unnamed package')">
10139N/A <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
10139N/A </xsl:if>
10139N/A <xsl:value-of select="$class.name"/><xsl:text>.html</xsl:text>
10139N/A </xsl:attribute>
10139N/A <xsl:value-of select="$class.name"/>
10139N/A </a>
10139N/A </td>
10139N/A </tr>
10139N/A</xsl:template>
10139N/A
10139N/A<!--
10139N/A Creates an html file that contains a link to all package-summary.html files on
10139N/A each package existing on testsuites.
10139N/A @bug there will be a problem here, I don't know yet how to handle unnamed package :(
10139N/A-->
10139N/A<xsl:template match="metrics" mode="all.packages">
10139N/A <html>
10139N/A <head>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="./package/@name"/>
10139N/A </xsl:call-template>
10139N/A </head>
10139N/A <body>
10139N/A <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
10139N/A <h2>Packages</h2>
10139N/A <table width="100%">
10139N/A <xsl:apply-templates select=".//package[not(./@name = 'unnamed package')]" mode="all.packages">
10139N/A <xsl:sort select="@name"/>
10139N/A </xsl:apply-templates>
10139N/A </table>
10139N/A </body>
10139N/A </html>
10139N/A</xsl:template>
10139N/A
10139N/A<xsl:template match="package" mode="all.packages">
10139N/A <tr>
10139N/A <td nowrap="nowrap">
10139N/A <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
10139N/A <xsl:value-of select="@name"/>
10139N/A </a>
10139N/A </td>
10139N/A </tr>
10139N/A</xsl:template>
10139N/A
10139N/A
10139N/A<xsl:template match="metrics" mode="overview.packages">
10139N/A <html>
10139N/A <head>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="''"/>
10139N/A </xsl:call-template>
10139N/A </head>
10139N/A <body onload="open('allclasses-frame.html','classListFrame')">
10139N/A <xsl:call-template name="pageHeader"/>
10139N/A <h3>Summary</h3>
10139N/A <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
10139N/A <tr>
10139N/A <th><a href="metrics-reference.html#V(G)">V(G)</a></th>
10139N/A <th><a href="metrics-reference.html#LOC">LOC</a></th>
10139N/A <th><a href="metrics-reference.html#DIT">DIT</a></th>
10139N/A <th><a href="metrics-reference.html#NOA">NOA</a></th>
10139N/A <th><a href="metrics-reference.html#NRM">NRM</a></th>
10139N/A <th><a href="metrics-reference.html#NLM">NLM</a></th>
10139N/A <th><a href="metrics-reference.html#WMC">WMC</a></th>
10139N/A <th><a href="metrics-reference.html#RFC">RFC</a></th>
10139N/A <th><a href="metrics-reference.html#DAC">DAC</a></th>
10139N/A <th><a href="metrics-reference.html#FANOUT">FANOUT</a></th>
10139N/A <th><a href="metrics-reference.html#CBO">CBO</a></th>
10139N/A <th><a href="metrics-reference.html#LCOM">LCOM</a></th>
10139N/A <th><a href="metrics-reference.html#NOCL">NOCL</a></th>
10139N/A </tr>
10139N/A <xsl:apply-templates select="." mode="print.metrics"/>
10139N/A </table>
10139N/A <table border="0" width="100%">
10139N/A <tr>
10139N/A <td style="text-align: justify;">
10139N/A Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
10139N/A various kind of complexity. Complexity is a common source of problems and defects in software.
10139N/A High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
10139N/A a program.
10139N/A <p/>
10139N/A The primary use of metrics is to focus your attention on those parts of code that potentially are
10139N/A complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
10139N/A actions.
10139N/A For additional information about metrics and their meaning, please consult
10139N/A Metamata Metrics manual.
10139N/A </td>
10139N/A </tr>
10139N/A </table>
10139N/A
10139N/A <h3>Packages</h3>
10139N/A <table border="0" cellpadding="5" cellspacing="2" width="100%">
10139N/A <xsl:call-template name="all.metrics.header"/>
10139N/A <xsl:for-each select=".//package[not(@name = 'unnamed package')]">
10139N/A <xsl:sort select="@name" order="ascending"/>
10139N/A <xsl:apply-templates select="." mode="print.metrics"/>
10139N/A </xsl:for-each>
10139N/A </table>
10139N/A <!-- @bug there could some classes at this level (classes in unnamed package) -->
10139N/A <xsl:call-template name="pageFooter"/>
10139N/A </body>
10139N/A </html>
10139N/A</xsl:template>
10139N/A
10139N/A<xsl:template match="package" mode="package.summary">
10139N/A <HTML>
10139N/A <HEAD>
10139N/A <xsl:call-template name="create.stylesheet.link">
10139N/A <xsl:with-param name="package.name" select="@name"/>
10139N/A </xsl:call-template>
10139N/A </HEAD>
10139N/A <body onload="open('package-frame.html','classListFrame')">
10139N/A <xsl:call-template name="pageHeader"/>
10139N/A <!-- create an anchor to this package name -->
10139N/A <h3>Package <xsl:value-of select="@name"/></h3>
10139N/A
10139N/A <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
10139N/A <xsl:call-template name="all.metrics.header"/>
10139N/A <xsl:apply-templates select="." mode="print.metrics"/>
10139N/A </table>
10139N/A
<table border="0" width="100%">
<tr>
<td style="text-align: justify;">
Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
various kind of complexity. Complexity is a common source of problems and defects in software.
High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
a program.
<p/>
The primary use of metrics is to focus your attention on those parts of code that potentially are
complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
actions.
For additional information about metrics and their meaning, please consult
Metamata Metrics manual.
</td>
</tr>
</table>
<xsl:variable name="classes-in-package" select="$doctree/classes/class[@package = current()/@name]"/>
<xsl:if test="count($classes-in-package) &gt; 0">
<H3>Classes</H3>
<table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
<xsl:call-template name="all.metrics.header"/>
<xsl:for-each select="$classes-in-package">
<xsl:sort select="@name"/>
<xsl:apply-templates select="." mode="print.metrics"/>
</xsl:for-each>
</table>
</xsl:if>
<xsl:call-template name="pageFooter"/>
</body>
</HTML>
</xsl:template>
<!--
transform string like a.b.c to ../../../
@param path the path to transform into a descending directory path
-->
<xsl:template name="path">
<xsl:param name="path"/>
<xsl:if test="contains($path,'.')">
<xsl:text>../</xsl:text>
<xsl:call-template name="path">
<xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($path,'.')) and not($path = '')">
<xsl:text>../</xsl:text>
</xsl:if>
</xsl:template>
<!-- create the link to the stylesheet based on the package name -->
<xsl:template name="create.stylesheet.link">
<xsl:param name="package.name"/>
<LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
</xsl:template>
<!-- Page Header -->
<xsl:template name="pageHeader">
<!-- jakarta logo -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="bannercell" rowspan="2">
<a href="http://jakarta.apache.org/">
<img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
</a>
</td>
<td style="text-align:right"><h2>Source Code Metrics</h2></td>
</tr>
<tr>
<td style="text-align:right">Designed for use with <a href='http://www.webgain.com/products/quality_analyzer/'>Webgain QA/Metamata Metrics</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
</tr>
</table>
<hr size="1"/>
</xsl:template>
<!-- Page Footer -->
<xsl:template name="pageFooter">
<table width="100%">
<tr><td><hr noshade="yes" size="1"/></td></tr>
<tr><td>
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 1999-2001, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</xsl:template>
<!-- class header -->
<xsl:template name="all.metrics.header">
<tr>
<th width="80%">Name</th>
<th nowrap="nowrap">V(G)</th>
<th>LOC</th>
<th>DIT</th>
<th>NOA</th>
<th>NRM</th>
<th>NLM</th>
<th>WMC</th>
<th>RFC</th>
<th>DAC</th>
<th>FANOUT</th>
<th>CBO</th>
<th>LCOM</th>
<th>NOCL</th>
</tr>
</xsl:template>
<!-- method header -->
<xsl:template name="method.metrics.header">
<tr>
<th width="80%">Name</th>
<th nowrap="nowrap">V(G)</th>
<th>LOC</th>
<th>FANOUT</th>
<th>CBO</th>
</tr>
</xsl:template>
<!-- method information -->
<xsl:template match="method" mode="print.metrics">
<tr>
<xsl:call-template name="alternate-row"/>
<td><xsl:apply-templates select="@name"/></td>
<td><xsl:apply-templates select="@vg"/></td>
<td><xsl:apply-templates select="@loc"/></td>
<td><xsl:apply-templates select="@fanout"/></td>
<td><xsl:apply-templates select="@cbo"/></td>
</tr>
</xsl:template>
<!-- class information -->
<xsl:template match="class" mode="print.metrics">
<tr>
<xsl:call-template name="alternate-row"/>
<td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
<td><xsl:apply-templates select="@vg"/></td>
<td><xsl:apply-templates select="@loc"/></td>
<td><xsl:apply-templates select="@dit"/></td>
<td><xsl:apply-templates select="@noa"/></td>
<td><xsl:apply-templates select="@nrm"/></td>
<td><xsl:apply-templates select="@nlm"/></td>
<td><xsl:apply-templates select="@wmc"/></td>
<td><xsl:apply-templates select="@rfc"/></td>
<td><xsl:apply-templates select="@dac"/></td>
<td><xsl:apply-templates select="@fanout"/></td>
<td><xsl:apply-templates select="@cbo"/></td>
<td><xsl:apply-templates select="@lcom"/></td>
<td><xsl:apply-templates select="@nocl"/></td>
</tr>
</xsl:template>
<xsl:template match="file|package" mode="print.metrics">
<tr>
<xsl:call-template name="alternate-row"/>
<td>
<a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
<xsl:value-of select="@name"/>
</a>
</td>
<td><xsl:apply-templates select="@vg"/></td>
<td><xsl:apply-templates select="@loc"/></td>
<td><xsl:apply-templates select="@dit"/></td>
<td><xsl:apply-templates select="@noa"/></td>
<td><xsl:apply-templates select="@nrm"/></td>
<td><xsl:apply-templates select="@nlm"/></td>
<td><xsl:apply-templates select="@wmc"/></td>
<td><xsl:apply-templates select="@rfc"/></td>
<td><xsl:apply-templates select="@dac"/></td>
<td><xsl:apply-templates select="@fanout"/></td>
<td><xsl:apply-templates select="@cbo"/></td>
<td><xsl:apply-templates select="@lcom"/></td>
<td><xsl:apply-templates select="@nocl"/></td>
</tr>
</xsl:template>
<xsl:template match="metrics" mode="print.metrics">
<tr>
<xsl:call-template name="alternate-row"/>
<!-- the global metrics is the top package metrics -->
<td><xsl:apply-templates select="./package/@vg"/></td>
<td><xsl:apply-templates select="./package/@loc"/></td>
<td><xsl:apply-templates select="./package/@dit"/></td>
<td><xsl:apply-templates select="./package/@noa"/></td>
<td><xsl:apply-templates select="./package/@nrm"/></td>
<td><xsl:apply-templates select="./package/@nlm"/></td>
<td><xsl:apply-templates select="./package/@wmc"/></td>
<td><xsl:apply-templates select="./package/@rfc"/></td>
<td><xsl:apply-templates select="./package/@dac"/></td>
<td><xsl:apply-templates select="./package/@fanout"/></td>
<td><xsl:apply-templates select="./package/@cbo"/></td>
<td><xsl:apply-templates select="./package/@lcom"/></td>
<td><xsl:apply-templates select="./package/@nocl"/></td>
</tr>
</xsl:template>
<!-- alternated row style -->
<xsl:template name="alternate-row">
<xsl:attribute name="class">
<xsl:if test="position() mod 2 = 1">a</xsl:if>
<xsl:if test="position() mod 2 = 0">b</xsl:if>
</xsl:attribute>
</xsl:template>
<!-- how to display the metrics with their max value -->
<!-- @todo the max values must be external to the xsl -->
<xsl:template match="@vg">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$vg.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@loc">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$loc.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@dit">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$dit.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@noa">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$noa.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@nrm">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$nrm.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@nlm">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$nlm.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@wmc">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$wmc.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@rfc">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$rfc.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@dac">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$dac.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@fanout">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$fanout.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@cbo">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$cbo.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@lcom">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$lcom.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@nocl">
<xsl:call-template name="display-value">
<xsl:with-param name="value" select="current()"/>
<xsl:with-param name="max" select="$nocl.max"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="display-value">
<xsl:param name="value"/>
<xsl:param name="max"/>
<xsl:if test="$value > $max">
<xsl:attribute name="class">Error</xsl:attribute>
</xsl:if>
<xsl:value-of select="$value"/>
</xsl:template>
</xsl:stylesheet>