From f785c62ff8259184c889eacea78c5dc25cb9e1a3 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 10 May 2016 18:12:35 +0200 Subject: [PATCH] SONAR-7612 Move new Sensor API out of @Beta --- .../sonar/xoo/extensions/XooPostJobTest.java | 6 ++-- .../sonar/api/batch/AbstractCpdMapping.java | 5 +-- .../org/sonar/api/batch/BuildBreaker.java | 2 ++ .../org/sonar/api/batch/CheckProject.java | 2 ++ .../java/org/sonar/api/batch/CpdMapping.java | 2 +- .../sonar/api/batch/DecoratorBarriers.java | 3 +- .../org/sonar/api/batch/DecoratorContext.java | 2 ++ .../java/org/sonar/api/batch/Initializer.java | 4 --- .../java/org/sonar/api/batch/PostJob.java | 2 ++ .../main/java/org/sonar/api/batch/Sensor.java | 2 ++ .../org/sonar/api/batch/SensorContext.java | 2 ++ .../java/org/sonar/api/batch/SonarIndex.java | 1 + .../org/sonar/api/batch/postjob/PostJob.java | 10 +++--- .../api/batch/postjob/PostJobContext.java | 16 +++------ .../api/batch/postjob/PostJobDescriptor.java | 8 ----- .../internal/DefaultPostJobDescriptor.java | 14 +------- .../issue/{Issue.java => PostJobIssue.java} | 16 +++------ .../org/sonar/api/batch/sensor/Sensor.java | 6 ---- .../sonar/api/batch/sensor/SensorContext.java | 2 -- .../api/batch/sensor/SensorDescriptor.java | 2 -- .../batch/sensor/coverage/CoverageType.java | 2 -- .../batch/sensor/coverage/NewCoverage.java | 2 -- .../api/batch/sensor/cpd/NewCpdTokens.java | 2 -- .../sensor/highlighting/NewHighlighting.java | 2 -- .../batch/sensor/highlighting/TypeOfText.java | 3 -- .../sonar/api/batch/sensor/issue/Issue.java | 2 -- .../api/batch/sensor/issue/IssueLocation.java | 2 -- .../api/batch/sensor/issue/NewIssue.java | 2 -- .../batch/sensor/issue/NewIssueLocation.java | 2 -- .../api/batch/sensor/measure/Measure.java | 2 -- .../api/batch/sensor/measure/NewMeasure.java | 2 -- .../api/batch/sensor/symbol/NewSymbol.java | 2 -- .../batch/sensor/symbol/NewSymbolTable.java | 2 -- .../java/org/sonar/api/component/Module.java | 4 +++ .../api/component/ResourcePerspectives.java | 33 ++----------------- .../api/component/RubyComponentService.java | 5 +-- .../org/sonar/api/component/SourceFile.java | 4 +++ .../api/component/mock/MockSourceFile.java | 4 +++ .../org/sonar/api/source/Highlightable.java | 3 ++ .../java/org/sonar/api/source/Symbol.java | 6 ++++ .../org/sonar/api/source/Symbolizable.java | 3 ++ .../java/org/sonar/api/utils/StaxParser.java | 6 ++-- .../sonar/api/utils/XmlParserException.java | 2 ++ .../java/org/sonar/api/utils/XpathParser.java | 2 ++ .../batch/postjob/DefaultPostJobContext.java | 32 +++++------------- .../sonar/batch/postjob/PostJobOptimizer.java | 9 +---- .../postjob/DefaultPostJobContextTest.java | 16 +++------ .../batch/postjob/PostJobOptimizerTest.java | 18 +--------- 48 files changed, 88 insertions(+), 193 deletions(-) rename sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/{Issue.java => PostJobIssue.java} (83%) diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java index 82112ac2709..66b9c5e227f 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java @@ -23,7 +23,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.batch.postjob.PostJobContext; import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; -import org.sonar.api.batch.postjob.issue.Issue; +import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.utils.log.LogTester; import java.util.Arrays; @@ -41,8 +41,8 @@ public class XooPostJobTest { public void increaseCoverage() { new XooPostJob().describe(new DefaultPostJobDescriptor()); PostJobContext context = mock(PostJobContext.class); - when(context.issues()).thenReturn(Arrays.asList()); - when(context.resolvedIssues()).thenReturn(Arrays.asList()); + when(context.issues()).thenReturn(Arrays.asList()); + when(context.resolvedIssues()).thenReturn(Arrays.asList()); new XooPostJob().execute(context); assertThat(logTester.logs()).contains("Resolved issues: 0", "Open issues: 0"); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCpdMapping.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCpdMapping.java index 248aeee5479..d644d00d5e3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCpdMapping.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCpdMapping.java @@ -19,15 +19,16 @@ */ package org.sonar.api.batch; -import org.sonar.api.resources.Resource; - import java.util.List; +import org.sonar.api.resources.Resource; /** * A pre-implementation of the CpdMapping extension point * * @since 1.10 + * @deprecated since 5.6 */ +@Deprecated public abstract class AbstractCpdMapping implements CpdMapping { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BuildBreaker.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BuildBreaker.java index bc989e83ce4..c8296c7f3b7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BuildBreaker.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BuildBreaker.java @@ -23,7 +23,9 @@ import org.sonar.api.utils.SonarException; /** * @since 1.10 + * @deprecated since 5.6 */ +@Deprecated @Phase(name = Phase.Name.POST) public abstract class BuildBreaker implements PostJob { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CheckProject.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CheckProject.java index 37e39a0555c..b3d12907e47 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CheckProject.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CheckProject.java @@ -23,7 +23,9 @@ import org.sonar.api.resources.Project; /** * @since 1.10 + * @deprecated since 5.6 */ +@Deprecated public interface CheckProject { boolean shouldExecuteOnProject(Project project); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java index 33fca518ee9..a39c405dcec 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java @@ -29,7 +29,7 @@ import org.sonar.api.resources.Resource; /** * Implement this extension to get Copy/Paste detection for your language. * @since 1.10 - * @deprecated since 5.5 + * @deprecated since 5.5 use {@link SensorContext#newCpdTokens()} */ @BatchSide @ExtensionPoint diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java index d6f3f10f26e..e05bbb2a9db 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java @@ -28,7 +28,9 @@ package org.sonar.api.batch; * * * @since 2.3 + * @deprecated since 5.6 no more used since Decorators are deprecated */ +@Deprecated public interface DecoratorBarriers { /** @@ -47,7 +49,6 @@ public interface DecoratorBarriers { */ String ISSUES_TRACKED = "END_OF_VIOLATION_TRACKING"; - /** * @deprecated in 3.6. Not required anymore. */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java index 351f217a329..2da3f35e3ba 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java @@ -30,7 +30,9 @@ import org.sonar.api.resources.Resource; /** * @since 1.10 + * @deprecated since 5.6 no more used since Decorator is deprecated */ +@Deprecated public interface DecoratorContext { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Initializer.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Initializer.java index a9bfa828390..66e2f9f27db 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Initializer.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Initializer.java @@ -26,12 +26,8 @@ import org.sonar.api.resources.Project; *

* Initializer can execute external tool (like a Maven plugin), change project configuration. For example CoberturaMavenInitializer invokes * the Codehaus Cobertura Mojo and sets path to Cobertura report according to Maven POM. - * - * *

* Initializers are executed first and once during project analysis. - * - * * @since 2.6 */ @BatchSide diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/PostJob.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/PostJob.java index 6ba8298c70e..5605a34c305 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/PostJob.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/PostJob.java @@ -29,7 +29,9 @@ import org.sonar.api.resources.Project; * it is an asynchronous processing on server side. * * @since 1.10 + * @deprecated since 5.6 use {@link org.sonar.api.batch.postjob.PostJob} */ +@Deprecated @BatchSide @ExtensionPoint public interface PostJob { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Sensor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Sensor.java index 72cb369f3d3..ebe26fdb6d9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Sensor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Sensor.java @@ -40,7 +40,9 @@ import org.sonar.api.resources.Project; * * * @since 1.10 + * @deprecated since 5.6 use {@link org.sonar.api.batch.sensor.Sensor} */ +@Deprecated @BatchSide @ExtensionPoint public interface Sensor extends CheckProject { 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 d9573c82deb..b9775f0fcd8 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 @@ -32,7 +32,9 @@ import org.sonar.api.resources.Resource; /** * @since 1.10 + * @deprecated since 5.6 use {@link org.sonar.api.batch.sensor.Sensor} */ +@Deprecated public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java index cd3a9947013..404bc29ca1e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java @@ -22,6 +22,7 @@ package org.sonar.api.batch; import java.util.Collection; import javax.annotation.CheckForNull; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.design.Dependency; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilter; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJob.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJob.java index 25a060733b1..58510ad3ea1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJob.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJob.java @@ -19,19 +19,17 @@ */ package org.sonar.api.batch.postjob; -import com.google.common.annotations.Beta; -import org.sonar.api.batch.BatchSide; import org.sonar.api.ExtensionPoint; +import org.sonar.api.batch.BatchSide; /** - * PostJobs are executed at the very end of batch analysis. A PostJob can't do any modification + * PostJobs are executed at the very end of scanner analysis. A PostJob can't do any modification * since everything is already computed (issues, measures,...).
- * WANRING: Do not rely on the fact that analysis results are available on server side using WS since this is an + * WARNING: Do not rely on the fact that analysis results are available on server side when using WS since this is an * asynchronous process to compute data on server side in 5.x series. * * @since 5.2 */ -@Beta @BatchSide @ExtensionPoint public interface PostJob { @@ -42,7 +40,7 @@ public interface PostJob { void describe(PostJobDescriptor descriptor); /** - * The actual sensor code. + * Called at the end of the analysis. */ void execute(PostJobContext context); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java index 43d0c7c9713..ed9706309bb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java @@ -19,16 +19,13 @@ */ package org.sonar.api.batch.postjob; -import com.google.common.annotations.Beta; -import org.sonar.api.batch.AnalysisMode; -import org.sonar.api.batch.postjob.issue.Issue; +import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.config.Settings; /** * See {@link PostJob#execute(PostJobContext)} * @since 5.2 */ -@Beta public interface PostJobContext { /** @@ -36,21 +33,16 @@ public interface PostJobContext { */ Settings settings(); - /** - * Get analysis mode. - */ - AnalysisMode analysisMode(); - - // ----------- ISSUES -------------- + // ----------- Only available in preview mode -------------- /** * All the unresolved issues of the project, including the issues reported by end-users. */ - Iterable issues(); + Iterable issues(); /** * All the issues of this project that have been marked as resolved during this scan */ - Iterable resolvedIssues(); + Iterable resolvedIssues(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobDescriptor.java index 081b0d2779f..7e7a1693da5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobDescriptor.java @@ -19,15 +19,12 @@ */ package org.sonar.api.batch.postjob; -import com.google.common.annotations.Beta; - /** * Describe what a {@link PostJob} is doing. Information may be used by the platform * to log interesting information or perform some optimization. * See {@link PostJob#describe(PostJobDescriptor)} * @since 5.2 */ -@Beta public interface PostJobDescriptor { /** @@ -47,9 +44,4 @@ public interface PostJobDescriptor { */ PostJobDescriptor requireProperties(String... propertyKeys); - /** - * Should this PostJob be disabled in issues mode. Default is to run all PostJobs in preview mode. - */ - PostJobDescriptor disabledInIssues(); - } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/internal/DefaultPostJobDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/internal/DefaultPostJobDescriptor.java index 8cf5a578deb..ce277761e99 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/internal/DefaultPostJobDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/internal/DefaultPostJobDescriptor.java @@ -19,16 +19,14 @@ */ package org.sonar.api.batch.postjob.internal; -import org.sonar.api.batch.postjob.PostJobDescriptor; - import java.util.Arrays; import java.util.Collection; +import org.sonar.api.batch.postjob.PostJobDescriptor; public class DefaultPostJobDescriptor implements PostJobDescriptor { private String name; private String[] properties = new String[0]; - private boolean disabledInIssues = false; public String name() { return name; @@ -38,10 +36,6 @@ public class DefaultPostJobDescriptor implements PostJobDescriptor { return Arrays.asList(properties); } - public boolean isDisabledInIssues() { - return disabledInIssues; - } - @Override public DefaultPostJobDescriptor name(String name) { this.name = name; @@ -59,10 +53,4 @@ public class DefaultPostJobDescriptor implements PostJobDescriptor { return this; } - @Override - public DefaultPostJobDescriptor disabledInIssues() { - this.disabledInIssues = true; - return this; - } - } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/PostJobIssue.java similarity index 83% rename from sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/Issue.java rename to sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/PostJobIssue.java index ec514a5936b..553e12826a9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/Issue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/issue/PostJobIssue.java @@ -19,19 +19,17 @@ */ package org.sonar.api.batch.postjob.issue; -import com.google.common.annotations.Beta; import javax.annotation.CheckForNull; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.rule.Severity; import org.sonar.api.rule.RuleKey; /** - * Represents an issue state at the end of the batch analysis. Only available after local issue tracking in preview mode. + * Represents an issue state at the end of the batch analysis. Some attributes are only available in preview/issues mode. * * @since 5.2 */ -@Beta -public interface Issue { +public interface PostJobIssue { /** * Key of the issue. @@ -61,12 +59,6 @@ public interface Issue { @CheckForNull Integer line(); - /** - * Effort to fix the issue. Used by technical debt model. - */ - @CheckForNull - Double effortToFix(); - /** * Message of the issue. */ @@ -74,12 +66,12 @@ public interface Issue { String message(); /** - * Severity. + * Severity. Only accurate in preview/issues mode. */ Severity severity(); /** - * If the issue a new one. + * If the issue a new one. Only available in preview/issues mode. */ boolean isNew(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java index 1509e58fc5c..e4cc8e61744 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor; -import com.google.common.annotations.Beta; import org.sonar.api.ExtensionPoint; import org.sonar.api.batch.BatchSide; @@ -27,15 +26,10 @@ import org.sonar.api.batch.BatchSide; *

* A sensor is invoked once for each module of a project, starting from leaf modules. The sensor can parse a flat file, connect to a web server... Sensors are * used to add measure and issues at file level. - * - * *

* For example the Cobertura Sensor parses Cobertura report and saves the first-level of measures on files. - * - * * @since 5.1 */ -@Beta @BatchSide @ExtensionPoint public interface Sensor { 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 044f5f36c16..bb1aa0fd922 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 @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor; -import com.google.common.annotations.Beta; import java.io.Serializable; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputModule; @@ -41,7 +40,6 @@ import org.sonar.api.utils.Version; * In order to write unit tests you can use {@link SensorContextTester} * @since 5.1 */ -@Beta public interface SensorContext { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java index 9000a81432b..4f36c763964 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; /** @@ -28,7 +27,6 @@ import org.sonar.api.batch.fs.InputFile; * See {@link Sensor#describe(SensorDescriptor)} * @since 5.1 */ -@Beta public interface SensorDescriptor { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java index cdab75f44c4..cdde991667d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.coverage; -import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableSet; import java.util.Set; import org.sonar.api.measures.Metric; @@ -50,7 +49,6 @@ import static org.sonar.api.measures.CoreMetrics.UNCOVERED_LINES; * Different coverage categories. * @since 5.2 */ -@Beta public enum CoverageType { UNIT(LINES_TO_COVER, UNCOVERED_LINES, COVERAGE_LINE_HITS_DATA, CONDITIONS_TO_COVER, UNCOVERED_CONDITIONS, COVERED_CONDITIONS_BY_LINE, CONDITIONS_BY_LINE), diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/NewCoverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/NewCoverage.java index 2ef1be16a2a..c9e9024072a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/NewCoverage.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/NewCoverage.java @@ -19,14 +19,12 @@ */ package org.sonar.api.batch.sensor.coverage; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; /** * This builder is used to define code coverage by tests of a given type (UT/IT/Overall) on files. * @since 5.2 */ -@Beta public interface NewCoverage { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java index e2a48d1a724..1a2785ac8fb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.cpd; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; @@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; * This builder is used to define tokens used by CPD algorithm on files. * @since 5.5 */ -@Beta public interface NewCpdTokens { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/NewHighlighting.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/NewHighlighting.java index 6f59fad4bad..577aefd911e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/NewHighlighting.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/NewHighlighting.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.highlighting; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; @@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; * This builder is used to define syntax highlighting (aka code coloration) on files. * @since 5.1 */ -@Beta public interface NewHighlighting { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/TypeOfText.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/TypeOfText.java index 4065eff5789..559e44e61a6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/TypeOfText.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/TypeOfText.java @@ -19,15 +19,12 @@ */ package org.sonar.api.batch.sensor.highlighting; -import com.google.common.annotations.Beta; - /** * Experimental, do not use. *
* Possible types for highlighting code. See sonar-colorizer.css * @since 5.1 */ -@Beta public enum TypeOfText { ANNOTATION("a"), CONSTANT("c"), 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 1f275390788..fb7cfc87b40 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,7 +19,6 @@ */ package org.sonar.api.batch.sensor.issue; -import com.google.common.annotations.Beta; import java.util.List; import javax.annotation.CheckForNull; import org.sonar.api.batch.rule.Severity; @@ -31,7 +30,6 @@ import org.sonar.api.rule.RuleKey; * * @since 5.1 */ -@Beta public interface Issue { interface Flow { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/IssueLocation.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/IssueLocation.java index 37d32cbebf8..2dade89c658 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/IssueLocation.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/IssueLocation.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.issue; -import com.google.common.annotations.Beta; import javax.annotation.CheckForNull; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.fs.TextRange; @@ -29,7 +28,6 @@ import org.sonar.api.batch.fs.TextRange; * * @since 5.2 */ -@Beta public interface IssueLocation { /** 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 index 2dbf02b31d1..f428d8c6aa1 100644 --- 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 @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.issue; -import com.google.common.annotations.Beta; import javax.annotation.Nullable; import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.Sensor; @@ -30,7 +29,6 @@ import org.sonar.api.rule.RuleKey; * * @since 5.1 */ -@Beta public interface NewIssue { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssueLocation.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssueLocation.java index f4fe17f13ac..ea62885fbc0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssueLocation.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssueLocation.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.issue; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; @@ -29,7 +28,6 @@ import org.sonar.api.batch.fs.TextRange; * * @since 5.2 */ -@Beta public interface NewIssueLocation { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java index 40b479f4485..87b37b15e08 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/Measure.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.measure; -import com.google.common.annotations.Beta; import java.io.Serializable; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.measure.Metric; @@ -29,7 +28,6 @@ import org.sonar.api.batch.measure.Metric; * Should not be implemented by client. * @since 5.1 */ -@Beta public interface Measure { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java index fc3dc68201e..00b3a17a1be 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/NewMeasure.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.measure; -import com.google.common.annotations.Beta; import java.io.Serializable; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.measure.Metric; @@ -29,7 +28,6 @@ import org.sonar.api.batch.measure.Metric; * Should not be implemented by client. * @since 5.2 */ -@Beta public interface NewMeasure { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbol.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbol.java index 46368ed5ee1..06c2ba8529d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbol.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbol.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.symbol; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; @@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; * This builder is used to define symbol references on files. * @since 5.6 */ -@Beta public interface NewSymbol { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbolTable.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbolTable.java index 1e8487c557d..874261a6c6f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbolTable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/symbol/NewSymbolTable.java @@ -19,7 +19,6 @@ */ package org.sonar.api.batch.sensor.symbol; -import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; @@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; * This builder is used to define symbol references on files. * @since 5.6 */ -@Beta public interface NewSymbolTable { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/Module.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/Module.java index c2aeab148b1..3ab3f6d1776 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/Module.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/Module.java @@ -19,6 +19,10 @@ */ package org.sonar.api.component; +/** + * @deprecated since 5.6 + */ +@Deprecated public interface Module extends Component { String getDescription(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java index 76cb7cd3d04..858f5b9e7fd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java @@ -22,41 +22,14 @@ package org.sonar.api.component; import javax.annotation.CheckForNull; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.InputPath; -import org.sonar.api.issue.Issuable; +import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.resources.Resource; -import org.sonar.api.source.Highlightable; -import org.sonar.api.source.Symbolizable; -import org.sonar.api.test.TestPlan; -import org.sonar.api.test.Testable; /** - * Use this component to create perspective from resources or {@link InputPath} - * Only on batch-side. - * - *

- * public class MySensor implements Sensor {
- *   private final ResourcePerspectives perspectives;
- *
- *   public MySensor(ResourcePerspectives perspectives) {
- *     this.perspectives = perspectives;
- *   }
- *   
- *   public void analyse(Project module, SensorContext context) {
- *      // Get some Resource or InputFile/InputPath
- *      Highlightable highlightable = perspectives.as(Highlightable.class, inputPath);
- *      if (highlightable != null) {
- *        ...
- *      }
- *   }
- * }
- * 
- * @see Issuable - * @see Highlightable - * @see Symbolizable - * @see Testable - * @see TestPlan * @since 3.5 + * @deprecated since 5.6 all features are available on {@link SensorContext} */ +@Deprecated public interface ResourcePerspectives { @CheckForNull diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java index 901290d57b4..0f4f3e2ca5b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/RubyComponentService.java @@ -19,13 +19,14 @@ */ package org.sonar.api.component; -import org.sonar.api.server.ServerSide; - import javax.annotation.CheckForNull; +import org.sonar.api.server.ServerSide; /** * @since 3.6 + * @deprecated since 5.6 */ +@Deprecated @ServerSide public interface RubyComponentService { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/SourceFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/SourceFile.java index bfc25f1d786..76cb7f0883a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/SourceFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/SourceFile.java @@ -19,5 +19,9 @@ */ package org.sonar.api.component; +/** + * @deprecated since 5.6 + */ +@Deprecated public interface SourceFile extends Component { } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java index 8ee9b16a5d9..e169ddc6524 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java @@ -21,6 +21,10 @@ package org.sonar.api.component.mock; import org.sonar.api.component.SourceFile; +/** + * @deprecated since 5.6 + */ +@Deprecated public class MockSourceFile implements SourceFile { private String key; private String path; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java b/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java index 267fd082a8b..4230b2ccdee 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java @@ -19,6 +19,7 @@ */ package org.sonar.api.source; +import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.component.Perspective; import org.sonar.api.component.ResourcePerspectives; @@ -26,7 +27,9 @@ import org.sonar.api.component.ResourcePerspectives; * Use this perspective to save syntax highlighting on files. * See {@link ResourcePerspectives}. * @since 3.6 + * @deprecated since 5.6 use {@link SensorContext#newHighlighting()} */ +@Deprecated public interface Highlightable extends Perspective { interface HighlightingBuilder { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbol.java b/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbol.java index c639e022e0e..fac2b3e76f9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbol.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbol.java @@ -19,6 +19,12 @@ */ package org.sonar.api.source; +import org.sonar.api.batch.sensor.SensorContext; + +/** + * @deprecated since 5.6 use {@link SensorContext#newSymbolTable()} + */ +@Deprecated public interface Symbol { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbolizable.java b/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbolizable.java index 1e40f26a23c..98177598ef1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbolizable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/source/Symbolizable.java @@ -20,6 +20,7 @@ package org.sonar.api.source; import java.util.List; +import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.component.Perspective; import org.sonar.api.component.ResourcePerspectives; @@ -27,7 +28,9 @@ import org.sonar.api.component.ResourcePerspectives; * Use this perspective to save symbol references on files. * See {@link ResourcePerspectives}. * @since 3.6 + * @deprecated since 5.6 use {@link SensorContext#newSymbolTable()} */ +@Deprecated public interface Symbolizable extends Perspective { interface SymbolTableBuilder { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java index 2a75d72bb4c..0b7eb907b85 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java @@ -37,7 +37,9 @@ import org.codehaus.staxmate.in.SMHierarchicCursor; /** * @since 1.10 + * @deprecated since 5.6 plugins should use their own dependencies */ +@Deprecated public class StaxParser { private SMInputFactory inf; @@ -77,7 +79,7 @@ public class StaxParser { } public void parse(File xmlFile) throws XMLStreamException { - FileInputStream input=null; + FileInputStream input = null; try { input = new FileInputStream(xmlFile); parse(input); @@ -123,7 +125,7 @@ public class StaxParser { if (StringUtils.startsWithIgnoreCase(undeclaredEntity, "u") && undeclaredEntity.length() == 5) { int unicodeCharHexValue = Integer.parseInt(undeclaredEntity.substring(1), 16); if (Character.isDefined(unicodeCharHexValue)) { - undeclaredEntity = new String(new char[]{(char) unicodeCharHexValue}); + undeclaredEntity = new String(new char[] {(char) unicodeCharHexValue}); } } return undeclaredEntity; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XmlParserException.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XmlParserException.java index 4737039a0df..cd88d5bf6de 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XmlParserException.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XmlParserException.java @@ -21,7 +21,9 @@ package org.sonar.api.utils; /** * @since 1.10 + * @deprecated since 5.6 */ +@Deprecated public class XmlParserException extends SonarException { public XmlParserException() { } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java index df350a4893b..e21fcefaf38 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java @@ -56,7 +56,9 @@ import org.xml.sax.SAXException; * XML Parsing tool using XPATH. It's recommended to use StaxParser when parsing big XML files. * * @since 1.10 + * @deprecated since 5.6 plugins should use their own dependencies */ +@Deprecated public class XpathParser { private static final String CAN_NOT_PARSE_XML = "can not parse xml : "; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java index 02b1582b999..341bc7991a8 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java @@ -19,35 +19,29 @@ */ package org.sonar.batch.postjob; -import org.sonar.batch.issue.tracking.TrackedIssue; - import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; - import javax.annotation.Nullable; - -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.postjob.PostJobContext; -import org.sonar.api.batch.postjob.issue.Issue; +import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.batch.rule.Severity; import org.sonar.api.config.Settings; import org.sonar.api.rule.RuleKey; import org.sonar.batch.index.BatchComponent; import org.sonar.batch.index.BatchComponentCache; import org.sonar.batch.issue.IssueCache; +import org.sonar.batch.issue.tracking.TrackedIssue; public class DefaultPostJobContext implements PostJobContext { private final Settings settings; - private final AnalysisMode analysisMode; private final IssueCache cache; private final BatchComponentCache resourceCache; - public DefaultPostJobContext(Settings settings, AnalysisMode analysisMode, IssueCache cache, BatchComponentCache resourceCache) { + public DefaultPostJobContext(Settings settings, IssueCache cache, BatchComponentCache resourceCache) { this.settings = settings; - this.analysisMode = analysisMode; this.cache = cache; this.resourceCache = resourceCache; } @@ -58,21 +52,16 @@ public class DefaultPostJobContext implements PostJobContext { } @Override - public AnalysisMode analysisMode() { - return analysisMode; - } - - @Override - public Iterable issues() { + public Iterable issues() { return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer()); } @Override - public Iterable resolvedIssues() { + public Iterable resolvedIssues() { return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(true)), new IssueTransformer()); } - private class DefaultIssueWrapper implements Issue { + private class DefaultIssueWrapper implements PostJobIssue { private final TrackedIssue wrapped; @@ -106,11 +95,6 @@ public class DefaultPostJobContext implements PostJobContext { return wrapped.startLine(); } - @Override - public Double effortToFix() { - return wrapped.gap(); - } - @Override public String message() { return wrapped.getMessage(); @@ -128,9 +112,9 @@ public class DefaultPostJobContext implements PostJobContext { } } - private class IssueTransformer implements Function { + private class IssueTransformer implements Function { @Override - public Issue apply(TrackedIssue input) { + public PostJobIssue apply(TrackedIssue input) { return new DefaultIssueWrapper(input); } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java index b27e89e87f8..e1b0cca1c1e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java @@ -22,7 +22,6 @@ package org.sonar.batch.postjob; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.BatchSide; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; import org.sonar.api.config.Settings; @@ -32,11 +31,9 @@ public class PostJobOptimizer { private static final Logger LOG = LoggerFactory.getLogger(PostJobOptimizer.class); private final Settings settings; - private final AnalysisMode analysisMode; - public PostJobOptimizer(Settings settings, AnalysisMode analysisMode) { + public PostJobOptimizer(Settings settings) { this.settings = settings; - this.analysisMode = analysisMode; } /** @@ -47,10 +44,6 @@ public class PostJobOptimizer { LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name()); return false; } - if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) { - LOG.debug("'{}' skipped in issues mode", descriptor.name()); - return false; - } return true; } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java index 12f00a55d90..5f9916919ec 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java @@ -19,20 +19,18 @@ */ package org.sonar.batch.postjob; -import org.sonar.batch.issue.tracking.TrackedIssue; - import java.util.Arrays; - import org.junit.Before; import org.junit.Test; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.postjob.issue.Issue; +import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.batch.rule.Severity; import org.sonar.api.config.Settings; import org.sonar.api.resources.File; import org.sonar.batch.index.BatchComponentCache; import org.sonar.batch.issue.IssueCache; +import org.sonar.batch.issue.tracking.TrackedIssue; + import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,7 +39,6 @@ public class DefaultPostJobContextTest { private IssueCache issueCache; private BatchComponentCache resourceCache; - private AnalysisMode analysisMode; private DefaultPostJobContext context; private Settings settings; @@ -49,15 +46,13 @@ public class DefaultPostJobContextTest { public void prepare() { issueCache = mock(IssueCache.class); resourceCache = new BatchComponentCache(); - analysisMode = mock(AnalysisMode.class); settings = new Settings(); - context = new DefaultPostJobContext(settings, analysisMode, issueCache, resourceCache); + context = new DefaultPostJobContext(settings, issueCache, resourceCache); } @Test public void test() { assertThat(context.settings()).isSameAs(settings); - assertThat(context.analysisMode()).isSameAs(analysisMode); TrackedIssue defaultIssue = new TrackedIssue(); defaultIssue.setComponentKey("foo:src/Foo.php"); @@ -69,9 +64,8 @@ public class DefaultPostJobContextTest { defaultIssue.setSeverity("BLOCKER"); when(issueCache.all()).thenReturn(Arrays.asList(defaultIssue)); - Issue issue = context.issues().iterator().next(); + PostJobIssue issue = context.issues().iterator().next(); assertThat(issue.componentKey()).isEqualTo("foo:src/Foo.php"); - assertThat(issue.effortToFix()).isEqualTo(2.0); assertThat(issue.isNew()).isTrue(); assertThat(issue.key()).isEqualTo("xyz"); assertThat(issue.line()).isEqualTo(1); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java index e5d30f1dfa3..3420e45f209 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java @@ -23,13 +23,10 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; import org.sonar.api.config.Settings; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class PostJobOptimizerTest { @@ -38,13 +35,11 @@ public class PostJobOptimizerTest { private PostJobOptimizer optimizer; private Settings settings; - private AnalysisMode analysisMode; @Before public void prepare() { settings = new Settings(); - analysisMode = mock(AnalysisMode.class); - optimizer = new PostJobOptimizer(settings, analysisMode); + optimizer = new PostJobOptimizer(settings); } @Test @@ -63,15 +58,4 @@ public class PostJobOptimizerTest { settings.setProperty("sonar.foo.reportPath", "foo"); assertThat(optimizer.shouldExecute(descriptor)).isTrue(); } - - @Test - public void should_disabled_in_issues_mode() { - DefaultPostJobDescriptor descriptor = new DefaultPostJobDescriptor() - .disabledInIssues(); - assertThat(optimizer.shouldExecute(descriptor)).isTrue(); - - when(analysisMode.isIssues()).thenReturn(true); - - assertThat(optimizer.shouldExecute(descriptor)).isFalse(); - } } -- 2.39.5