Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Code Climate #1002

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
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/";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ParserRegistry {
new CmakeDescriptor(),
new CodeAnalysisDescriptor(),
new CodeCheckerDescriptor(),
new CodeClimateDescriptor(),
new CodeGeneratorDescriptor(),
new CodeNarcDescriptor(),
new CoolfluxChessccDescriptor(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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;

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();
}
}
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"
}
]
Loading