Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix typo of rule in test May 18, 2019
.editorconfig Initial Commit Apr 8, 2019
.gitignore Initial Commit Apr 8, 2019
LICENSE Initial Commit Apr 8, 2019
README.adoc wrote documentation Apr 22, 2019
pom.xml wrote documentation Apr 22, 2019

README.adoc

jQAssistant Java Metrics Plugin

This project provides a jQAssistant plugin to measure some widely known metrics.

How It Works

OOD-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.

Visibility Metrics

  • Relative Visibility - Relative number describes the outside visible elements.

Usage

Prerequisites

  • Java 8 or higher

  • Maven 3.2.5 or higher

  • jQAssistant 1.6.0 or higher (see below)

Setup

The plugin can be enabled in Maven based project by adding it as a dependency to the jQAssistant Maven plugin:

pom.xml
<build>
    <plugins>
        <plugin>
            <groupId>com.buschmais.jqassistant</groupId>
            <artifactId>jqassistant-maven-plugin</artifactId>
            <version>1.6.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.7.0-SNAPSHOT</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
  1. Configure wanted the concepts of the plugin.

  2. Declares the plugin as dependency of jQAssistant

Application of the results

Manually query the results

Query some OOD-Metrics of package a.b.c
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.

Rule

jqassistant/my-rules.xml
<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.

Reference

All properties are created at a Node with Label :Java:Package.

Table 1. All properties created by this plugin
Property Description Created by

ca

Afferent couplings

ood-metrics:AfferentCouplings
ood-metrics:Instability
ood-metrics:Distance
ood-metrics:NormalizedDistance

ce

Efferent couplings

ood-metrics:EfferentCouplings
ood-metrics:Instability
ood-metrics:Distance
ood-metrics:NormalizedDistance

instability

Instability

ood-metrics:Instability
ood-metrics:Distance
ood-metrics:NormalizedDistance

nc

Number Classes

ood-metrics:NumberClasses
ood-metrics:Abstractness
ood-metrics:Distance
ood-metrics:NormalizedDistance

na

Number Abstracts

ood-metrics:NumberAbstracts
ood-metrics:Abstractness
ood-metrics:Distance
ood-metrics:NormalizedDistance

abstractness

Abstractness

ood-metrics:Abstractness
ood-metrics:Distance
ood-metrics:NormalizedDistance

distance

Distance

ood-metrics:Distance

normalizeDistance

Normalized Distance

ood-metrics:NormalizedDistance

relativeVisibility

Relative Visibility

visibility-metrics:RelativeVisibility

Feedback

Please report any issues.

Acknowledgements

This plugin could not provide its functionality without the support of the following open source projects:

You can’t perform that action at this time.