Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Mair committed Aug 9, 2018
1 parent f00b6e6 commit c9dc1ea
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,6 +1,6 @@
# CodeNarc Change Log

TODO: Version 1.2.1 (??? 2018)
TODO: Version 1.2.1 (Aug 2018)
--------------------------------------
Bug Fixes
- #310: **Indentation** rule: Fix handling of indent level within scripts and method call chaining.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -7,7 +7,7 @@ plugins {

group = "org.codenarc"
archivesBaseName = "CodeNarc"
version = "1.2"
version = "1.2.1"

sourceCompatibility = '1.6'
targetCompatibility = '1.6'
Expand Down
2 changes: 1 addition & 1 deletion site-pom.xml
Expand Up @@ -9,7 +9,7 @@
The CodeNarc project provides a static analysis tool for Groovy code.
</description>
<packaging>jar</packaging>
<version>1.2</version>
<version>1.2.1</version>
<url>http://codenarc.org/</url>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/codenarc-base-rules.properties
@@ -1,4 +1,4 @@
# CodeNarc Rules (see PropertiesFileRuleRegistry): Sat Jul 07 07:02:26 EDT 2018
# CodeNarc Rules (see PropertiesFileRuleRegistry): Wed Aug 08 21:29:08 EDT 2018
AbcMetric = org.codenarc.rule.size.AbcMetricRule
AbstractClassName = org.codenarc.rule.naming.AbstractClassNameRule
AbstractClassWithPublicConstructor = org.codenarc.rule.design.AbstractClassWithPublicConstructorRule
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/codenarc-version.txt
@@ -1 +1 @@
1.2
1.2.1
43 changes: 33 additions & 10 deletions src/site/resources/SampleCodeNarcHtmlReport.html

Large diffs are not rendered by default.

