From 072791ac2b31eb8f01b686b754c930a1ff4a600e Mon Sep 17 00:00:00 2001 From: Léo Geoffroy Date: Fri, 18 Aug 2023 14:03:55 +0200 Subject: SONAR-20021 Fix Quality gate failure and issue with adhoc rule definition --- .../java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins') diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java index 03a18f350b2..84a11798a15 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java @@ -27,6 +27,8 @@ import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.batch.sensor.issue.NewExternalIssue; +import org.sonar.api.issue.impact.SoftwareQuality; +import org.sonar.api.rules.CleanCodeAttribute; import org.sonar.api.rules.RuleType; import org.sonar.xoo.Xoo; @@ -63,6 +65,9 @@ public class OneExternalIssuePerLineSensor implements Sensor { .description("blah blah") .severity(Severity.BLOCKER) .type(RuleType.BUG) + .cleanCodeAttribute(CleanCodeAttribute.CLEAR) + .addDefaultImpact(SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.MEDIUM) + .addDefaultImpact(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW) .save(); } } @@ -78,6 +83,8 @@ public class OneExternalIssuePerLineSensor implements Sensor { .at(file.selectLine(line)) .message("This issue is generated on each line")) .severity(Severity.valueOf(SEVERITY)) + //Overrides default impact from the adhoc rule + .addImpact(SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.HIGH) .remediationEffortMinutes(EFFORT) .type(TYPE) .save(); -- cgit v1.2.3