]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6162 Fix bad merge
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 9 Feb 2015 17:23:17 +0000 (18:23 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 9 Feb 2015 17:35:36 +0000 (18:35 +0100)
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java
sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java
sonar-batch/src/test/java/org/sonar/batch/issue/ModuleIssuesTest.java
sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ChecksMediumTest.java

index 249967d425e2c74e39ad1a25f60189fd37dd9a47..dd4792c97236ed9a875ebb842e5a9e78829345a2 100644 (file)
@@ -42,9 +42,9 @@ public class ChecksSensor implements Sensor {
   public void describe(SensorDescriptor descriptor) {
     descriptor
       .name("ChecksSensor")
-      .workOnLanguages(Xoo.KEY)
+      .onlyOnLanguage(Xoo.KEY)
       .createIssuesForRuleRepositories(XooRulesDefinition.XOO_REPOSITORY)
-      .workOnFileTypes(InputFile.Type.MAIN);
+      .onlyOnFileType(InputFile.Type.MAIN);
   }
 
   @Override
index b98cde9ff153ae8f2047fc38326e7f963e1df63f..64f7e8d2446f31038ef97969a879d7527155ab2a 100644 (file)
@@ -26,6 +26,7 @@ import org.sonar.api.batch.rule.ActiveRule;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.rule.Rule;
 import org.sonar.api.batch.rule.Rules;
+import org.sonar.api.batch.rule.internal.DefaultActiveRule;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.resources.Project;
 import org.sonar.api.rule.RuleKey;
@@ -115,8 +116,8 @@ public class ModuleIssues {
   }
 
   private void updateIssue(DefaultIssue issue, @Nullable Rule rule, ActiveRule activeRule) {
-    if (rule != null && Strings.isNullOrEmpty(issue.message())) {
-      issue.setMessage(rule.name());
+    if (Strings.isNullOrEmpty(issue.message())) {
+      issue.setMessage(((DefaultActiveRule) activeRule).name());
     }
     if (project != null) {
       issue.setCreationDate(project.getAnalysisDate());
index d4ed8b2972b3ff81aa4c6ce76b180068cf6ccf26..9e6884f0a8de990057eaba3ea36a767be755dcf9 100644 (file)
@@ -57,11 +57,6 @@ import org.sonar.duplications.internal.pmd.PmdBlockChunker;
 import java.io.Serializable;
 import java.util.List;
 
-/**
- * Common bits between {@link ExperimentalSensorStorage} and {@link SensorContextAdapter}
- * @author julien
- *
- */
 public class DefaultSensorContext implements SensorContext {
 
   private final Settings settings;
index a4cf6a1329bcdd20cd226ede63307c6c2938aee1..0594cb162347ac7bcaeb1d0baba570f6ba4c7bcd 100644 (file)
@@ -179,7 +179,7 @@ public class ModuleIssuesTest {
   @Test
   public void use_rule_name_if_no_message() throws Exception {
     ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
-    activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).activate();
+    activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).setName(SQUID_RULE_NAME).activate();
     initModuleIssues();
 
     Date analysisDate = new Date();
index 54c2aab58b4e97b28833a74008c1039419b348f0..5d1a3838f36a69b162358dc08b457cb773c2672d 100644 (file)
@@ -25,17 +25,15 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.issue.Issue;
 import org.sonar.batch.mediumtest.BatchMediumTester;
-import org.sonar.batch.mediumtest.BatchMediumTester.TaskResult;
+import org.sonar.batch.mediumtest.TaskResult;
 import org.sonar.batch.protocol.input.ActiveRule;
 import org.sonar.xoo.XooPlugin;
 
 import java.io.File;
 import java.io.IOException;
 
-import static org.fest.assertions.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class ChecksMediumTest {
 
@@ -47,7 +45,6 @@ public class ChecksMediumTest {
     .addDefaultQProfile("xoo", "Sonar Way")
     .activateRule(new ActiveRule("xoo", "TemplateRule_1234", "TemplateRule", "A template rule", "MAJOR", null, "xoo").addParam("line", "1"))
     .activateRule(new ActiveRule("xoo", "TemplateRule_1235", "TemplateRule", "Another template rule", "MAJOR", null, "xoo").addParam("line", "2"))
-    .bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor"))
     .build();
 
   @Before
@@ -86,15 +83,15 @@ public class ChecksMediumTest {
 
     boolean foundIssueAtLine1 = false;
     boolean foundIssueAtLine2 = false;
-    for (Issue issue : result.issues()) {
+    for (org.sonar.api.issue.Issue issue : result.issues()) {
       if (issue.line() == 1) {
         foundIssueAtLine1 = true;
-        assertThat(issue.inputPath()).isEqualTo(new DefaultInputFile("com.foo.project", "src/sample.xoo"));
+        assertThat(issue.componentKey()).isEqualTo("com.foo.project:src/sample.xoo");
         assertThat(issue.message()).isEqualTo("A template rule");
       }
       if (issue.line() == 2) {
         foundIssueAtLine2 = true;
-        assertThat(issue.inputPath()).isEqualTo(new DefaultInputFile("com.foo.project", "src/sample.xoo"));
+        assertThat(issue.componentKey()).isEqualTo("com.foo.project:src/sample.xoo");
         assertThat(issue.message()).isEqualTo("Another template rule");
       }
     }