43 changes: 33 additions & 10 deletions src/site/resources/SampleCodeNarcSortableHtmlReport.html
Expand Up @@ -255,7 +255,7 @@
}
}
}
}</script></head><body><img class='logo' src='http://codenarc.sourceforge.net/images/codenarc-logo.png' alt='CodeNarc' align='right'/><h1>CodeNarc Report</h1><div class='metadata'><table><tr><td class='em'>Report title:</td><td>Sample Project</td></tr><tr><td class='em'>Date:</td><td>Jul 7, 2018 7:04:43 AM</td></tr><tr><td class='em'>Generated with:</td><td><a href='http://www.codenarc.org'>CodeNarc v1.2</a></td></tr></table></div><div class='summary'><h2>Summary</h2><table><thead><tr class='tableHeader'><th>Total Files</th><th>Files with Violations</th><th>Priority 1</th><th>Priority 2</th><th>Priority 3</th></tr></thead><tbody><tr><td class='number'>380</td><td class='number'>34</td><td class='priority1'>-</td><td class='priority2'>60</td><td class='priority3'>18</td></tr></tbody></table></div><h2>Violations</h2><div class='buttons'><button type='button' onclick='sortData(sortByRuleName)'>Sort by Rule Name</button><button type='button' onclick='sortData(sortByPriority)'>Sort by Rule Priority</button><button type='button' onclick='sortData(sortByRule)'>Sort by Rule (w/Most Violations)</button><button type='button' onclick='sortData(sortByFile)'>Sort by File (w/Most Violations)</button></div><table id='violationsTable' border='1'><thead><tr class='tableHeader'><th>File</th><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr></thead><tbody><tr><td class='pathColumn'>design/PrivateFieldCouldBeFinalRuleTest.groovy</td><td class='ruleColumn'><a href='#MethodCount'>MethodCount</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class PrivateFieldCouldBeFinalRuleTest extends AbstractR..FinalRule&gt; {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.design.PrivateFieldCouldBeFinalRuleTest has 33 methods</span></p></td></tr><tr><td class='pathColumn'>formatting/BracesForForLoopRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>101</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
}</script></head><body><img class='logo' src='http://codenarc.sourceforge.net/images/codenarc-logo.png' alt='CodeNarc' align='right'/><h1>CodeNarc Report</h1><div class='metadata'><table><tr><td class='em'>Report title:</td><td>Sample Project</td></tr><tr><td class='em'>Date:</td><td>Aug 8, 2018 9:32:30 PM</td></tr><tr><td class='em'>Generated with:</td><td><a href='http://www.codenarc.org'>CodeNarc v1.2.1</a></td></tr></table></div><div class='summary'><h2>Summary</h2><table><thead><tr class='tableHeader'><th>Total Files</th><th>Files with Violations</th><th>Priority 1</th><th>Priority 2</th><th>Priority 3</th></tr></thead><tbody><tr><td class='number'>380</td><td class='number'>34</td><td class='priority1'>-</td><td class='priority2'>61</td><td class='priority3'>18</td></tr></tbody></table></div><h2>Violations</h2><div class='buttons'><button type='button' onclick='sortData(sortByRuleName)'>Sort by Rule Name</button><button type='button' onclick='sortData(sortByPriority)'>Sort by Rule Priority</button><button type='button' onclick='sortData(sortByRule)'>Sort by Rule (w/Most Violations)</button><button type='button' onclick='sortData(sortByFile)'>Sort by File (w/Most Violations)</button></div><table id='violationsTable' border='1'><thead><tr class='tableHeader'><th>File</th><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr></thead><tbody><tr><td class='pathColumn'>design/PrivateFieldCouldBeFinalRuleTest.groovy</td><td class='ruleColumn'><a href='#MethodCount'>MethodCount</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class PrivateFieldCouldBeFinalRuleTest extends AbstractR..FinalRule&gt; {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.design.PrivateFieldCouldBeFinalRuleTest has 33 methods</span></p></td></tr><tr><td class='pathColumn'>formatting/BracesForForLoopRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>101</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
for(String name=${SomeClass.SOME_CONSTANT}; name==null;) // And what about {}
{
doStuff()
Expand All @@ -272,7 +272,7 @@
return 99
}
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}'</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#MethodCount'>MethodCount</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class IndentationRuleTest extends AbstractRuleTestCase&lt;I..ationRule&gt; {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.IndentationRuleTest has 39 methods</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>525</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}'</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#MethodCount'>MethodCount</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class IndentationRuleTest extends AbstractRuleTestCase&lt;I..ationRule&gt; {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.IndentationRuleTest has 41 methods</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>525</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|class MyClass {
| private void execute() {
| try {
Expand All @@ -296,17 +296,40 @@
| }
| }
|}
' contains a GString-type expression: '${t.message}'</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>747</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|project.files(project.configurations.scaconfig.files.findAll { File it -&gt; it.name.endsWith '.aar' }
' contains a GString-type expression: '${t.message}'</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>796</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|project.files(project.configurations.scaconfig.files.findAll { File it -&gt; it.name.endsWith '.aar' }.collect { File it -&gt;
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n"
| String hash = new BigInteger(1, sha1.digest(inputFile.bytes)).toString(16)
| cacheDir + hash + File.separator + 'output/jars/classes.jar'
|}).asFileTree
' contains a GString-type expression: '${it.absolutePath}'</span></p></td></tr><tr><td class='pathColumn'>formatting/IndentationRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>810</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|buildFileList()
| .collect { File it -&gt;
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n" +
| "FILE_SIZE=${it.length()}\n" +
| "FILE_TIMESTAMP=${it.lastModified()}"
| String hash = new BigInteger(1, sha1.digest(inputFile.bytes)).toString(16)
| cacheDir + hash + File.separator + 'output/jars/classes.jar'
| }).asFileTree
| "FILE_PATH=${it.absolutePath}\n"
| cacheDir + File.separator + inputFile + sha1
| }
| .each { name -&gt;
| println name
| }
|println "done"
|
|list2.collect { item -&gt;
| item.name
|}.each { name -&gt; println name }
|
|otherList.collect { item -&gt; item.name }.each { name -&gt; println name }
|
|if (expr instanceof ConstructorCallExpression || expr instanceof CastExpression) {
| [Map, Iterable, List, Collection, ArrayList, Set, HashSet].findAll {
| AstUtil.classNodeImplementsType(expr.type, it)
| }.each {
| callbackFunction()
| }
|}
' contains a GString-type expression: '${it.absolutePath}'</span></p></td></tr><tr><td class='pathColumn'>formatting/SpaceAfterClosingBraceRuleTest.groovy</td><td class='ruleColumn'><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2 priorityColumn'>2</td><td class='number'>38</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
Expand Down
48 changes: 36 additions & 12 deletions src/site/resources/SampleCodeNarcTextReport.txt
@@ -1,6 +1,6 @@
CodeNarc Report: Sample Project - Jul 7, 2018 7:04:45 AM
CodeNarc Report: Sample Project - Aug 8, 2018 9:32:32 PM

