-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/edu/hm/hafner/analysis/parser/violations/CodeClimateAdapter.java
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 edu.hm.hafner.analysis.parser.violations; | ||
|
||
import se.bjurr.violations.lib.parsers.CodeClimateParser; | ||
|
||
/** | ||
* Parses CodeClimate JSON files. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
public class CodeClimateAdapter extends AbstractViolationAdapter { | ||
private static final long serialVersionUID = 673249539417291948L; | ||
|
||
@Override | ||
CodeClimateParser createParser() { | ||
return new CodeClimateParser(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/edu/hm/hafner/analysis/registry/CodeClimateDescriptor.java
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,27 @@ | ||
package edu.hm.hafner.analysis.registry; | ||
|
||
import edu.hm.hafner.analysis.IssueParser; | ||
import edu.hm.hafner.analysis.parser.violations.CodeClimateAdapter; | ||
|
||
/** | ||
* A descriptor for the Code Climate parser. | ||
* | ||
*/ | ||
class CodeClimateDescriptor extends ParserDescriptor { | ||
private static final String ID = "code-climate"; | ||
private static final String NAME = "Code Climate"; | ||
|
||
CodeClimateDescriptor() { | ||
super(ID, NAME); | ||
} | ||
|
||
@Override | ||
public IssueParser createParser(final Option... options) { | ||
return new CodeClimateAdapter(); | ||
} | ||
|
||
@Override | ||
public String getUrl() { | ||
return "https://codeclimate.com/"; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/test/java/edu/hm/hafner/analysis/parser/violations/CodeClimateAdapterTest.java
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,41 @@ | ||
package edu.hm.hafner.analysis.parser.violations; | ||
|
||
import edu.hm.hafner.analysis.Report; | ||
import edu.hm.hafner.analysis.Severity; | ||
import edu.hm.hafner.analysis.assertions.SoftAssertions; | ||
import edu.hm.hafner.analysis.registry.AbstractParserTest; | ||
|
||
/** | ||
* Tests the class {@link CodeNarcAdapter}. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
class CodeClimateAdapterTest extends AbstractParserTest { | ||
CodeClimateAdapterTest() { | ||
super("code-climate.json"); | ||
} | ||
|
||
@Override | ||
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) { | ||
softly.assertThat(report).hasSize(2); | ||
softly.assertThat(report.get(0)) | ||
.hasMessage("Avoid parameter lists longer than 5 parameters. [6/5]") | ||
.hasFileName("argument_count.rb") | ||
.hasType("Rubocop/Metrics/ParameterLists") | ||
.hasCategory("Complexity") | ||
.hasLineStart(2) | ||
.hasSeverity(Severity.WARNING_NORMAL); | ||
softly.assertThat(report.get(1)) | ||
.hasMessage("Method `destroy` has 6 arguments (exceeds 4 allowed). Consider refactoring.") | ||
.hasFileName("argument_count.rb") | ||
.hasType("argument_count") | ||
.hasCategory("Complexity") | ||
.hasLineStart(2) | ||
.hasSeverity(Severity.WARNING_NORMAL); | ||
} | ||
|
||
@Override | ||
protected CodeClimateAdapter createParser() { | ||
return new CodeClimateAdapter(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/test/resources/edu/hm/hafner/analysis/parser/violations/code-climate.json
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,55 @@ | ||
[ | ||
{ | ||
"categories": [ | ||
"Complexity" | ||
], | ||
"check_name": "argument_count", | ||
"content": { | ||
"body": "" | ||
}, | ||
"description": "Method `destroy` has 6 arguments (exceeds 4 allowed). Consider refactoring.", | ||
"fingerprint": "f778445eae9245ad3a9e5a61bc380d31", | ||
"location": { | ||
"path": "argument_count.rb", | ||
"lines": { | ||
"begin": 2, | ||
"end": 2 | ||
} | ||
}, | ||
"other_locations": [ | ||
|
||
], | ||
"remediation_points": 450000, | ||
"severity": "minor", | ||
"type": "issue", | ||
"engine_name": "structure" | ||
}, | ||
{ | ||
"type": "Issue", | ||
"check_name": "Rubocop\/Metrics\/ParameterLists", | ||
"description": "Avoid parameter lists longer than 5 parameters. [6\/5]", | ||
"categories": [ | ||
"Complexity" | ||
], | ||
"remediation_points": 250000, | ||
"location": { | ||
"path": "argument_count.rb", | ||
"positions": { | ||
"begin": { | ||
"column": 14, | ||
"line": 2 | ||
}, | ||
"end": { | ||
"column": 27, | ||
"line": 2 | ||
} | ||
} | ||
}, | ||
"content": { | ||
"body": "This cop checks for methods with too many parameters.\nThe maximum number of parameters is configurable.\nKeyword arguments can optionally be excluded from the total count." | ||
}, | ||
"engine_name": "rubocop", | ||
"fingerprint": "5182fe949b37d86b6a434d96c19ca44f", | ||
"severity": "minor" | ||
} | ||
] |