Skip to content

Commit

Permalink
[cleanup] Stop over usage of 'def' when types are known in IT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hazendaz committed Dec 16, 2023
1 parent 6941e35 commit 3fb8685
Show file tree
Hide file tree
Showing 48 changed files with 184 additions and 187 deletions.
10 changes: 5 additions & 5 deletions src/it/basic-1/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import groovy.xml.XmlSlurper

def effortLevel = 'default'
String effortLevel = 'default'


File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html')
Expand All @@ -34,12 +34,12 @@ println '***************************'

assert spotbugsHtml.text.contains( "<i>" + effortLevel + "</i>" )

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )
//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -50,7 +50,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -61,7 +61,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"


Expand Down
2 changes: 1 addition & 1 deletion src/it/change-xml-filename/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand Down
4 changes: 2 additions & 2 deletions src/it/check-bug-file-multi-list/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -39,7 +39,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == 0
Expand Down
4 changes: 2 additions & 2 deletions src/it/check-bug-file-multi/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -39,7 +39,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == 0
Expand Down
4 changes: 2 additions & 2 deletions src/it/check-bug-file/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -39,7 +39,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == 0
Expand Down
4 changes: 2 additions & 2 deletions src/it/check-jvmargs/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"

println '***************************'
Expand All @@ -39,7 +39,7 @@ println '***************************'
def path = new XmlSlurper().parse(spotbugXdoc)

def allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == spotbugsXmlErrors
2 changes: 1 addition & 1 deletion src/it/check-multi/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ println '**********************************'


allNodes = path.depthFirst().collect { it }
def spotbugsErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsErrors}"

assert spotbugsErrors > 0
Expand Down
4 changes: 2 additions & 2 deletions src/it/check-pluginList-repo/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -40,7 +40,7 @@ println '***************************'
def path = new XmlSlurper().parse(spotbugXdoc)

def allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == spotbugsXmlErrors
4 changes: 2 additions & 2 deletions src/it/check/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -43,7 +43,7 @@ println '***************************'
def path = new XmlSlurper().parse(spotbugXdoc)

xNodes = path.depthFirst().collect{ it }
def xdocErrors = xNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = xNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert xdocErrors == spotbugsXmlErrors
10 changes: 5 additions & 5 deletions src/it/effort-default/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import groovy.xml.XmlSlurper

def effortLevel = 'default'
String effortLevel = 'default'

File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html')
assert spotbugsHtml.exists()
Expand All @@ -33,13 +33,13 @@ println '***************************'

assert spotbugsHtml.text.contains( "<i>" + effortLevel + "</i>" )

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )

//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -50,7 +50,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -61,7 +61,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert path.findAll {it.name() == 'BugCollection'}.@effort.text() == effortLevel
Expand Down
10 changes: 5 additions & 5 deletions src/it/effort-max/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import groovy.xml.XmlSlurper

def effortLevel = 'max'
String effortLevel = 'max'


File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html')
Expand All @@ -34,13 +34,13 @@ println '***************************'

assert spotbugsHtml.text.contains( "<i>" + effortLevel + "</i>" )

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )

//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -51,7 +51,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -62,7 +62,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert path.findAll {it.name() == 'BugCollection'}.@effort.text() == effortLevel
Expand Down
10 changes: 5 additions & 5 deletions src/it/effort-min/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import groovy.xml.XmlSlurper

def effortLevel = 'min'
String effortLevel = 'min'


File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html')
Expand All @@ -34,13 +34,13 @@ println '***************************'

assert spotbugsHtml.text.contains( "<i>" + effortLevel + "</i>" )

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )

//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -51,7 +51,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -62,7 +62,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"

assert path.findAll {it.name() == 'BugCollection'}.@effort.text() == effortLevel
Expand Down
8 changes: 4 additions & 4 deletions src/it/encoding-utf8/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ println '***************************'
println "Checking HTML file"
println '***************************'

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )
//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -45,7 +45,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -56,7 +56,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"


Expand Down
2 changes: 1 addition & 1 deletion src/it/exclude-modules/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ println '**********************************'


allNodes = path.depthFirst().collect { it }
def spotbugsErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsErrors}"

assert spotbugsErrors > 0
Expand Down
8 changes: 4 additions & 4 deletions src/it/exclude-multi-list/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ println '***************************'
println "Checking HTML file"
println '***************************'

def xhtmlParser = new XmlSlurper();
XmlSlurper xhtmlParser = new XmlSlurper();
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def path = xhtmlParser.parse( spotbugsHtml )
//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2]
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
int spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger()
println "Error Count is ${spotbugsErrors}"


Expand All @@ -45,7 +45,7 @@ println '**********************************'
path = new XmlSlurper().parse(spotbugXml)

allNodes = path.depthFirst().collect{ it }
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${spotbugsXmlErrors}"


Expand All @@ -56,7 +56,7 @@ println '***************************'
path = new XmlSlurper().parse(spotbugXdoc)

allNodes = path.depthFirst().collect{ it }
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
int xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size()
println "BugInstance size is ${xdocErrors}"


Expand Down
Loading

0 comments on commit 3fb8685

Please sign in to comment.