if (issue.type() == null) {
Rule rule = ruleRepository.getByKey(issue.ruleKey());
if (!rule.isExternal()) {
+ // rule type should never be null for rules created by plugins (non-external rules)
issue.setType(rule.getType());
}
}
assertThat(tester.allExternalIssues()).isEmpty();
NewExternalIssue newExternalIssue = tester.newExternalIssue();
newExternalIssue
- .at(newExternalIssue.newLocation().on(new TestInputFileBuilder("foo", "src/Foo.java").build()))
+ .at(newExternalIssue.newLocation().message("message").on(new TestInputFileBuilder("foo", "src/Foo.java").build()))
.forRule(RuleKey.of("repo", "rule"))
.type(RuleType.BUG)
.severity(Severity.BLOCKER)
.save();
newExternalIssue = tester.newExternalIssue();
newExternalIssue
- .at(newExternalIssue.newLocation().on(new TestInputFileBuilder("foo", "src/Foo.java").build()))
+ .at(newExternalIssue.newLocation().message("message").on(new TestInputFileBuilder("foo", "src/Foo.java").build()))
.type(RuleType.BUG)
.severity(Severity.BLOCKER)
.forRule(RuleKey.of("repo", "rule"))
}
@CheckForNull
- private NewIssueLocation fillLocation(SensorContext context, NewIssueLocation newLocation, Location location) {
+ private static NewIssueLocation fillLocation(SensorContext context, NewIssueLocation newLocation, Location location) {
InputFile file = findFile(context, location.filePath);
if (file != null) {
newLocation
System.out.println(Paths.get("org/sonar/scanner/externalissue/report.json").toAbsolutePath());
Report report = parser.parse();
- assertThat(report.issues).hasSize(2);
+ assertThat(report.issues).hasSize(3);
assertThat(report.issues[0].engineId).isEqualTo("eslint");
assertThat(report.issues[0].ruleId).isEqualTo("rule1");
assertThat(report.issues[0].severity).isEqualTo("MAJOR");
assertThat(report.issues[0].type).isEqualTo("CODE_SMELL");
assertThat(report.issues[0].primaryLocation.filePath).isEqualTo("file1.js");
assertThat(report.issues[0].primaryLocation.message).isEqualTo("fix the issue here");
- assertThat(report.issues[0].primaryLocation.textRange.startColumn).isNull();
+ assertThat(report.issues[0].primaryLocation.textRange.startColumn).isEqualTo(2);
assertThat(report.issues[0].primaryLocation.textRange.startLine).isEqualTo(1);
- assertThat(report.issues[0].primaryLocation.textRange.endColumn).isNull();
- assertThat(report.issues[0].primaryLocation.textRange.endLine).isEqualTo(2);
+ assertThat(report.issues[0].primaryLocation.textRange.endColumn).isEqualTo(4);
+ assertThat(report.issues[0].primaryLocation.textRange.endLine).isEqualTo(3);
assertThat(report.issues[0].secondaryLocations).isNull();
}
"message": "fix the bug here",
"filePath": "xources/hello/HelloJava.xoo",
"textRange": {
- "startLine": 3,
- "endLine": 3
+ "startLine": 3
}
}
},
"message": "fix the bug here",
"filePath": "invalidFile",
"textRange": {
- "startLine": 3,
- "endLine": 3
+ "startLine": 3
}
}
},
"filePath": "file1.js",
"textRange": {
"startLine": 1,
- "endLine": 2
+ "startColumn": 2,
+ "endLine": 3,
+ "endColumn": 4
}
}
},
"message": "fix the bug here",
"filePath": "file2.js",
"textRange": {
- "startLine": 3,
- "endLine": 4
+ "startLine": 3
}
+ }
+ },
+ {
+ "engineId": "eslint",
+ "ruleId": "rule3",
+ "severity": "MAJOR",
+ "type": "BUG",
+ "primaryLocation": {
+ "message": "fix the bug here",
+ "filePath": "file3.js"
}
}
]
}
-