From a4e409caa5f745b9895fe38a05f34ecf931af7d3 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 20 Feb 2015 16:34:31 +0100 Subject: [PATCH] Fix some quality flaws --- .../batch/bootstrap/DefaultAnalysisMode.java | 7 +- .../deprecated/DeprecatedSensorContext.java | 15 ++-- .../deprecated/decorator/package-info.java | 23 +++++++ .../duplication/FileBlocksValueCoder.java | 69 ------------------- .../batch/mediumtest/BatchMediumTester.java | 8 ++- .../sonar/batch/report/IssuesPublisher.java | 5 +- .../batch/scan/filesystem/FileMetadata.java | 2 +- .../batch/sensor/DefaultSensorContext.java | 6 +- .../symbol/DefaultSymbolTableBuilder.java | 2 +- ....java => PreviewAndReportsMediumTest.java} | 50 ++++++++++++-- .../sensor/DefaultSensorContextTest.java | 8 +-- .../java/org/sonar/api/CoreProperties.java | 5 -- .../org/sonar/api/batch/SensorContext.java | 7 ++ .../batch/fs/internal/DefaultFileSystem.java | 5 +- .../batch/fs/internal/DefaultInputDir.java | 3 +- .../batch/fs/internal/DefaultInputFile.java | 3 +- 16 files changed, 111 insertions(+), 107 deletions(-) create mode 100644 sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/package-info.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/duplication/FileBlocksValueCoder.java rename sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/{ReportsMediumTest.java => PreviewAndReportsMediumTest.java} (65%) diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultAnalysisMode.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultAnalysisMode.java index e97dce7da40..2b5e7bd5577 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultAnalysisMode.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultAnalysisMode.java @@ -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 diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java index c216e7ab29f..6558fa59c0b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java @@ -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 index 00000000000..4d537fe7f63 --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/package-info.java @@ -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 index 99b3467c921..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/duplication/FileBlocksValueCoder.java +++ /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 blocks = new ArrayList(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); - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java index dc060ce058b..5f5f74b3a1a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java +++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java @@ -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 props) { bootstrapProperties.putAll(props); return this; diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java index 0e135f8c373..a8e03ed8a4c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java @@ -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()); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileMetadata.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileMetadata.java index 8a0f242a9a3..122ca40a5eb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileMetadata.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileMetadata.java @@ -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) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java index 130e8c10c63..f6fb5f2d423 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java @@ -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; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/symbol/DefaultSymbolTableBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/symbol/DefaultSymbolTableBuilder.java index fc33c337b52..fb7b92dc038 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/symbol/DefaultSymbolTableBuilder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/symbol/DefaultSymbolTableBuilder.java @@ -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/ReportsMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java similarity index 65% rename from sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/ReportsMediumTest.java rename to sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java index d3500431180..6cb9e22fb00 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/ReportsMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java @@ -26,6 +26,7 @@ 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; @@ -37,7 +38,9 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -public class ReportsMediumTest { +import static org.assertj.core.api.Assertions.assertThat; + +public class PreviewAndReportsMediumTest { @org.junit.Rule public TemporaryFolder temp = new TemporaryFolder(); @@ -56,7 +59,9 @@ public class ReportsMediumTest { .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")) + .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") @@ -75,6 +80,15 @@ public class ReportsMediumTest { .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 @@ -87,26 +101,54 @@ public class ReportsMediumTest { 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(ReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI()); + 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(ReportsMediumTest.class.getResource("/mediumtest/xoo/sample").toURI()); + 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/sensor/DefaultSensorContextTest.java b/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorContextTest.java index b5d443aa303..488cab9f8bd 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorContextTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorContextTest.java @@ -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 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index 296468c6ea6..1df01833ae5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -442,11 +442,6 @@ public interface CoreProperties { */ String ANALYSIS_MODE_INCREMENTAL = "incremental"; - /** - * @since 5.1 - */ - String ANALYSIS_MODE_MEDIUM_TEST = "mediumtest"; - /** * @since 4.0 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java index 77da586cc5a..a9eb2562878 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java @@ -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 Measure getMeasure(Metric metric); /** * @deprecated since 5.1 Sensors should not read but only save data */ + @Deprecated M getMeasures(MeasuresFilter 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 Measure getMeasure(Resource resource, Metric 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 getMeasures(Resource resource, MeasuresFilter 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 getDependencies(); /** * @deprecated since 5.1 Sensors should not read but only save data */ + @Deprecated Collection getIncomingDependencies(Resource to); /** * @deprecated since 5.1 Sensors should not read but only save data */ + @Deprecated Collection getOutgoingDependencies(Resource from); // ----------- FILE SOURCES -------------- diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java index ef1b62e9d14..719dd2f8aac 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java @@ -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; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java index 834c6e9c810..88db382750f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java @@ -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; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java index c639559c60e..69731c41492 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java @@ -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; -- 2.39.5