This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
Bugfix: Ensure multiple runs invariant #30
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4e4b940
Provide Violations as explicit parameter
mr-archano 5aeab9a
Streamline project specific setup
mr-archano 19c0774
Introduce separate task to collect Checkstyle violations
mr-archano 8eaab97
Extract abstract class for tasks collecting violations
mr-archano 2d3f845
Introduce separate task to collect Pmd violations
mr-archano e4fcdf3
Add html report path as explicit parameter
mr-archano 4b9641a
Use onlyIf predicate to skip task execution
mr-archano 4d6c0af
Format tests
mr-archano a6881f2
Introduce separate task to collect Findbugs violations
mr-archano c7fdc10
Align naming across configurators
mr-archano 8ba2de7
Rename tests to better explain scenario
mr-archano 64f7019
Split variable declaration over separate lines
mr-archano File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
37 changes: 37 additions & 0 deletions
37
plugin/src/main/groovy/com/novoda/staticanalysis/internal/CollectViolationsTask.groovy
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,37 @@ | ||
package com.novoda.staticanalysis.internal | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
abstract class CollectViolationsTask extends DefaultTask { | ||
|
||
private File xmlReportFile | ||
private Violations violations | ||
|
||
CollectViolationsTask() { | ||
onlyIf { xmlReportFile?.exists() } | ||
} | ||
|
||
void setXmlReportFile(File xmlReportFile) { | ||
this.xmlReportFile = xmlReportFile | ||
} | ||
|
||
void setViolations(Violations violations) { | ||
this.violations = violations | ||
} | ||
|
||
@TaskAction | ||
final void run() { | ||
collectViolations(xmlReportFile, htmlReportFile, violations) | ||
} | ||
|
||
File getXmlReportFile() { | ||
return xmlReportFile | ||
} | ||
|
||
File getHtmlReportFile() { | ||
new File(xmlReportFile.absolutePath - '.xml' + '.html') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool syntax |
||
} | ||
|
||
abstract void collectViolations(File xmlReportFile, File htmlReportFile, Violations violations) | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...oovy/com/novoda/staticanalysis/internal/checkstyle/CollectCheckstyleViolationsTask.groovy
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,17 @@ | ||
package com.novoda.staticanalysis.internal.checkstyle | ||
|
||
import com.novoda.staticanalysis.internal.CollectViolationsTask | ||
import com.novoda.staticanalysis.internal.Violations | ||
import groovy.util.slurpersupport.GPathResult | ||
|
||
class CollectCheckstyleViolationsTask extends CollectViolationsTask { | ||
|
||
@Override | ||
void collectViolations(File xmlReportFile, File htmlReportFile, Violations violations) { | ||
GPathResult xml = new XmlSlurper().parse(xmlReportFile) | ||
int errors = xml.'**'.findAll { node -> node.name() == 'error' && node.@severity == 'error' }.size() | ||
int warnings = xml.'**'.findAll { node -> node.name() == 'error' && node.@severity == 'warning' }.size() | ||
violations.addViolations(errors, warnings, htmlReportFile ?: xmlReportFile) | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...n/groovy/com/novoda/staticanalysis/internal/findbugs/CollectFindbugsViolationsTask.groovy
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,13 @@ | ||
package com.novoda.staticanalysis.internal.findbugs | ||
|
||
import com.novoda.staticanalysis.internal.CollectViolationsTask | ||
import com.novoda.staticanalysis.internal.Violations | ||
|
||
class CollectFindbugsViolationsTask extends CollectViolationsTask { | ||
|
||
@Override | ||
void collectViolations(File xmlReportFile, File htmlReportFile, Violations violations) { | ||
def evaluator = new FinbugsViolationsEvaluator(xmlReportFile) | ||
violations.addViolations(evaluator.errorsCount(), evaluator.warningsCount(), htmlReportFile) | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...main/groovy/com/novoda/staticanalysis/internal/findbugs/GenerateFindBugsHtmlReport.groovy
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,19 @@ | ||
package com.novoda.staticanalysis.internal.findbugs | ||
|
||
import org.gradle.api.tasks.JavaExec | ||
|
||
class GenerateFindBugsHtmlReport extends JavaExec { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
File xmlReportFile | ||
File htmlReportFile | ||
|
||
@Override | ||
void exec() { | ||
if (xmlReportFile?.exists()) { | ||
main = 'edu.umd.cs.findbugs.PrintingBugReporter' | ||
standardOutput = new FileOutputStream(htmlReportFile) | ||
args '-html', xmlReportFile | ||
super.exec() | ||
} | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
plugin/src/main/groovy/com/novoda/staticanalysis/internal/findbugs/GenerateHtmlReport.groovy
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...in/src/main/groovy/com/novoda/staticanalysis/internal/pmd/CollectPmdViolationsTask.groovy
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,23 @@ | ||
package com.novoda.staticanalysis.internal.pmd | ||
|
||
import com.novoda.staticanalysis.internal.CollectViolationsTask | ||
import com.novoda.staticanalysis.internal.Violations | ||
|
||
class CollectPmdViolationsTask extends CollectViolationsTask { | ||
|
||
@Override | ||
void collectViolations(File xmlReportFile, File htmlReportFile, Violations violations) { | ||
PmdViolationsEvaluator evaluator = new PmdViolationsEvaluator(xmlReportFile) | ||
int errors = 0 | ||
int warnings = 0 | ||
evaluator.collectViolations().each { PmdViolationsEvaluator.PmdViolation violation -> | ||
if (violation.isError()) { | ||
errors += 1 | ||
} else { | ||
warnings += 1 | ||
} | ||
} | ||
violations.addViolations(errors, warnings, htmlReportFile ?: xmlReportFile) | ||
} | ||
|
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
heh this reminds me of the PMD source code