-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/yegor256/jpeek into 68
- Loading branch information
Showing
5 changed files
with
235 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2017-2018 Yegor Bugayenko | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> | ||
<xsl:param name="ctors" select="0"/> | ||
<xsl:template match="skeleton"> | ||
<metric> | ||
<xsl:apply-templates select="@*"/> | ||
<title>LCOM2</title> | ||
<description> | ||
<xsl:text>LCOM2 is an attempt to address some shortcomings of the | ||
original LCOM: | ||
- LCOM gives a value of zero for very different classes | ||
- Its definition is based on method-data interaction, which may not | ||
be a correct way to define cohesiveness in the object-oriented world | ||
- Very different classes may have an equal value | ||
- As LCOM is defined on variable access, it's not well suited for | ||
classes that internally access their data via properties | ||
LCOM2 equals the percentage of methods that do not access a specific | ||
attribute averaged over all attributes in the class. If the number | ||
of methods or attributes is zero, LCOM2 is undefined and displayed | ||
as zero. Values for LCOM2 are in the range [0, 1]. A low value indicates | ||
high cohesion and a well-designed class. It is likely that the system has | ||
good class subdivision implying simplicity and high reusability. A | ||
cohesive class will tend to provide a high degree of encapsulation. | ||
A higher value of LCOM2 indicates decreased encapsulation and | ||
increased complexity, thereby increasing the likelihood of errors.</xsl:text> | ||
</description> | ||
<xsl:apply-templates select="node()"/> | ||
</metric> | ||
</xsl:template> | ||
<xsl:template match="class"> | ||
<xsl:variable name="attrs" select="attributes/attribute/text()"/> | ||
<xsl:variable name="attrs_count" select="count($attrs)"/> | ||
<xsl:variable name="methods" select="methods/method[($ctors=0 and @ctor='false') or $ctors=1]"/> | ||
<xsl:variable name="methods_count" select="count($methods)"/> | ||
<xsl:variable name="attr_use"> | ||
<xsl:for-each select="$attrs"> | ||
<xsl:variable name="attr" select="."/> | ||
<count> | ||
<xsl:value-of select="count($methods/ops[op = $attr])"/> | ||
</count> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<xsl:copy> | ||
<xsl:attribute name="value"> | ||
<xsl:choose> | ||
<xsl:when test="$methods_count = 0 or $attrs_count = 0"> | ||
<xsl:text>0</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="format-number(1 - (sum($attr_use/count) div ($methods_count * $attrs_count)), '0.####')"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:attribute> | ||
<xsl:apply-templates select="@*"/> | ||
<vars> | ||
<var id="methods"> | ||
<xsl:value-of select="$methods_count"/> | ||
</var> | ||
<var id="attributes"> | ||
<xsl:value-of select="$attrs_count"/> | ||
</var> | ||
</vars> | ||
</xsl:copy> | ||
</xsl:template> | ||
<xsl:template match="node()|@*"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="node()|@*"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2017-2018 Yegor Bugayenko | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> | ||
<xsl:param name="ctors" select="0"/> | ||
<xsl:template match="skeleton"> | ||
<metric> | ||
<xsl:apply-templates select="@*"/> | ||
<title>LCOM3</title> | ||
<description> | ||
<xsl:text>LCOM3, like LCOM2, is an attempt to address some shortcomings | ||
of the original LCOM: | ||
- LCOM gives a value of zero for very different classes | ||
- Its definition is based on method-data interaction, which may not | ||
be a correct way to define cohesiveness in the object-oriented world | ||
- Very different classes may have an equal value | ||
- As LCOM is defined on variable access, it's not well suited for | ||
classes that internally access their data via properties | ||
LCOM3 values are in the range [0, 2], where 0 = "high cohesion", | ||
1 = "no cohesion" (class should be split), and values >= 1 suggest | ||
serious design flaws in the class, such as unused ("dead") attributes | ||
or perhaps the attributes are accessed only from outside the class. | ||
If there are no more than one method in a class, LCOM3 is undefined. | ||
If there are no variables in a class, LCOM3 is undefined. An | ||
undefined LCOM3 is displayed as zero.</xsl:text> | ||
</description> | ||
<xsl:apply-templates select="node()"/> | ||
</metric> | ||
</xsl:template> | ||
<xsl:template match="class"> | ||
<xsl:variable name="attrs" select="attributes/attribute/text()"/> | ||
<xsl:variable name="attrs_count" select="count($attrs)"/> | ||
<xsl:variable name="methods" select="methods/method[($ctors=0 and @ctor='false') or $ctors=1]"/> | ||
<xsl:variable name="methods_count" select="count($methods)"/> | ||
<xsl:variable name="attr_use"> | ||
<xsl:for-each select="$attrs"> | ||
<xsl:variable name="attr" select="."/> | ||
<count> | ||
<xsl:value-of select="count($methods/ops[op = $attr])"/> | ||
</count> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<xsl:copy> | ||
<xsl:attribute name="value"> | ||
<xsl:choose> | ||
<xsl:when test="$methods_count < 2 or $attrs_count = 0"> | ||
<xsl:text>0</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="format-number((($methods_count - (sum($attr_use/count) div $attrs_count)) div ($methods_count - 1)), '0.####')"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:attribute> | ||
<xsl:apply-templates select="@*"/> | ||
<vars> | ||
<var id="methods"> | ||
<xsl:value-of select="$methods_count"/> | ||
</var> | ||
<var id="attributes"> | ||
<xsl:value-of select="$attrs_count"/> | ||
</var> | ||
</vars> | ||
</xsl:copy> | ||
</xsl:template> | ||
<xsl:template match="node()|@*"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="node()|@*"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aae0a5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
68-6427b294
discovered insrc/test/java/org/jpeek/MetricsTest.java
and submitted as #140. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, butwe discovered it only now.
aae0a5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
68-96e0ea92
discovered insrc/test/java/org/jpeek/MetricsTest.java
and submitted as #141. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, butwe discovered it only now.
aae0a5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
68-03d5665d
discovered insrc/main/resources/org/jpeek/metrics/SCOM.xsl
and submitted as #142. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, butwe discovered it only now.