Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 17, 2018
2 parents 16fc9f8 + 9b1bfa8 commit d73541f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ _[A] new metric [...] yielding meaningful values [...] more sensitive than those
International Journal "Information Theories & Applications", Volume 13, 2006,
[PDF](http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=55D08270F99333F15E0937AF137F4468?doi=10.1.1.84.1506&rep=rep1&type=pdf).

[`bieman95`]
Tight Class Cohesion (**TCC**).<br/>
James M. Bieman et al.,<br/>
Cohesion and Reuse in an Object-Oriented System,<br/>
Department of Computer Science, Colorado State University, 1995,
[PDF](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.53.2683).

## How it works?

First, `Skeleton` parses Java bytecode using Javaassit and ASM, in order to produce
Expand Down
Binary file added papers/bieman95.pdf
Binary file not shown.
37 changes: 26 additions & 11 deletions src/main/resources/org/jpeek/metrics/TCC.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,57 @@ SOFTWARE.
</metric>
</xsl:template>
<xsl:template match="class">
<xsl:variable name="methods" select="methods/method"/>
<!--
@todo #120:30min TCC: inclusion of inherited attributes and methods in the analysis
should be configurable. Come back here after #187 is fixed and adjust the xpath
for `attrs` and `methods` accordingly.
-->
<xsl:variable name="attrs" select="attributes/attribute[@static='false']/text()"/>
<!--
@todo #120:30min TCC: this metric needs to exclude private methods from the analysis.
Adjust the xpath for `methods` accordingly after #188 is fixed.
-->
<xsl:variable name="methods" select="methods/method[@abstract='false' and @ctor='false']"/>
<xsl:variable name="methods_count" select="count($methods)"/>
<xsl:variable name="NC" select="$methods_count * ($methods_count - 1) div 2"/>
<xsl:variable name="directly-related-pairs">
<xsl:for-each select="$methods">
<!--
@todo #9:30min `directly-related-pairs` currently don't take into account cases when two methods are
directly related through calling the third one. This could be possible to take into account only when
skeleton will be able to provide method-method relation information (issue #106)
@todo #120:30min TCC: need to come back and refactor the following after
#156 is fixed. The ops for fields must be properly filtered to ensure
that they belong to the enclosing class.
-->
<xsl:variable name="i" select="position()"/>
<xsl:variable name="left" select="."/>
<xsl:variable name="left_ops" select="$left/ops/op[@code='get' or @code='put']"/>
<xsl:variable name="left_attrs" select="$attrs[. = $left/ops/op/text()]"/>
<xsl:for-each select="$methods">
<xsl:if test="position() &gt; $i">
<xsl:variable name="right" select="."/>
<xsl:variable name="right_ops" select="$right/ops/op[@code='get' or @code='put']"/>
<pair>
<xsl:value-of select="count($left_ops[.=$right_ops])"/>
</pair>
<xsl:variable name="right_attrs" select="$attrs[. = $right/ops/op/text()]"/>
<xsl:if test="exists($left_attrs[. = $right_attrs])">
<pair/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="NDC" select="count($directly-related-pairs)"/>
<xsl:variable name="NDC" select="count($directly-related-pairs/pair)"/>
<xsl:copy>
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$methods_count le 1"><xsl:text>0</xsl:text>0</xsl:when>
<xsl:when test="$methods_count le 1">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$NDC div $NC"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<vars>
<var id="attributes">
<xsl:value-of select="count($attrs)"/>
</var>
<var id="methods">
<xsl:value-of select="count($methods)"/>
</var>
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/jpeek/MetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public static Collection<Object[]> targets() {
new Object[] {"OneVoidMethodWithoutParams", "LCOM3", 1.0d},
new Object[] {"OverloadMethods", "LCOM3", 0.25d},
new Object[] {"TwoCommonAttributes", "LCOM3", 1.0d},
new Object[] {"WithoutAttributes", "LCOM3", 0.0d}
new Object[] {"WithoutAttributes", "LCOM3", 0.0d},
new Object[] {"Foo", "TCC", 1.0d},
new Object[] {"MethodsWithDiffParamTypes", "TCC", 0.2d}
);
}

Expand Down

4 comments on commit d73541f

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d73541f Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 9-57e7e31a disappeared from src/main/resources/org/jpeek/metrics/TCC.xsl, that's why I closed #120. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d73541f Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 120-5199fe22 discovered in src/main/resources/org/jpeek/metrics/TCC.xsl and submitted as #193. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but
we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d73541f Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 120-7c3cf0d4 discovered in src/main/resources/org/jpeek/metrics/TCC.xsl and submitted as #194. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but
we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d73541f Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 120-bc67ce38 discovered in src/main/resources/org/jpeek/metrics/TCC.xsl and submitted as #195. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but
we discovered it only now.

Please sign in to comment.