From 51db1a41ea40cf2d07f4cebaf2feef12d80c2a34 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 19 Feb 2015 22:34:14 +0100 Subject: [PATCH] SONAR-5931 Cleanup new issue API --- .../sonar/xoo/lang/DependencySensorTest.java | 3 +- .../org/sonar/xoo/lang/MeasureSensorTest.java | 3 +- .../xoo/rule/OneIssuePerLineSensorTest.java | 3 +- .../deprecated/DeprecatedSensorContext.java | 3 +- .../batch/sensor/DefaultSensorContext.java | 6 +- .../batch/sensor/DefaultSensorStorage.java | 3 +- .../sonar/batch/cpd/JavaCpdEngineTest.java | 3 +- .../sensor/DefaultSensorContextTest.java | 4 +- .../sonar/api/batch/sensor/SensorContext.java | 5 +- .../internal/DefaultDependency.java | 3 +- .../internal/DefaultDuplication.java | 3 +- .../sensor/internal/DefaultStorable.java | 1 - .../sensor/{ => internal}/SensorStorage.java | 2 +- .../sonar/api/batch/sensor/issue/Issue.java | 55 +----------- .../api/batch/sensor/issue/NewIssue.java | 85 +++++++++++++++++++ .../sensor/issue/internal/DefaultIssue.java | 8 +- .../measure/internal/DefaultMeasure.java | 3 +- .../issue/internal/DefaultIssueTest.java | 4 +- .../measure/internal/DefaultMeasureTest.java | 4 +- 19 files changed, 122 insertions(+), 79 deletions(-) rename sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/{ => internal}/SensorStorage.java (96%) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java index e586263feda..73b63909ebc 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.xoo.lang; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; @@ -30,7 +32,6 @@ import org.sonar.api.batch.fs.InputFile.Type; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.dependency.Dependency; import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java index 6626a5e9545..92169bdf42b 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.xoo.lang; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; @@ -31,7 +33,6 @@ import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; import org.sonar.api.measures.CoreMetrics; diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java index 9f1a4436a0e..ab8ea247d35 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.xoo.rule; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -28,7 +30,6 @@ import org.mockito.stubbing.Answer; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.sensor.issue.Issue.Severity; 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 a8d96036863..c216e7ab29f 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,6 +19,8 @@ */ 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; @@ -31,7 +33,6 @@ 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.SensorStorage; import org.sonar.api.config.Settings; import org.sonar.api.design.Dependency; import org.sonar.api.measures.Measure; 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 667552ae840..e010b83fca2 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 @@ -25,13 +25,13 @@ import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.dependency.NewDependency; import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency; import org.sonar.api.batch.sensor.duplication.NewDuplication; import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication; import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder; -import org.sonar.api.batch.sensor.issue.Issue; +import org.sonar.api.batch.sensor.internal.SensorStorage; +import org.sonar.api.batch.sensor.issue.NewIssue; 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; @@ -88,7 +88,7 @@ public class DefaultSensorContext implements SensorContext { } @Override - public Issue newIssue() { + public NewIssue newIssue() { return new DefaultIssue(sensorStorage); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java index 1624e10d7b2..170fd671daf 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java +++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.sensor; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import com.google.common.base.Preconditions; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputDir; @@ -26,7 +28,6 @@ import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.InputPath; import org.sonar.api.batch.measure.MetricFinder; import org.sonar.api.batch.rule.ActiveRules; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.duplication.Duplication; import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication; import org.sonar.api.batch.sensor.issue.Issue; diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java index 2de7d5952cf..e4e4d3e0366 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.cpd; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -27,7 +29,6 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.duplication.NewDuplication; import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication; import org.sonar.api.batch.sensor.measure.Measure; 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 19b12f7b972..b5d443aa303 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,6 +19,8 @@ */ 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; @@ -29,11 +31,9 @@ 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.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; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java index 336a7eef61a..bd15a900398 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java @@ -28,6 +28,7 @@ import org.sonar.api.batch.sensor.dependency.NewDependency; import org.sonar.api.batch.sensor.duplication.NewDuplication; import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder; import org.sonar.api.batch.sensor.issue.Issue; +import org.sonar.api.batch.sensor.issue.NewIssue; import org.sonar.api.batch.sensor.measure.Measure; import org.sonar.api.batch.sensor.measure.NewMeasure; import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder; @@ -71,9 +72,9 @@ public interface SensorContext { // ----------- ISSUES -------------- /** - * Fluent builder to create a new {@link Issue}. Don't forget to call {@link Issue#save()} once all parameters are provided. + * Fluent builder to create a new {@link Issue}. Don't forget to call {@link NewIssue#save()} once all parameters are provided. */ - Issue newIssue(); + NewIssue newIssue(); // ------------ HIGHLIGHTING ------------ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/dependency/internal/DefaultDependency.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/dependency/internal/DefaultDependency.java index 9dcb3d34ece..56161c29646 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/dependency/internal/DefaultDependency.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/dependency/internal/DefaultDependency.java @@ -19,12 +19,13 @@ */ package org.sonar.api.batch.sensor.dependency.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import com.google.common.base.Preconditions; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.dependency.Dependency; import org.sonar.api.batch.sensor.dependency.NewDependency; import org.sonar.api.batch.sensor.internal.DefaultStorable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java index 496f3cd9332..d9836036646 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java @@ -19,6 +19,8 @@ */ package org.sonar.api.batch.sensor.duplication.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import com.google.common.base.Preconditions; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -26,7 +28,6 @@ import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.duplication.Duplication; import org.sonar.api.batch.sensor.duplication.NewDuplication; import org.sonar.api.batch.sensor.internal.DefaultStorable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java index e3b7f919f2c..31f16142b57 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java @@ -23,7 +23,6 @@ import com.google.common.base.Preconditions; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.sensor.SensorStorage; import javax.annotation.Nullable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorStorage.java similarity index 96% rename from sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java rename to sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorStorage.java index 7ee6b308936..69b79f7addf 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorStorage.java @@ -17,7 +17,7 @@ * 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.api.batch.sensor; +package org.sonar.api.batch.sensor.internal; import org.sonar.api.batch.sensor.dependency.Dependency; import org.sonar.api.batch.sensor.duplication.Duplication; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java index e126ddef95b..d320bd2c11f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java @@ -19,22 +19,17 @@ */ package org.sonar.api.batch.sensor.issue; -import com.google.common.annotations.Beta; -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.sensor.Sensor; import org.sonar.api.rule.RuleKey; import javax.annotation.CheckForNull; -import javax.annotation.Nullable; /** * Represents an issue detected by a {@link Sensor}. * - * @since 5.0 + * @since 5.1 */ -@Beta public interface Issue { public enum Severity { @@ -45,43 +40,17 @@ public interface Issue { BLOCKER; } - /** - * The {@link RuleKey} of the issue. - */ - Issue ruleKey(RuleKey ruleKey); - /** * The {@link RuleKey} of this issue. */ RuleKey ruleKey(); - /** - * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}. - */ - Issue onFile(InputFile file); - - /** - * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}. - */ - Issue onDir(InputDir inputDir); - - /** - * Tell that the issue is global to the project. - */ - Issue onProject(); - /** * The {@link InputPath} this issue belongs to. Returns null if issue is global to the project. */ @CheckForNull InputPath inputPath(); - /** - * Line of the issue. Only available for {@link #onFile(InputFile)} issues. - * If no line is specified it means that issue is global to the file. - */ - Issue atLine(int line); - /** * Line of the issue. Null for global issues and issues on directories. Can also be null * for files (issue global to the file). @@ -89,44 +58,22 @@ public interface Issue { @CheckForNull Integer line(); - /** - * Effort to fix the issue. - */ - Issue effortToFix(@Nullable Double effortToFix); - /** * Effort to fix the issue. Used by technical debt model. */ @CheckForNull Double effortToFix(); - /** - * Message of the issue. - */ - Issue message(String message); - /** * Message of the issue. */ @CheckForNull String message(); - /** - * Override severity of the issue. - * Setting a null value or not calling this method means to use severity configured in quality profile. - */ - Issue overrideSeverity(@Nullable Severity severity); - /** * Overriden severity. */ @CheckForNull Severity overridenSeverity(); - /** - * Save the issue. If rule key is unknow or rule not enabled in the current quality profile then a warning is logged but no exception - * is thrown. - */ - void save(); - } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java new file mode 100644 index 00000000000..8819fc23b25 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java @@ -0,0 +1,85 @@ +/* + * 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.api.batch.sensor.issue; + +import org.sonar.api.batch.fs.InputDir; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.sensor.Sensor; +import org.sonar.api.batch.sensor.issue.Issue.Severity; +import org.sonar.api.rule.RuleKey; + +import javax.annotation.Nullable; + +/** + * Represents an issue detected by a {@link Sensor}. + * + * @since 5.1 + */ +public interface NewIssue { + + /** + * The {@link RuleKey} of the issue. + */ + NewIssue ruleKey(RuleKey ruleKey); + + /** + * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}. + */ + NewIssue onFile(InputFile file); + + /** + * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}. + */ + NewIssue onDir(InputDir inputDir); + + /** + * Tell that the issue is global to the project. + */ + NewIssue onProject(); + + /** + * Line of the issue. Only available for {@link #onFile(InputFile)} issues. + * If no line is specified it means that issue is global to the file. + */ + NewIssue atLine(int line); + + /** + * Effort to fix the issue. + */ + NewIssue effortToFix(@Nullable Double effortToFix); + + /** + * Message of the issue. + */ + NewIssue message(String message); + + /** + * Override severity of the issue. + * Setting a null value or not calling this method means to use severity configured in quality profile. + */ + NewIssue overrideSeverity(@Nullable Severity severity); + + /** + * 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. + */ + void save(); + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java index df4779a4894..c029722eb9d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java @@ -19,21 +19,23 @@ */ package org.sonar.api.batch.sensor.issue.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import com.google.common.base.Preconditions; import com.google.common.base.Strings; 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.sensor.SensorStorage; import org.sonar.api.batch.sensor.internal.DefaultStorable; import org.sonar.api.batch.sensor.issue.Issue; +import org.sonar.api.batch.sensor.issue.NewIssue; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.internal.Uuids; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class DefaultIssue extends DefaultStorable implements Issue { +public class DefaultIssue extends DefaultStorable implements Issue, NewIssue { private static final String INPUT_DIR_SHOULD_BE_NON_NULL = "InputDir should be non null"; private static final String INPUT_FILE_SHOULD_BE_NON_NULL = "InputFile should be non null"; @@ -110,7 +112,7 @@ public class DefaultIssue extends DefaultStorable implements Issue { } @Override - public Issue overrideSeverity(@Nullable Severity severity) { + public DefaultIssue overrideSeverity(@Nullable Severity severity) { this.overridenSeverity = severity; return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java index a6e4a0021fa..e798ce64fde 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java @@ -19,12 +19,13 @@ */ package org.sonar.api.batch.sensor.measure.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import com.google.common.base.Preconditions; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.measure.Metric; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.batch.sensor.internal.DefaultStorable; import org.sonar.api.batch.sensor.measure.Measure; import org.sonar.api.batch.sensor.measure.NewMeasure; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java index 5580f881f1a..8973939afe3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java @@ -19,13 +19,13 @@ */ package org.sonar.api.batch.sensor.issue.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.rule.RuleKey; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasureTest.java index a4e5c4afb8e..6dae7fc2dbf 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasureTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasureTest.java @@ -19,13 +19,13 @@ */ package org.sonar.api.batch.sensor.measure.internal; +import org.sonar.api.batch.sensor.internal.SensorStorage; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorStorage; import org.sonar.api.measures.CoreMetrics; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -- 2.39.5