Summary: TotalFiles=380 FilesWithViolations=34 P1=0 P2=60 P3=18
Summary: TotalFiles=380 FilesWithViolations=34 P1=0 P2=61 P3=18

File: AbstractAstVisitorRuleTest.groovy
Violation: Rule=UnnecessaryObjectReferences P=3 Line=184 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToClassNames = 'Xxx' // doNotApply = NO]
Expand Down Expand Up @@ -57,7 +57,7 @@ File: formatting/BracesForMethodRuleTest.groovy
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}'] Src=[final SOURCE = ''']

File: formatting/IndentationRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=26 Msg=[Class org.codenarc.rule.formatting.IndentationRuleTest has 39 methods] Src=[class IndentationRuleTest extends AbstractRuleTestCase<IndentationRule> {]
Violation: Rule=MethodCount P=2 Line=26 Msg=[Class org.codenarc.rule.formatting.IndentationRuleTest has 41 methods] Src=[class IndentationRuleTest extends AbstractRuleTestCase<IndentationRule> {]
Violation: Rule=GStringExpressionWithinString P=2 Line=525 Msg=[The String '
|class MyClass {
| private void execute() {
Expand All @@ -83,17 +83,41 @@ File: formatting/IndentationRuleTest.groovy
| }
|}
' contains a GString-type expression: '${t.message}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=747 Msg=[The String '
|project.files(project.configurations.scaconfig.files.findAll { File it -> it.name.endsWith '.aar' }
Violation: Rule=GStringExpressionWithinString P=2 Line=796 Msg=[The String '
|project.files(project.configurations.scaconfig.files.findAll { File it -> it.name.endsWith '.aar' }.collect { File it ->
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n"
| String hash = new BigInteger(1, sha1.digest(inputFile.bytes)).toString(16)
| cacheDir + hash + File.separator + 'output/jars/classes.jar'
|}).asFileTree
' contains a GString-type expression: '${it.absolutePath}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=810 Msg=[The String '
|buildFileList()
| .collect { File it ->
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n" +
| "FILE_SIZE=${it.length()}\n" +
| "FILE_TIMESTAMP=${it.lastModified()}"
| String hash = new BigInteger(1, sha1.digest(inputFile.bytes)).toString(16)
| cacheDir + hash + File.separator + 'output/jars/classes.jar'
| }).asFileTree
| "FILE_PATH=${it.absolutePath}\n"
| cacheDir + File.separator + inputFile + sha1
| }
| .each { name ->
| println name
| }
|println "done"
|
|list2.collect { item ->
| item.name
|}.each { name -> println name }
|
|otherList.collect { item -> item.name }.each { name -> println name }
|
|if (expr instanceof ConstructorCallExpression || expr instanceof CastExpression) {
| [Map, Iterable, List, Collection, ArrayList, Set, HashSet].findAll {
| AstUtil.classNodeImplementsType(expr.type, it)
| }.each {
| callbackFunction()
| }
|}
' contains a GString-type expression: '${it.absolutePath}'] Src=[final SOURCE = ''']

File: formatting/SpaceAfterClosingBraceRuleTest.groovy
Expand Down Expand Up @@ -576,4 +600,4 @@ File: unused/UnusedPrivateMethodRuleTest.groovy
File: unused/UnusedVariableRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=26 Msg=[Class org.codenarc.rule.unused.UnusedVariableRuleTest has 35 methods] Src=[class UnusedVariableRuleTest extends AbstractRuleTestCase<UnusedVariableRule> {]

[CodeNarc (http://www.codenarc.org) v1.2]
[CodeNarc (http://www.codenarc.org) v1.2.1]

0 comments on commit c9dc1ea

Please sign in to comment.