aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-04-13 15:59:23 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-26 20:20:51 +0200
commit6c5aad9a2d48cd783993a3a31911e307bf6827f5 (patch)
treee12910dde39fb187663a7f9bf6c93d73bb45efef
parent4cbf46ae604e6619c5b1fdaab81f5dd28f464a0e (diff)
downloadsonarqube-6c5aad9a2d48cd783993a3a31911e307bf6827f5.tar.gz
sonarqube-6c5aad9a2d48cd783993a3a31911e307bf6827f5.zip
SONAR-10543 Update test to v7.2 and remove descriptionUrl and ruleTitle from scanner
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java3
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneExternalIssuePerLineSensor.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/ExternalIssue.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewExternalIssue.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java24
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java29
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewExternalIssue.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java3
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto5
11 files changed, 5 insertions, 100 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index 3c036b1d566..47a8c3be351 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -168,8 +168,7 @@ public class XooPlugin implements Plugin {
if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(6, 6))) {
context.addExtension(XooBuiltInQualityProfilesDefinition.class);
}
- // TODO change to v7.2 once version of SQ was updated
- if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 1))) {
+ if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2))) {
context.addExtension(OneExternalIssuePerLineSensor.class);
}
}
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 e47ddd4ef60..7b872e26ee8 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
@@ -74,8 +74,6 @@ public class OneExternalIssuePerLineSensor implements Sensor {
.on(file)
.at(file.selectLine(line))
.message("This issue is generated on each line"))
- .ruleTitle(NAME)
- .descriptionUrl("http://oneexternalissueperline.xoo.net")
.severity(Severity.valueOf(SEVERITY))
.remediationEffort(EFFORT)
.type(type)
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/ExternalIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/ExternalIssue.java
index ec72c49de1a..b151a6582aa 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/ExternalIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/ExternalIssue.java
@@ -33,12 +33,6 @@ public interface ExternalIssue extends IIssue {
Severity severity();
/**
- * Link to a page describing more details about the rule that triggered this issue.
- */
- @CheckForNull
- String descriptionUrl();
-
- /**
* Effort to fix the issue, in minutes.
*/
@CheckForNull
@@ -48,9 +42,5 @@ public interface ExternalIssue extends IIssue {
* Type of the issue.
*/
RuleType type();
-
- /**
- * Short description of the rule. Should not depend on the issue being raised.
- */
- String ruleTitle();
+
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewExternalIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewExternalIssue.java
index 8049c44e1dc..d2e55a999ee 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewExternalIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewExternalIssue.java
@@ -63,11 +63,6 @@ public interface NewExternalIssue {
NewExternalIssue addLocation(NewIssueLocation secondaryLocation);
/**
- * Add a URL pointing to more information about the rule triggering this issue.
- */
- NewExternalIssue descriptionUrl(String url);
-
- /**
* Register a flow for this issue. A flow is an ordered list of issue locations that help to understand the issue.
* It should be a <b>path that backtracks the issue from its primary location to the start of the flow</b>.
* Several flows can be registered.
@@ -80,11 +75,6 @@ public interface NewExternalIssue {
NewIssueLocation newLocation();
/**
- * Add the description of the rule. Should not depend on the issue being raised.
- */
- NewExternalIssue ruleTitle(String title);
-
- /**
* Save the issue. If rule key is unknown or rule not enabled in the current quality profile then a warning is logged but no exception
* is thrown.
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
index 6ffcb5055e8..a0bd77b53c7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java
@@ -34,9 +34,7 @@ import static java.util.Objects.requireNonNull;
public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIssue> implements ExternalIssue, NewExternalIssue {
private Long effort;
private Severity severity;
- private String url;
private RuleType type;
- private String ruleTitle;
public DefaultExternalIssue() {
super(null);
@@ -74,24 +72,12 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
requireNonNull(this.ruleKey, "Rule key is mandatory on external issue");
checkState(primaryLocation != null, "Primary location is mandatory on every external issue");
checkState(primaryLocation.inputComponent().isFile(), "External issues must be located in files");
- checkState(ruleTitle != null, "Rule title is mandatory on every external issue");
checkState(severity != null, "Severity is mandatory on every external issue");
checkState(type != null, "Type is mandatory on every external issue");
storage.store(this);
}
@Override
- public DefaultExternalIssue descriptionUrl(String url) {
- this.url = url;
- return this;
- }
-
- @Override
- public String descriptionUrl() {
- return url;
- }
-
- @Override
public RuleType type() {
return type;
}
@@ -102,14 +88,4 @@ public class DefaultExternalIssue extends AbstractDefaultIssue<DefaultExternalIs
return this;
}
- @Override
- public String ruleTitle() {
- return ruleTitle;
- }
-
- @Override
- public DefaultExternalIssue ruleTitle(String ruleTitle) {
- this.ruleTitle = ruleTitle;
- return this;
- }
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
index b47ef208fed..0cee9bc2a96 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
@@ -117,7 +117,6 @@ public class SensorContextTesterTest {
.forRule(RuleKey.of("repo", "rule"))
.type(RuleType.BUG)
.severity(Severity.BLOCKER)
- .ruleTitle("title")
.save();
newExternalIssue = tester.newExternalIssue();
newExternalIssue
@@ -125,7 +124,6 @@ public class SensorContextTesterTest {
.type(RuleType.BUG)
.severity(Severity.BLOCKER)
.forRule(RuleKey.of("repo", "rule"))
- .ruleTitle("title")
.save();
assertThat(tester.allExternalIssues()).hasSize(2);
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
index 57998dc4ba8..1176527f04c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
@@ -52,19 +52,15 @@ public class DefaultExternalIssueTest {
.message("Wrong way!"))
.forRule(RuleKey.of("repo", "rule"))
.remediationEffort(10l)
- .descriptionUrl("url")
.type(RuleType.BUG)
- .ruleTitle("rule")
.severity(Severity.BLOCKER);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(inputFile);
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule"));
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
assertThat(issue.remediationEffort()).isEqualTo(10l);
- assertThat(issue.descriptionUrl()).isEqualTo("url");
assertThat(issue.type()).isEqualTo(RuleType.BUG);
assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
- assertThat(issue.ruleTitle()).isEqualTo("rule");
assertThat(issue.primaryLocation().message()).isEqualTo("Wrong way!");
issue.save();
@@ -82,8 +78,6 @@ public class DefaultExternalIssueTest {
.message("Wrong way!"))
.forRule(RuleKey.of("repo", "rule"))
.remediationEffort(10l)
- .descriptionUrl("url")
- .ruleTitle("rule")
.severity(Severity.BLOCKER);
exception.expect(IllegalStateException.class);
@@ -100,8 +94,6 @@ public class DefaultExternalIssueTest {
.message("Wrong way!"))
.forRule(RuleKey.of("repo", "rule"))
.remediationEffort(10l)
- .descriptionUrl("url")
- .ruleTitle("rule")
.severity(Severity.BLOCKER);
exception.expect(IllegalStateException.class);
@@ -119,8 +111,6 @@ public class DefaultExternalIssueTest {
.message("Wrong way!"))
.forRule(RuleKey.of("repo", "rule"))
.remediationEffort(10l)
- .descriptionUrl("url")
- .ruleTitle("rule")
.type(RuleType.BUG);
exception.expect(IllegalStateException.class);
@@ -128,23 +118,4 @@ public class DefaultExternalIssueTest {
issue.save();
}
- @Test
- public void fail_to_store_if_no_rule_title() {
- SensorStorage storage = mock(SensorStorage.class);
- DefaultExternalIssue issue = new DefaultExternalIssue(storage)
- .at(new DefaultIssueLocation()
- .on(inputFile)
- .at(inputFile.selectLine(1))
- .message("Wrong way!"))
- .forRule(RuleKey.of("repo", "rule"))
- .remediationEffort(10l)
- .descriptionUrl("url")
- .severity(Severity.BLOCKER)
- .type(RuleType.BUG);
-
- exception.expect(IllegalStateException.class);
- exception.expectMessage("Rule title is mandatory");
- issue.save();
- }
-
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java
index 1ff50f8e5b5..f8d72f526e7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ModuleIssues.java
@@ -111,7 +111,7 @@ public class ModuleIssues {
}
private static ScannerReport.ExternalIssue createReportExternalIssue(ExternalIssue issue, int componentRef) {
- String primaryMessage = Strings.isNullOrEmpty(issue.primaryLocation().message()) ? issue.ruleTitle() : issue.primaryLocation().message();
+ String primaryMessage = Strings.isNullOrEmpty(issue.primaryLocation().message()) ? issue.ruleKey().toString() : issue.primaryLocation().message();
Severity severity = Severity.valueOf(issue.severity().name());
ScannerReport.ExternalIssue.Builder builder = ScannerReport.ExternalIssue.newBuilder();
@@ -121,7 +121,6 @@ public class ModuleIssues {
builder.setSeverity(severity);
builder.setRuleRepository(issue.ruleKey().repository());
builder.setRuleKey(issue.ruleKey().rule());
- builder.setRuleTitle(issue.ruleTitle());
builder.setMsg(primaryMessage);
locationBuilder.setMsg(primaryMessage);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewExternalIssue.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewExternalIssue.java
index 42d4a902a74..16066a4f617 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewExternalIssue.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewExternalIssue.java
@@ -65,12 +65,6 @@ public class NoOpNewExternalIssue implements NewExternalIssue {
}
@Override
- public NewExternalIssue descriptionUrl(String url) {
- // no op
- return this;
- }
-
- @Override
public NewExternalIssue addFlow(Iterable<NewIssueLocation> flowLocations) {
// no op
return this;
@@ -83,12 +77,6 @@ public class NoOpNewExternalIssue implements NewExternalIssue {
}
@Override
- public NewExternalIssue ruleTitle(String title) {
- // no op
- return this;
- }
-
- @Override
public void save() {
// no op
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java
index 844f6edcfab..6309720339d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ModuleIssuesTest.java
@@ -155,8 +155,7 @@ public class ModuleIssuesTest {
DefaultExternalIssue issue = new DefaultExternalIssue()
.at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo"))
.forRule(SQUID_RULE_KEY)
- .severity(org.sonar.api.batch.rule.Severity.CRITICAL)
- .ruleTitle("title");
+ .severity(org.sonar.api.batch.rule.Severity.CRITICAL);
moduleIssues.initAndAddExternalIssue(issue);
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index 13cf6dd56cc..922adca6f57 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -197,10 +197,7 @@ message ExternalIssue {
// Will be identical to the first location of the first flow
TextRange text_range = 6;
repeated Flow flow = 7;
- // Can be empty as the field is optional
- string descriptionUrl = 8;
- IssueType type = 9;
- string rule_title = 10;
+ IssueType type = 8;
}
enum IssueType {