Skip to content

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
feitosa-daniel committed Apr 26, 2017
0 parents commit 5769dc9
Show file tree
Hide file tree
Showing 28 changed files with 2,096 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@

# Created by https://www.gitignore.io/api/linux,macos,windows,intellij+iml

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar


### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# IntelliJ .idea folder
.idea/

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
*.ipr

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/linux,macos,windows,intellij+iml
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Spoon-grime

This is a set of [Spoon](http://spoon.gforge.inria.fr/) processors to calculate metrics for pattern
grime in GoF pattern instances. The processors can be applied as described in Spoon's [website](http://spoon.gforge.inria.fr/first_analysis_processor.html#apply-the-processor).

Spoon-grime is available as a standalone application, which will calculate all available metrics.

In all cases, the metrics are calculated and exported as an XML file.

**Notes:**
* built with Spoon 5.6.0
* requires JVM 1.8
* compatible with Java 7 (or lower) and Java 8 source code

## Usage

### Processor
```shell
$ java -classpath spoon-grime-0.1.0.jar:spoon-core-5.6.0-jar-with-dependencies.jar
spoon.Launcher -i <src-folder> -p nl.rug.search.patterngrime.spoon.processors.<MetricProcessor>
```

### Standalone
```
> java -jar spoon-grime.jar -n <pattern-description-xml> -s <src-folder> [-o <output-xml>]
<pattern-description-xml> xml file describing all pattern instances in the source code
<src-folder> folder contaning source files
<output-xml> output file (defaults to "./<pattern-description-xml>.pttgrime.xml"
```


## Metrics

#### [Class grime] cg-npm
**Processor:** nl.rug.search.patterngrime.spoon.processors.CgNpmProcessor

Number of public methods that are not part of the original pattern definition.
```
// steps for calculation
1. get list of public methods part of the pattern instace (from SSA)
2. get list of public methods in the class (from spoon)
3. subtract set (1) from set (2)
```

#### [Class grime] cg-na
**Processor:** nl.rug.search.patterngrime.spoon.processors.CgNaProcessor

Number of attributes that are not part of the original pattern definition.
```
// steps for calculation
1. get list of attributes that are part of the pattern instace (from SSA)
2. get list of class attributes (from spoon)
3. subtract set (1) from set (2)
```

#### [Modular grime] mg-ca
**Processor:** nl.rug.search.patterngrime.spoon.processors.MgCaProcessor

Pattern instance afferent coupling.
```
// steps for calculation
1. get list of classes of the pattern instance (from SSA)
2. for each class in set (1), get classes in the system that depend on it (from spoon)
3. remove duplications in set (2)
4. subtract set (1) from set (2)
```

#### [Modular grime] mg-ce
**Processor:** nl.rug.search.patterngrime.spoon.processors.MgCeProcessor

Pattern instance efferent coupling.
```
// steps for calculation
1. get list of classes of the pattern instance (from SSA)
2. for each class in set (1), get list of (class) dependencies
3. remove duplications in set (2)
4. subtract set (1) from set (2)
```


#### [Organizational grime] og-np
**Processor:** nl.rug.search.patterngrime.spoon.processors.OgNpProcessor

Number of packages within the pattern instance.
```
// steps for calculation
1. get list of classes of the pattern instance (from SSA)
2. for each class in set (1), get package name
3. remove duplications from set (2)
```

#### [Organizational grime] og-ca
**Processor:** nl.rug.search.patterngrime.spoon.processors.OgCaProcessor

Fan-in at the package level.
```
// steps for calculation
1. get list of classes of the pattern instance (from SSA)
2. for each class in set (1), get package name
3. remove duplications from set (2)
4. for each package in set(3), get classes in the system that depend on it (from spoon)
5. for each class in set (4), get package name
6. remove duplications from set (5)
```
176 changes: 176 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.rug.search</groupId>
<artifactId>spoon-pttgrime</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>

<name>spoon-grime</name>
<description>Spoon processor to extract grime metrics</description>
<url></url>
<inceptionYear>2017</inceptionYear>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Daniel Feitosa</name>
<url>http://feitosa-daniel.github.io</url>
</developer>
</developers>

<properties>
<java-version>1.8</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spoon-core.version>5.6.0</spoon-core.version>
<xstream.version>1.4.9</xstream.version>

<jcommander.version>1.68</jcommander.version>
<commons-io.version>2.5</commons-io.version>

<log4j.version>2.8.2</log4j.version>

<junit.version>4.12</junit.version>
<xmlunit.version>2.3.0</xmlunit.version>
</properties>

<repositories>
<repository>
<id>mavencentral</id>
<name>Maven Central</name>
<url>http://central.maven.org/maven2/</url>
</repository>
<repository>
<id>gforge.inria.fr-snapshot</id>
<name>Maven Repository for Spoon Snapshots</name>
<url>http://spoon.gforge.inria.fr/repositories/snapshots/</url>
<snapshots />
</repository>
<repository>
<id>jcenter</id>
<name>JCenter Repository</name>
<url>http://jcenter.bintray.com/</url>
<snapshots />
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<!-- Core application -->
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>${spoon-core.version}</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>${xstream.version}</version>
</dependency>

<!-- CLI -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>${jcommander.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>


<!-- Testing -->
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgs>-Xlint:all</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>nl.rug.search.patterngrime.CLI</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 5769dc9

Please sign in to comment.