diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2018-04-24 09:19:12 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-04-26 20:20:53 +0200 |
commit | 4373ca61250f094d623bc951c90978118e2179c1 (patch) | |
tree | 3e3458320a9d9c1f4734c8139384e70990e4673d /sonar-scanner-engine | |
parent | 99087f92a5839fe9f44090674d75576a4d9e6908 (diff) | |
download | sonarqube-4373ca61250f094d623bc951c90978118e2179c1.tar.gz sonarqube-4373ca61250f094d623bc951c90978118e2179c1.zip |
SONAR-10543 Fix external issues effort
Diffstat (limited to 'sonar-scanner-engine')
5 files changed, 9 insertions, 3 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueImporter.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueImporter.java index 99100318b68..74cf2e6434d 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueImporter.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssueImporter.java @@ -72,9 +72,12 @@ public class ExternalIssueImporter { NewExternalIssue externalIssue = context.newExternalIssue() .forRule(RuleKey.of(issue.engineId, issue.ruleId)) .severity(Severity.valueOf(issue.severity)) - .remediationEffortMinutes(20L) .type(RuleType.valueOf(issue.type)); + if (issue.effortMinutes != null) { + externalIssue.remediationEffortMinutes(Long.valueOf(issue.effortMinutes)); + } + NewIssueLocation primary = fillLocation(context, externalIssue.newLocation(), issue.primaryLocation); if (primary != null) { knownFiles.add(issue.primaryLocation.filePath); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java index add4404b2a9..5c67ec7707e 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java @@ -43,7 +43,7 @@ public class ReportParserTest { 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].effortMinutes).isEqualTo(20); + assertThat(report.issues[0].effortMinutes).isEqualTo(40); 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"); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java index 92e01b6491d..dddb88040ff 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java @@ -92,6 +92,7 @@ public class ExternalIssuesMediumTest { assertThat(issue.getMsg()).isEqualTo("fix the issue here"); assertThat(issue.getRuleKey()).isEqualTo("rule1"); assertThat(issue.getSeverity()).isEqualTo(Severity.MAJOR); + assertThat(issue.getEffort()).isEqualTo(50l); assertThat(issue.getType()).isEqualTo(IssueType.CODE_SMELL); assertThat(issue.getTextRange().getStartLine()).isEqualTo(5); assertThat(issue.getTextRange().getEndLine()).isEqualTo(5); @@ -105,6 +106,7 @@ public class ExternalIssuesMediumTest { assertThat(issue.getRuleKey()).isEqualTo("rule2"); assertThat(issue.getSeverity()).isEqualTo(Severity.CRITICAL); assertThat(issue.getType()).isEqualTo(IssueType.BUG); + assertThat(issue.getEffort()).isZero(); assertThat(issue.getTextRange().getStartLine()).isEqualTo(3); assertThat(issue.getTextRange().getEndLine()).isEqualTo(3); assertThat(issue.getTextRange().getStartOffset()).isEqualTo(0); diff --git a/sonar-scanner-engine/src/test/resources/mediumtest/xoo/sample/externalIssues.json b/sonar-scanner-engine/src/test/resources/mediumtest/xoo/sample/externalIssues.json index 539533af78f..8ad6dd2c9ec 100644 --- a/sonar-scanner-engine/src/test/resources/mediumtest/xoo/sample/externalIssues.json +++ b/sonar-scanner-engine/src/test/resources/mediumtest/xoo/sample/externalIssues.json @@ -5,6 +5,7 @@ "ruleId": "rule1", "severity": "MAJOR", "type": "CODE_SMELL", + "effortMinutes": 50, "primaryLocation": { "message": "fix the issue here", "filePath": "xources/hello/HelloJava.xoo", diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/externalissue/report.json b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/externalissue/report.json index b951311436b..1009cfe4eb8 100644 --- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/externalissue/report.json +++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/externalissue/report.json @@ -5,7 +5,7 @@ "ruleId": "rule1", "severity": "MAJOR", "type": "CODE_SMELL", - "effortMinutes": 20, + "effortMinutes": 40, "primaryLocation": { "message": "fix the issue here", "filePath": "file1.js", |