- NOTE
-
This project has been archived and is no longer actively developed. Please refer to the existing releases and documentation.
This project provides a jQAssistant plugin to measure some widely known metrics.
The OOD metrics were described first by Robert C. Martin. He described several metrics:
-
Normalized Distance - It’s very similar to distance, but in normalized range.
-
Distance - The distance from the "main sequence"
-
Instability - Relative number describes the stability of a package.
-
Afferent Couplings - Absolute number of incoming dependencies.
-
Efferent Couplings - Absolute number of outgoing dependencies.
-
-
Abstractness - Relative number describes the abstractness of a package.
-
Number Classes - Absolute number of classes in a package.
-
Number Abstracts - Absolute number of abstract classes in package.
-
-
-
Relative Visibility - Relative number describes the outside visible elements.
The plugin can be enabled in Maven based project by adding it as a dependency to the jQAssistant Maven plugin:
<build>
<plugins>
<plugin>
<groupId>com.buschmais.jqassistant</groupId>
<artifactId>jqassistant-maven-plugin</artifactId>
<version>1.8.0</version>
<executions>
<execution>
<goals>
<goal>scan</goal>
<goal>analyze</goal>
</goals>
<configuration>
<concepts>
<concept>ood-metrics:NormalizedDistance</concept> <!--(1)-->
<concept>visiblity-metrics:RelativeVisibility</concept>
</concepts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency> <!--(2)-->
<groupId>org.jqassistant.contrib.plugin</groupId>
<artifactId>jqassistant-java-metrics-plugin</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
-
Configure wanted the concepts of the plugin.
-
Declares the plugin as dependency of jQAssistant
MATCH
(p:Java:Package {fqn:"a.b.c"})
RETURN
p.normalizedDistance, p.abstractness, p.instability
Usually you won’t query the results manually. Instead you’ll implement your own rule to check if packages meet your requirements.
<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/rule/schema/v1.3">
<constraint id="my-rule:NormalizedDistance">
<requiresConcept refId="ood-metrics:NormalizedDistance"/>
<description>The Normalized Distance of package a.b.c must be lower or equals than 0.2.</description>
<cypher><![CDATA[
MATCH (p:Package {fqn:"a.b.c"})
WHERE p.normalizedDistance > 0.2
RETURN p
]]></cypher>
</concept>
</jqa:jqassistant-rules>
This constraint will return the package a.b.c
if its Normalized Distance is greater than 0.2.
By using the default settings this will break your build.
All properties are created at a Node with Label :Java:Package
.
Property | Description | Created by |
---|---|---|
ca |
ood-metrics:AfferentCouplings |
|
ce |
ood-metrics:EfferentCouplings |
|
instability |
ood-metrics:Instability |
|
nc |
ood-metrics:NumberClasses |
|
na |
ood-metrics:NumberAbstracts |
|
abstractness |
ood-metrics:Abstractness |
|
distance |
ood-metrics:Distance |
|
normalizeDistance |
ood-metrics:NormalizedDistance |
|
relativeVisibility |
visibility-metrics:RelativeVisibility |
Please report any issues.
This plugin could not provide its functionality without the support of the following open source projects: