]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 20 Feb 2015 15:34:31 +0000 (16:34 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 20 Feb 2015 16:15:00 +0000 (17:15 +0100)
17 files changed:
sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultAnalysisMode.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/package-info.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/duplication/FileBlocksValueCoder.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileMetadata.java
sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java
sonar-batch/src/main/java/org/sonar/batch/symbol/DefaultSymbolTableBuilder.java
sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/ReportsMediumTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorContextTest.java
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java

index e97dce7da40020e596588b769f1fe6b1f447b0f8..2b5e7bd5577296b4c610cd63246614579d5d42b0 100644 (file)
@@ -23,6 +23,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.AnalysisMode;
+import org.sonar.batch.mediumtest.BatchMediumTester;
 
 import java.text.MessageFormat;
 
@@ -64,18 +65,18 @@ public class DefaultAnalysisMode implements AnalysisMode {
       LOG.warn(MessageFormat.format("Property {0} is deprecated. Please use {1} instead.", CoreProperties.DRY_RUN, CoreProperties.ANALYSIS_MODE));
       preview = "true".equals(bootstrapProps.property(CoreProperties.DRY_RUN));
       incremental = false;
-      mediumTestMode = false;
     } else {
       String mode = bootstrapProps.property(CoreProperties.ANALYSIS_MODE);
       preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
       incremental = CoreProperties.ANALYSIS_MODE_INCREMENTAL.equals(mode);
-      mediumTestMode = CoreProperties.ANALYSIS_MODE_MEDIUM_TEST.equals(mode);
     }
+    mediumTestMode = "true".equals(bootstrapProps.property(BatchMediumTester.MEDIUM_TEST_ENABLED));
     if (incremental) {
       LOG.info("Incremental mode");
     } else if (preview) {
       LOG.info("Preview mode");
-    } else if (mediumTestMode) {
+    }
+    if (mediumTestMode) {
       LOG.info("Medium test mode");
     }
     // To stay compatible with plugins that use the old property to check mode
index c216e7ab29f6e0f1ed976ad716c08b08f0019f0e..6558fa59c0b85dd217cebc89496c44cdb336ba0f 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch.deprecated;
 
-import org.sonar.api.batch.sensor.internal.SensorStorage;
-
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,15 +31,20 @@ import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputPath;
 import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
 import org.sonar.api.config.Settings;
 import org.sonar.api.design.Dependency;
 import org.sonar.api.measures.Measure;
 import org.sonar.api.measures.MeasuresFilter;
 import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.ProjectLink;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
 import org.sonar.api.rules.Violation;
 import org.sonar.api.utils.SonarException;
-import org.sonar.batch.index.ComponentDataCache;
 import org.sonar.batch.sensor.DefaultSensorContext;
 import org.sonar.batch.sensor.coverage.CoverageExclusions;
 
@@ -62,9 +65,9 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen
   private final CoverageExclusions coverageFilter;
 
   public DeprecatedSensorContext(SonarIndex index, Project project, Settings settings, FileSystem fs, ActiveRules activeRules,
-    AnalysisMode analysisMode, ComponentDataCache componentDataCache, CoverageExclusions coverageFilter,
+    AnalysisMode analysisMode, CoverageExclusions coverageFilter,
     SensorStorage sensorStorage) {
-    super(settings, fs, activeRules, analysisMode, componentDataCache, sensorStorage);
+    super(settings, fs, activeRules, analysisMode, sensorStorage);
     this.index = index;
     this.project = project;
     this.coverageFilter = coverageFilter;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/package-info.java
new file mode 100644 (file)
index 0000000..4d537fe
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.batch.deprecated.decorator;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/FileBlocksValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/FileBlocksValueCoder.java
deleted file mode 100644 (file)
index 99b3467..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.duplication;
-
-import com.persistit.Value;
-import com.persistit.encoding.CoderContext;
-import com.persistit.encoding.ValueCoder;
-import org.sonar.duplications.block.Block;
-import org.sonar.duplications.block.ByteArray;
-import org.sonar.duplications.block.FileBlocks;
-
-import java.util.ArrayList;
-import java.util.List;
-
-class FileBlocksValueCoder implements ValueCoder {
-
-  @Override
-  public void put(Value value, Object object, CoderContext context) {
-    FileBlocks blocks = (FileBlocks) object;
-    value.putUTF(blocks.resourceId());
-    value.put(blocks.blocks().size());
-    for (Block b : blocks.blocks()) {
-      value.putByteArray(b.getBlockHash().getBytes());
-      value.put(b.getIndexInFile());
-      value.put(b.getStartLine());
-      value.put(b.getEndLine());
-      value.put(b.getStartUnit());
-      value.put(b.getEndUnit());
-    }
-  }
-
-  @Override
-  public Object get(Value value, Class clazz, CoderContext context) {
-    String resourceId = value.getString();
-    int count = value.getInt();
-    List<Block> blocks = new ArrayList<Block>(count);
-    for (int i = 0; i < count; i++) {
-      Block.Builder b = Block.builder();
-      b.setResourceId(resourceId);
-      b.setBlockHash(new ByteArray(value.getByteArray()));
-      b.setIndexInFile(value.getInt());
-      int startLine = value.getInt();
-      int endLine = value.getInt();
-      b.setLines(startLine, endLine);
-      int startUnit = value.getInt();
-      int endUnit = value.getInt();
-      b.setUnit(startUnit, endUnit);
-      blocks.add(b.build());
-    }
-    return new FileBlocks(resourceId, blocks);
-  }
-}
index dc060ce058ba5732afd8663f7ad373fc35d504e7..5f5f74b3a1a7c03baaab48a3fb678d1800133846 100644 (file)
@@ -61,11 +61,12 @@ import java.util.Properties;
  */
 public class BatchMediumTester {
 
+  public static final String MEDIUM_TEST_ENABLED = "sonar.mediumTest.enabled";
   private Batch batch;
 
   public static BatchMediumTesterBuilder builder() {
     BatchMediumTesterBuilder builder = new BatchMediumTesterBuilder().registerCoreMetrics();
-    builder.bootstrapProperties.put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_MEDIUM_TEST);
+    builder.bootstrapProperties.put(MEDIUM_TEST_ENABLED, "true");
     builder.bootstrapProperties.put(CoreProperties.WORKING_DIRECTORY, Files.createTempDir().getAbsolutePath());
     return builder;
   }
@@ -114,6 +115,11 @@ public class BatchMediumTester {
       return this;
     }
 
+    public BatchMediumTesterBuilder setPreviousAnalysisDate(Date previousAnalysis) {
+      projectRefProvider.ref.setLastAnalysisDate(previousAnalysis);
+      return this;
+    }
+
     public BatchMediumTesterBuilder bootstrapProperties(Map<String, String> props) {
       bootstrapProperties.putAll(props);
       return this;
index 0e135f8c3731886f557febf4ec56ead21312aa18..a8e03ed8a4c75846ca24c6b9a57dc1ae0944b921 100644 (file)
@@ -77,7 +77,10 @@ public class IssuesPublisher implements ReportPublisher {
     if (line != null) {
       builder.setLine(line);
     }
-    builder.setMsg(issue.message());
+    String message = issue.message();
+    if (message != null) {
+      builder.setMsg(message);
+    }
     if (issue.effortToFix() != null) {
       builder.setEffortToFix(issue.effortToFix());
     }
index 8a0f242a9a39b510f159be0f26a4f0c4bc35b608..122ca40a5eb0eef2b3943a5f77d1d8ba2ac19326 100644 (file)
@@ -139,7 +139,7 @@ public class FileMetadata implements BatchComponent {
 
   private static class FileHashComputer extends CharHandler {
     private MessageDigest globalMd5Digest = DigestUtils.getMd5Digest();
-    private StringBuffer sb = new StringBuffer();
+    private StringBuilder sb = new StringBuilder();
 
     @Override
     void handleIgnoreEoL(char c) {
index 130e8c10c63f4f3c16da27d81e45124a4318609c..f6fb5f2d42382d42df7d793b7c36c52d414f1870 100644 (file)
@@ -35,7 +35,6 @@ import org.sonar.api.batch.sensor.issue.internal.DefaultIssue;
 import org.sonar.api.batch.sensor.measure.NewMeasure;
 import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
 import org.sonar.api.config.Settings;
-import org.sonar.batch.index.ComponentDataCache;
 
 import java.io.Serializable;
 
@@ -44,17 +43,14 @@ public class DefaultSensorContext implements SensorContext {
   private final Settings settings;
   private final FileSystem fs;
   private final ActiveRules activeRules;
-  private final ComponentDataCache componentDataCache;
   private final SensorStorage sensorStorage;
   private final AnalysisMode analysisMode;
 
-  public DefaultSensorContext(Settings settings, FileSystem fs, ActiveRules activeRules, AnalysisMode analysisMode, ComponentDataCache componentDataCache,
-    SensorStorage sensorStorage) {
+  public DefaultSensorContext(Settings settings, FileSystem fs, ActiveRules activeRules, AnalysisMode analysisMode, SensorStorage sensorStorage) {
     this.settings = settings;
     this.fs = fs;
     this.activeRules = activeRules;
     this.analysisMode = analysisMode;
-    this.componentDataCache = componentDataCache;
     this.sensorStorage = sensorStorage;
   }
 
index fc33c337b525676d62212cd957be43f61fb6546b..fb7b92dc0382170ea4177b569f7a732edb02222a 100644 (file)
@@ -78,7 +78,7 @@ public class DefaultSymbolTableBuilder {
     @Override
     public int compare(Integer left, Integer right) {
       int result;
-      if (left != null & right != null) {
+      if (left != null && right != null) {
         result = left - right;
       } else {
         result = left == null ? -1 : 1;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java
new file mode 100644 (file)
index 0000000..6cb9e22
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.mediumtest.preview;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.issue.Issue;
+import org.sonar.batch.mediumtest.BatchMediumTester;
+import org.sonar.batch.mediumtest.TaskResult;
+import org.sonar.batch.protocol.input.ActiveRule;
+import org.sonar.batch.protocol.input.issues.PreviousIssue;
+import org.sonar.xoo.XooPlugin;
+
+import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PreviewAndReportsMediumTest {
+
+  @org.junit.Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+
+  private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+
+  private static Date date(String date) {
+    try {
+      return sdf.parse(date);
+    } catch (ParseException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  public BatchMediumTester tester = BatchMediumTester.builder()
+    .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW))
+    .registerPlugin("xoo", new XooPlugin())
+    .addDefaultQProfile("xoo", "Sonar Way")
+    .activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo"))
+    .activateRule(new ActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null))
+    .setPreviousAnalysisDate(new Date())
+    // Existing issue
+    .addPreviousIssue(new PreviousIssue().setKey("xyz")
+      .setComponentKey("sample:xources/hello/HelloJava.xoo")
+      .setRuleKey("xoo", "OneIssuePerLine")
+      .setLine(1)
+      .setSeverity("MAJOR")
+      .setCreationDate(date("14/03/2004"))
+      .setChecksum(DigestUtils.md5Hex("packagehello;"))
+      .setStatus("OPEN"))
+    // Resolved issue
+    .addPreviousIssue(new PreviousIssue().setKey("resolved")
+      .setComponentKey("sample:xources/hello/HelloJava.xoo")
+      .setRuleKey("xoo", "OneIssuePerLine")
+      .setLine(1)
+      .setSeverity("MAJOR")
+      .setCreationDate(date("14/03/2004"))
+      .setChecksum(DigestUtils.md5Hex("dontexist"))
+      .setStatus("OPEN"))
+    // Manual issue
+    .addPreviousIssue(new PreviousIssue().setKey("manual")
+      .setComponentKey("sample:xources/hello/HelloJava.xoo")
+      .setRuleKey("manual", "MyManualIssue")
+      .setLine(1)
+      .setSeverity("MAJOR")
+      .setCreationDate(date("14/03/2004"))
+      .setChecksum(DigestUtils.md5Hex("packagehello;"))
+      .setStatus("OPEN"))
+    .build();
+
+  @Before
+  public void prepare() {
+    tester.start();
+  }
+
+  @After
+  public void stop() {
+    tester.stop();
+  }
+
+  @Test
+  public void testIssueTracking() throws Exception {
+    File projectDir = new File(PreviewAndReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
+
+    TaskResult result = tester
+      .newScanTask(new File(projectDir, "sonar-project.properties"))
+      .start();
+
+    int newIssues = 0;
+    int openIssues = 0;
+    int resolvedIssue = 0;
+    for (Issue issue : result.issues()) {
+      if (issue.isNew()) {
+        newIssues++;
+      } else if (issue.resolution() != null) {
+        resolvedIssue++;
+      } else {
+        openIssues++;
+      }
+    }
+    assertThat(newIssues).isEqualTo(13);
+    assertThat(openIssues).isEqualTo(2);
+    assertThat(resolvedIssue).isEqualTo(1);
+  }
+
+  @Test
+  public void testConsoleReport() throws Exception {
+    File projectDir = new File(PreviewAndReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
+
+    TaskResult result = tester
+      .newScanTask(new File(projectDir, "sonar-project.properties"))
+      .property("sonar.issuesReport.console.enable", "true")
+      .start();
+
+    // TODO wait for ability to assert on logs
+  }
+
+  @Test
+  public void testHtmlReport() throws Exception {
+    File projectDir = new File(PreviewAndReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
+
+    TaskResult result = tester
+      .newScanTask(new File(projectDir, "sonar-project.properties"))
+      .property("sonar.issuesReport.html.enable", "true")
+      .start();
+
+    assertThat(new File(projectDir, ".sonar/issues-report/issues-report.html")).exists();
+    assertThat(new File(projectDir, ".sonar/issues-report/issues-report-light.html")).exists();
+  }
+
+}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/ReportsMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/ReportsMediumTest.java
deleted file mode 100644 (file)
index d350043..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.mediumtest.preview;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.CoreProperties;
-import org.sonar.batch.mediumtest.BatchMediumTester;
-import org.sonar.batch.mediumtest.TaskResult;
-import org.sonar.batch.protocol.input.ActiveRule;
-import org.sonar.batch.protocol.input.issues.PreviousIssue;
-import org.sonar.xoo.XooPlugin;
-
-import java.io.File;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class ReportsMediumTest {
-
-  @org.junit.Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
-
-  private static Date date(String date) {
-    try {
-      return sdf.parse(date);
-    } catch (ParseException e) {
-      throw new IllegalStateException(e);
-    }
-  }
-
-  public BatchMediumTester tester = BatchMediumTester.builder()
-    .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW))
-    .registerPlugin("xoo", new XooPlugin())
-    .addDefaultQProfile("xoo", "Sonar Way")
-    .activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", "OneIssuePerLine.internal", "xoo"))
-    // Existing issue
-    .addPreviousIssue(new PreviousIssue().setKey("xyz")
-      .setComponentKey("sample:xources/hello/HelloJava.xoo")
-      .setRuleKey("xoo", "OneIssuePerLine")
-      .setLine(1)
-      .setSeverity("MAJOR")
-      .setCreationDate(date("14/03/2004"))
-      .setChecksum(DigestUtils.md5Hex("packagehello;"))
-      .setStatus("OPEN"))
-    // Resolved issue
-    .addPreviousIssue(new PreviousIssue().setKey("resolved")
-      .setComponentKey("sample:xources/hello/HelloJava.xoo")
-      .setRuleKey("xoo", "OneIssuePerLine")
-      .setLine(1)
-      .setSeverity("MAJOR")
-      .setCreationDate(date("14/03/2004"))
-      .setChecksum(DigestUtils.md5Hex("dontexist"))
-      .setStatus("OPEN"))
-    .build();
-
-  @Before
-  public void prepare() {
-    tester.start();
-  }
-
-  @After
-  public void stop() {
-    tester.stop();
-  }
-
-  @Test
-  public void testConsoleReport() throws Exception {
-    File projectDir = new File(ReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
-
-    TaskResult result = tester
-      .newScanTask(new File(projectDir, "sonar-project.properties"))
-      .property("sonar.issuesReport.console.enable", "true")
-      .start();
-
-  }
-
-  @Test
-  public void testHtmlReport() throws Exception {
-    File projectDir = new File(ReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
-
-    TaskResult result = tester
-      .newScanTask(new File(projectDir, "sonar-project.properties"))
-      .property("sonar.issuesReport.html.enable", "true")
-      .start();
-
-  }
-
-}
index b5d443aa3033e476a45f9bdb8fe2fffc1bd3f81d..488cab9f8bd02a837fd76910eba6245eb13109f8 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch.sensor;
 
-import org.sonar.api.batch.sensor.internal.SensorStorage;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -31,9 +29,10 @@ import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.measure.MetricFinder;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
 import org.sonar.api.config.Settings;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.batch.index.ComponentDataCache;
+
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -61,10 +60,9 @@ public class DefaultSensorContextTest {
     when(metricFinder.findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
     when(metricFinder.findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
     settings = new Settings();
-    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
     sensorStorage = mock(SensorStorage.class);
     analysisMode = mock(AnalysisMode.class);
-    adaptor = new DefaultSensorContext(settings, fs, activeRules, analysisMode, componentDataCache, sensorStorage);
+    adaptor = new DefaultSensorContext(settings, fs, activeRules, analysisMode, sensorStorage);
   }
 
   @Test
index 296468c6ea640fe3c1b1ee497993437dd52ea2c3..1df01833ae5974d9b942b97362292939a3da21d4 100644 (file)
@@ -442,11 +442,6 @@ public interface CoreProperties {
    */
   String ANALYSIS_MODE_INCREMENTAL = "incremental";
 
-  /**
-   * @since 5.1
-   */
-  String ANALYSIS_MODE_MEDIUM_TEST = "mediumtest";
-
   /**
    * @since 4.0
    */
index 77da586cc5a25611f99c61e8c8f0cc27e8888091..a9eb25628783a4520a709b497106355105d7564e 100644 (file)
@@ -107,11 +107,13 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   <G extends Serializable> Measure<G> getMeasure(Metric<G> metric);
 
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   <M> M getMeasures(MeasuresFilter<M> filter);
 
   /**
@@ -129,6 +131,7 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   <G extends Serializable> Measure<G> getMeasure(Resource resource, Metric<G> metric);
 
   /**
@@ -143,6 +146,7 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
 
   /**
@@ -196,16 +200,19 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   Set<Dependency> getDependencies();
 
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   Collection<Dependency> getIncomingDependencies(Resource to);
 
   /**
    * @deprecated since 5.1 Sensors should not read but only save data
    */
+  @Deprecated
   Collection<Dependency> getOutgoingDependencies(Resource from);
 
   // ----------- FILE SOURCES --------------
index ef1b62e9d1465d467913fe1746c13fe1ae14f913..719dd2f8aaca7c684ea38df0bd62e6b5382244c5 100644 (file)
@@ -178,8 +178,9 @@ public class DefaultFileSystem implements FileSystem {
     }
     inputFile.setModuleBaseDir(this.baseDir);
     cache.add(inputFile);
-    if (inputFile.language() != null) {
-      languages.add(inputFile.language());
+    String language = inputFile.language();
+    if (language != null) {
+      languages.add(language);
     }
     return this;
   }
index 834c6e9c8107ad3d65e0171e0566e0eca5960aaa..88db382750f1cd51633e99a0fd5373e66ca26fee 100644 (file)
@@ -23,13 +23,12 @@ import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.utils.PathUtils;
 
 import java.io.File;
-import java.io.Serializable;
 import java.nio.file.Path;
 
 /**
  * @since 4.5
  */
-public class DefaultInputDir implements InputDir, Serializable {
+public class DefaultInputDir implements InputDir {
 
   private final String relativePath;
   private final String moduleKey;
index c639559c60ecf6ae329c2fba92d8bdfca0226080..69731c414929bc199b872cacc15f6312ac5d903a 100644 (file)
@@ -26,14 +26,13 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 import java.io.File;
-import java.io.Serializable;
 import java.nio.charset.Charset;
 import java.nio.file.Path;
 
 /**
  * @since 4.2
  */
-public class DefaultInputFile implements InputFile, Serializable {
+public class DefaultInputFile implements InputFile {
 
   private final String relativePath;
   private final String moduleKey;