diff options
158 files changed, 284 insertions, 3958 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index ba4ffd9c554..e493d286402 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -78,8 +78,6 @@ import org.sonar.xoo.rule.XooSonarWayProfile; import org.sonar.xoo.scm.XooBlameCommand; import org.sonar.xoo.scm.XooIgnoreCommand; import org.sonar.xoo.scm.XooScmProvider; -import org.sonar.xoo.test.CoveragePerTestSensor; -import org.sonar.xoo.test.TestExecutionSensor; /** * Plugin entry-point, as declared in pom.xml. @@ -172,10 +170,6 @@ public class XooPlugin implements Plugin { // Analysis errors AnalysisErrorSensor.class, - // Tests - TestExecutionSensor.class, - CoveragePerTestSensor.class, - // Other XooProjectBuilder.class, XooPostJob.class, diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/AbstractCoverageSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/AbstractCoverageSensor.java index d01c96b1bf7..3e49638de9b 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/AbstractCoverageSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/AbstractCoverageSensor.java @@ -30,7 +30,6 @@ import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.batch.sensor.coverage.CoverageType; import org.sonar.api.batch.sensor.coverage.NewCoverage; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -46,8 +45,7 @@ public abstract class AbstractCoverageSensor implements Sensor { try { List<String> lines = FileUtils.readLines(coverageFile, context.fileSystem().encoding().name()); NewCoverage coverageBuilder = context.newCoverage() - .onFile(inputFile) - .ofType(getCoverageType()); + .onFile(inputFile); int lineNumber = 0; for (String line : lines) { lineNumber++; @@ -80,8 +78,6 @@ public abstract class AbstractCoverageSensor implements Sensor { protected abstract String getCoverageExtension(); - protected abstract CoverageType getCoverageType(); - @Override public void describe(SensorDescriptor descriptor) { descriptor diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/ItCoverageSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/ItCoverageSensor.java index 45ba3770a73..046e7d13071 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/ItCoverageSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/ItCoverageSensor.java @@ -19,8 +19,6 @@ */ package org.sonar.xoo.coverage; -import org.sonar.api.batch.sensor.coverage.CoverageType; - /** * Parse files *.xoo.itcoverage */ @@ -32,11 +30,6 @@ public class ItCoverageSensor extends AbstractCoverageSensor { } @Override - protected CoverageType getCoverageType() { - return CoverageType.IT; - } - - @Override protected String getSensorName() { return "Xoo IT Coverage Sensor"; } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/OverallCoverageSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/OverallCoverageSensor.java index f654826a464..419b86fe606 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/OverallCoverageSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/OverallCoverageSensor.java @@ -19,8 +19,6 @@ */ package org.sonar.xoo.coverage; -import org.sonar.api.batch.sensor.coverage.CoverageType; - /** * Parse files *.xoo.overallcoverage */ @@ -32,11 +30,6 @@ public class OverallCoverageSensor extends AbstractCoverageSensor { } @Override - protected CoverageType getCoverageType() { - return CoverageType.OVERALL; - } - - @Override protected String getSensorName() { return "Xoo Overall Coverage Sensor"; } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/UtCoverageSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/UtCoverageSensor.java index cba44d76f76..3ff71222e2d 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/UtCoverageSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/UtCoverageSensor.java @@ -19,8 +19,6 @@ */ package org.sonar.xoo.coverage; -import org.sonar.api.batch.sensor.coverage.CoverageType; - /** * Parse files *.xoo.coverage */ @@ -32,11 +30,6 @@ public class UtCoverageSensor extends AbstractCoverageSensor { } @Override - protected CoverageType getCoverageType() { - return CoverageType.UNIT; - } - - @Override protected String getSensorName() { return "Xoo UT Coverage Sensor"; } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java index 717402dd1c7..6b4dc103fd1 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java @@ -19,7 +19,6 @@ */ package org.sonar.xoo.extensions; -import com.google.common.collect.Iterables; import org.sonar.api.batch.postjob.PostJob; import org.sonar.api.batch.postjob.PostJobContext; import org.sonar.api.batch.postjob.PostJobDescriptor; @@ -34,13 +33,11 @@ public class XooPostJob implements PostJob { public void describe(PostJobDescriptor descriptor) { descriptor.name("Xoo Post Job") .requireProperty("sonar.xoo.enablePostJob"); - } @Override public void execute(PostJobContext context) { - LOG.info("Resolved issues: " + Iterables.size(context.resolvedIssues())); - LOG.info("Open issues: " + Iterables.size(context.issues())); + LOG.info("Running Xoo PostJob"); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java index 63778317a1b..9bd845064ce 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.List; -import javax.annotation.Nullable; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.batch.fs.InputFile; @@ -77,54 +76,38 @@ public class SymbolReferencesSensor implements Sensor { Iterator<String> split = Splitter.on(",").split(line).iterator(); String[] symbolOffsets = split.next().split(":"); - if (symbolOffsets.length == 2) { - int startOffset = parseInt(symbolOffsets[0]); - int endOffset = parseInt(symbolOffsets[1]); - NewSymbol s = symbolTable.newSymbol(startOffset, endOffset); - parseReferences(s, split, endOffset - startOffset); - } else if (symbolOffsets.length == 4) { + if (symbolOffsets.length == 4) { int startLine = parseInt(symbolOffsets[0]); int startLineOffset = parseInt(symbolOffsets[1]); int endLine = parseInt(symbolOffsets[2]); int endLineOffset = parseInt(symbolOffsets[3]); NewSymbol s = symbolTable.newSymbol(startLine, startLineOffset, endLine, endLineOffset); - parseReferences(s, split, null); + parseReferences(s, split); } else { throw new IllegalStateException("Illegal number of elements separated by ':'. " + - "Must either be startOffset:endOffset (offset in whole file) or startLine:startLineOffset:endLine:endLineOffset"); + "Must be startLine:startLineOffset:endLine:endLineOffset"); } } catch (Exception e) { throw new IllegalStateException("Error processing line " + lineNumber + " of file " + symbolFile.getAbsolutePath(), e); } } - private static void parseReferences(NewSymbol s, Iterator<String> split, @Nullable Integer defaultLen) { + private static void parseReferences(NewSymbol s, Iterator<String> split) { while (split.hasNext()) { - addReference(s, split.next(), defaultLen); + addReference(s, split.next()); } } - private static void addReference(NewSymbol s, String str, @Nullable Integer defaultLen) { - if (str.contains(":")) { - String[] split = str.split(":"); - if (split.length == 2) { - int startOffset = parseInt(split[0]); - int endOffset = parseInt(split[1]); - s.newReference(startOffset, endOffset); - } else if (split.length == 4) { - int startLine = parseInt(split[0]); - int startLineOffset = parseInt(split[1]); - int endLine = parseInt(split[2]); - int endLineOffset = parseInt(split[3]); - s.newReference(startLine, startLineOffset, endLine, endLineOffset); - } else { - throw new IllegalStateException("Illegal number of elements separated by ':'"); - } - } else if (defaultLen == null) { - throw new IllegalStateException("Mix of new and old format. Use startLine:startLineOffset:endLine:endLineOffset for references too"); + private static void addReference(NewSymbol s, String str) { + String[] split = str.split(":"); + if (split.length == 4) { + int startLine = parseInt(split[0]); + int startLineOffset = parseInt(split[1]); + int endLine = parseInt(split[2]); + int endLineOffset = parseInt(split[3]); + s.newReference(startLine, startLineOffset, endLine, endLineOffset); } else { - int startOffset = parseInt(str); - s.newReference(startOffset, startOffset + defaultLen); + throw new IllegalStateException("Illegal number of elements separated by ':'"); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java index ec943a34432..628259e4e43 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java @@ -71,11 +71,7 @@ public class SyntaxHighlightingSensor implements Sensor { private static void processLine(File highlightingFile, int lineNumber, NewHighlighting highlighting, String line) { try { String[] split = line.split(":"); - if (split.length == 3) { - int startOffset = parseInt(split[0]); - int endOffset = parseInt(split[1]); - highlighting.highlight(startOffset, endOffset, TypeOfText.forCssClass(split[2])); - } else if (split.length == 5) { + if (split.length == 5) { int startLine = parseInt(split[0]); int startLineOffset = parseInt(split[1]); int endLine = parseInt(split[2]); @@ -83,7 +79,7 @@ public class SyntaxHighlightingSensor implements Sensor { highlighting.highlight(startLine, startLineOffset, endLine, endLineOffset, TypeOfText.forCssClass(split[4])); } else { throw new IllegalStateException("Illegal number of elements separated by ':'. " + - "Must either be startOffset:endOffset:class (offset in whole file) or startLine:startLineOffset:endLine:endLineOffset:class"); + "Must be startLine:startLineOffset:endLine:endLineOffset:class"); } } catch (Exception e) { throw new IllegalStateException("Error processing line " + lineNumber + " of file " + highlightingFile.getAbsolutePath(), e); diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2BasicProfile.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2BasicProfile.java index 2283c517f2a..6b2de61586d 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2BasicProfile.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2BasicProfile.java @@ -19,23 +19,15 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; +import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; import org.sonar.xoo.Xoo2; -public class Xoo2BasicProfile extends ProfileDefinition { - +public class Xoo2BasicProfile implements BuiltInQualityProfilesDefinition { @Override - public RulesProfile createProfile(ValidationMessages messages) { - RulesProfile profile = RulesProfile.create("Basic", Xoo2.KEY); - profile.setDefaultProfile(true); - - // so UGLY - profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR); - - return profile; + public void define(Context context) { + NewBuiltInQualityProfile qProfile = context.createBuiltInQualityProfile("Basic", Xoo2.KEY); + qProfile.setDefault(true); + qProfile.activateRule(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY); + qProfile.done(); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2SonarWayProfile.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2SonarWayProfile.java index e611408aa6c..cf938351c5f 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2SonarWayProfile.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/Xoo2SonarWayProfile.java @@ -19,22 +19,15 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; +import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; import org.sonar.xoo.Xoo2; -public class Xoo2SonarWayProfile extends ProfileDefinition { - +public class Xoo2SonarWayProfile implements BuiltInQualityProfilesDefinition { @Override - public RulesProfile createProfile(ValidationMessages messages) { - RulesProfile profile = RulesProfile.create("Sonar way", Xoo2.KEY); - - profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR); - profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, OneIssuePerLineSensor.RULE_KEY), RulePriority.MINOR); - - return profile; + public void define(Context context) { + NewBuiltInQualityProfile qProfile = context.createBuiltInQualityProfile("Sonar way", Xoo2.KEY); + qProfile.activateRule(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY); + qProfile.activateRule(XooRulesDefinition.XOO2_REPOSITORY, OneIssuePerLineSensor.RULE_KEY); + qProfile.done(); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooBasicProfile.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooBasicProfile.java index 3b4b5f25e32..c68efdfc0ee 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooBasicProfile.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooBasicProfile.java @@ -19,22 +19,15 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; +import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; import org.sonar.xoo.Xoo; -public class XooBasicProfile extends ProfileDefinition { - +public class XooBasicProfile implements BuiltInQualityProfilesDefinition { @Override - public RulesProfile createProfile(ValidationMessages validation) { - final RulesProfile profile = RulesProfile.create("Basic", Xoo.KEY); - profile.setDefaultProfile(true); - - profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR); - - return profile; + public void define(Context context) { + NewBuiltInQualityProfile qProfile = context.createBuiltInQualityProfile("Basic", Xoo.KEY); + qProfile.setDefault(true); + qProfile.activateRule(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY); + qProfile.done(); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooEmptyProfile.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooEmptyProfile.java index 1f51a24e526..049735c0d8c 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooEmptyProfile.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooEmptyProfile.java @@ -19,15 +19,13 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.utils.ValidationMessages; +import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; import org.sonar.xoo.Xoo; -public class XooEmptyProfile extends ProfileDefinition { - +public class XooEmptyProfile implements BuiltInQualityProfilesDefinition { @Override - public RulesProfile createProfile(ValidationMessages validation) { - return RulesProfile.create("empty", Xoo.KEY); + public void define(Context context) { + context.createBuiltInQualityProfile("empty", Xoo.KEY) + .done(); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooSonarWayProfile.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooSonarWayProfile.java index 0c92f9b67aa..f35fd64ae99 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooSonarWayProfile.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooSonarWayProfile.java @@ -19,24 +19,18 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; +import org.sonar.api.rule.Severity; +import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; import org.sonar.xoo.Xoo; -public class XooSonarWayProfile extends ProfileDefinition { - +public class XooSonarWayProfile implements BuiltInQualityProfilesDefinition { @Override - public RulesProfile createProfile(ValidationMessages validation) { - final RulesProfile profile = RulesProfile.create("Sonar way", Xoo.KEY); - - profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR); - profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerLineSensor.RULE_KEY), RulePriority.INFO); - profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerFileSensor.RULE_KEY), RulePriority.CRITICAL); - profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HotspotSensor.RULE_KEY), RulePriority.CRITICAL); - - return profile; + public void define(Context context) { + NewBuiltInQualityProfile qProfile = context.createBuiltInQualityProfile("Sonar way", Xoo.KEY); + qProfile.activateRule(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY).overrideSeverity(Severity.MAJOR); + qProfile.activateRule(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerLineSensor.RULE_KEY).overrideSeverity(Severity.INFO); + qProfile.activateRule(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerFileSensor.RULE_KEY).overrideSeverity(Severity.CRITICAL); + qProfile.activateRule(XooRulesDefinition.XOO_REPOSITORY, HotspotSensor.RULE_KEY).overrideSeverity(Severity.CRITICAL); + qProfile.done(); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/CoveragePerTestSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/CoveragePerTestSensor.java deleted file mode 100644 index 0c0c199ed38..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/CoveragePerTestSensor.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.xoo.test; - -import com.google.common.base.Splitter; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.DependsUpon; -import org.sonar.api.batch.fs.FilePredicates; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.batch.sensor.Sensor; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.component.ResourcePerspectives; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.api.test.MutableTestable; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.xoo.Xoo; - -/** - * Parse files *.xoo.testcoverage - */ -@DependsUpon("test-exec") -public class CoveragePerTestSensor implements Sensor { - private static final Logger LOG = Loggers.get(CoveragePerTestSensor.class); - - private static final String TEST_EXTENSION = ".testcoverage"; - - private final FileSystem fs; - private final ResourcePerspectives perspectives; - - public CoveragePerTestSensor(FileSystem fileSystem, ResourcePerspectives perspectives) { - this.fs = fileSystem; - this.perspectives = perspectives; - } - - private void processTestFile(InputFile inputFile, SensorContext context) { - File testExecutionFile = new File(inputFile.file().getParentFile(), inputFile.file().getName() + TEST_EXTENSION); - if (testExecutionFile.exists()) { - LOG.debug("Processing " + testExecutionFile.getAbsolutePath()); - try { - List<String> lines = FileUtils.readLines(testExecutionFile, fs.encoding().name()); - int lineNumber = 0; - MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, inputFile); - for (String line : lines) { - lineNumber++; - if (StringUtils.isBlank(line)) { - continue; - } - if (line.startsWith("#")) { - continue; - } - try { - Iterator<String> split = Splitter.on(";").split(line).iterator(); - String name = split.next(); - while (split.hasNext()) { - String coveredBlockStr = split.next(); - Iterator<String> splitCoveredBlock = Splitter.on(",").split(coveredBlockStr).iterator(); - String componentPath = splitCoveredBlock.next(); - InputFile coveredFile = context.fileSystem().inputFile(context.fileSystem().predicates().hasPath(componentPath)); - MutableTestable testable = perspectives.as(MutableTestable.class, coveredFile); - List<Integer> coveredLines = new ArrayList<>(); - while (splitCoveredBlock.hasNext()) { - coveredLines.add(Integer.parseInt(splitCoveredBlock.next())); - } - for (MutableTestCase testCase : testPlan.testCasesByName(name)) { - testCase.setCoverageBlock(testable, coveredLines); - } - } - } catch (Exception e) { - throw new IllegalStateException("Error processing line " + lineNumber + " of file " + testExecutionFile.getAbsolutePath(), e); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - @Override - public void describe(SensorDescriptor descriptor) { - descriptor - .name("Xoo Coverage Per Test Sensor") - .onlyOnLanguages(Xoo.KEY); - } - - @Override - public void execute(SensorContext context) { - FilePredicates p = context.fileSystem().predicates(); - for (InputFile file : context.fileSystem().inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.TEST)))) { - processTestFile(file, context); - } - } - -} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/TestExecutionSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/TestExecutionSensor.java deleted file mode 100644 index b39b2cbb18f..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/TestExecutionSensor.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.xoo.test; - -import com.google.common.base.Splitter; -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.DependedUpon; -import org.sonar.api.batch.fs.FilePredicates; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.batch.sensor.Sensor; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.component.ResourcePerspectives; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.api.test.TestCase; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.xoo.Xoo; - -/** - * Parse files *.xoo.test - */ -@DependedUpon("test-exec") -public class TestExecutionSensor implements Sensor { - private static final Logger LOG = Loggers.get(TestExecutionSensor.class); - - private static final String TEST_EXTENSION = ".test"; - - private final FileSystem fs; - private final ResourcePerspectives perspectives; - - public TestExecutionSensor(FileSystem fileSystem, ResourcePerspectives perspectives) { - this.fs = fileSystem; - this.perspectives = perspectives; - } - - private void processTestFile(InputFile inputFile, SensorContext context) { - File testExecutionFile = new File(inputFile.file().getParentFile(), inputFile.file().getName() + TEST_EXTENSION); - if (testExecutionFile.exists()) { - LOG.debug("Processing " + testExecutionFile.getAbsolutePath()); - try { - List<String> lines = FileUtils.readLines(testExecutionFile, fs.encoding().name()); - int lineNumber = 0; - MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, inputFile); - for (String line : lines) { - lineNumber++; - if (StringUtils.isBlank(line)) { - continue; - } - if (line.startsWith("#")) { - continue; - } - try { - Iterator<String> split = Splitter.on(":").split(line).iterator(); - String name = split.next(); - String durationStr = split.next(); - Long duration = StringUtils.isNotBlank(durationStr) ? Long.parseLong(durationStr) : null; - String msg = split.next(); - String stack = split.next(); - String status = split.next(); - String type = split.next(); - MutableTestCase testCase = testPlan.addTestCase(name); - testCase.setDurationInMs(duration); - testCase.setMessage(msg); - testCase.setStackTrace(stack); - testCase.setStatus(TestCase.Status.valueOf(status)); - testCase.setType(type); - } catch (Exception e) { - throw new IllegalStateException("Error processing line " + lineNumber + " of file " + testExecutionFile.getAbsolutePath(), e); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - @Override - public void describe(SensorDescriptor descriptor) { - descriptor - .name("Xoo Test Execution Sensor") - .onlyOnLanguages(Xoo.KEY); - } - - @Override - public void execute(SensorContext context) { - FilePredicates p = context.fileSystem().predicates(); - for (InputFile file : context.fileSystem().inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.TEST)))) { - processTestFile(file, context); - } - } - - -} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/package-info.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/package-info.java deleted file mode 100644 index 8586ad8b37e..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/test/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.xoo.test; - -import javax.annotation.ParametersAreNonnullByDefault; 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 7ee02b46c47..7ada6d09d07 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 @@ -19,16 +19,14 @@ */ package org.sonar.xoo.extensions; -import java.util.Arrays; import org.junit.Rule; import org.junit.Test; import org.sonar.api.batch.postjob.PostJobContext; -import org.sonar.api.utils.log.LogTester; import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; +import org.sonar.api.utils.log.LogTester; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class XooPostJobTest { @@ -39,9 +37,7 @@ 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()); new XooPostJob().execute(context); - assertThat(logTester.logs()).contains("Resolved issues: 0", "Open issues: 0"); + assertThat(logTester.logs()).contains("Running Xoo PostJob"); } } diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java index f525c39f4d9..6c681ba53fb 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java @@ -66,7 +66,7 @@ public class SymbolReferencesSensorTest { @Test public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.symbol"); - FileUtils.write(symbol, "1:4,7\n12:15,23:33\n\n#comment"); + FileUtils.write(symbol, "1:1:1:4,1:7:1:10\n1:11:1:13,1:14:1:33\n\n#comment"); InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") .initMetadata("xoo file with some source code and length over 33") .setLanguage(Xoo.KEY) @@ -78,8 +78,8 @@ public class SymbolReferencesSensorTest { assertThat(context.referencesForSymbolAt("foo:src/foo.xoo", 1, 2)) .containsOnly(new DefaultTextRange(new DefaultTextPointer(1, 7), new DefaultTextPointer(1, 10))); - assertThat(context.referencesForSymbolAt("foo:src/foo.xoo", 1, 13)) - .containsOnly(new DefaultTextRange(new DefaultTextPointer(1, 23), new DefaultTextPointer(1, 33))); + assertThat(context.referencesForSymbolAt("foo:src/foo.xoo", 1, 12)) + .containsOnly(new DefaultTextRange(new DefaultTextPointer(1, 14), new DefaultTextPointer(1, 33))); } } diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java index c00ddb270e6..3f4cd46a781 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java @@ -68,7 +68,7 @@ public class SyntaxHighlightingSensorTest { @Test public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.highlighting"); - FileUtils.write(symbol, "1:4:k\n12:15:cd\n\n#comment"); + FileUtils.write(symbol, "1:1:1:4:k\n2:7:2:10:cd\n\n#comment"); DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo") .setLanguage("xoo") .setModuleBaseDir(baseDir.toPath()) 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 8214b783d40..fabca7a0567 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 @@ -25,12 +25,13 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; -import org.sonar.api.batch.rule.Severity; -import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.fs.internal.TestInputFileBuilder; +import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; +import org.sonar.api.batch.sensor.issue.Issue; +import org.sonar.api.config.internal.MapSettings; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.Version; import org.sonar.xoo.Xoo; @@ -77,7 +78,7 @@ public class OneIssuePerLineSensorTest { SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); - context.settings().setProperty(OneIssuePerLineSensor.FORCE_SEVERITY_PROPERTY, "MINOR"); + context.setSettings(new MapSettings().setProperty(OneIssuePerLineSensor.FORCE_SEVERITY_PROPERTY, "MINOR")); sensor.execute(context); @@ -96,7 +97,7 @@ public class OneIssuePerLineSensorTest { SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); - context.settings().setProperty(OneIssuePerLineSensor.EFFORT_TO_FIX_PROPERTY, "1.2"); + context.setSettings(new MapSettings().setProperty(OneIssuePerLineSensor.EFFORT_TO_FIX_PROPERTY, "1.2")); sensor.execute(context); @@ -115,7 +116,7 @@ public class OneIssuePerLineSensorTest { SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); - context.settings().setProperty(OneIssuePerLineSensor.EFFORT_TO_FIX_PROPERTY, "1.2"); + context.setSettings(new MapSettings().setProperty(OneIssuePerLineSensor.EFFORT_TO_FIX_PROPERTY, "1.2")); context.setRuntime(SonarRuntimeImpl.forSonarQube(Version.parse("5.4"), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY)); sensor.execute(context); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReader.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReader.java index 0001fd1109c..338fbe5c2e2 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReader.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReader.java @@ -49,7 +49,6 @@ public class HighlightingLineReader implements LineReader { .put(HighlightingType.ANNOTATION, "a") .put(HighlightingType.CONSTANT, "c") .put(HighlightingType.COMMENT, "cd") - .put(HighlightingType.CPP_DOC, "cppd") .put(HighlightingType.STRUCTURED_COMMENT, "j") .put(HighlightingType.KEYWORD, "k") .put(HighlightingType.KEYWORD_LIGHT, "h") diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java index 3c8c6fb67c7..afba34d49fd 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java @@ -46,7 +46,6 @@ import static org.sonar.db.protobuf.DbFileSources.Data.newBuilder; import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.ANNOTATION; import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.COMMENT; import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.CONSTANT; -import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.CPP_DOC; import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.HIGHLIGHTING_STRING; import static org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType.KEYWORD; @@ -119,7 +118,7 @@ public class HighlightingLineReaderTest { public void supports_highlighting_over_multiple_lines_including_an_empty_one() { List<ScannerReport.SyntaxHighlightingRule> syntaxHighlightingList = new ArrayList<>(); addHighlighting(syntaxHighlightingList, 1, 0, 1, 7, KEYWORD); // package - addHighlighting(syntaxHighlightingList, 2, 0, 4, 6, CPP_DOC); // comment over 3 lines + addHighlighting(syntaxHighlightingList, 2, 0, 4, 6, COMMENT); // comment over 3 lines addHighlighting(syntaxHighlightingList, 5, 0, 5, 6, KEYWORD); // public addHighlighting(syntaxHighlightingList, 5, 7, 5, 12, KEYWORD); // class HighlightingLineReader highlightingLineReader = new HighlightingLineReader(FILE, syntaxHighlightingList.iterator(), new RangeOffsetConverter()); @@ -137,9 +136,9 @@ public class HighlightingLineReaderTest { .extracting("highlighting") .containsExactly( "0,7,k", - "0,2,cppd", + "0,2,cd", "", - "0,6,cppd", + "0,6,cd", "0,6,k;7,12,k", ""); } diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 4a5c936954d..c7f5ee8eaba 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -29,7 +29,6 @@ import org.sonar.api.SonarQubeVersion; import org.sonar.api.config.EmailSettings; import org.sonar.api.internal.MetadataLoader; import org.sonar.api.internal.SonarRuntimeImpl; -import org.sonar.api.profiles.AnnotationProfileParser; import org.sonar.api.profiles.XMLProfileParser; import org.sonar.api.profiles.XMLProfileSerializer; import org.sonar.api.resources.Languages; @@ -109,7 +108,7 @@ import org.sonar.server.l18n.ServerI18n; import org.sonar.server.log.ServerLogging; import org.sonar.server.measure.index.ProjectMeasuresIndexer; import org.sonar.server.metric.CoreCustomMetrics; -import org.sonar.server.metric.DefaultMetricFinder; +import org.sonar.server.metric.MetricFinder; import org.sonar.server.metric.UnanalyzedLanguageMetrics; import org.sonar.server.notification.DefaultNotificationManager; import org.sonar.server.notification.NotificationService; @@ -362,7 +361,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { ActiveRuleIndexer.class, XMLProfileParser.class, XMLProfileSerializer.class, - AnnotationProfileParser.class, BuiltInQualityProfileAnnotationLoader.class, Rules.QProfiles.class, @@ -378,7 +376,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { // measure CoreCustomMetrics.class, - DefaultMetricFinder.class, + MetricFinder.class, UnanalyzedLanguageMetrics.class, UserIndexer.class, diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java b/server/sonar-server-common/src/main/java/org/sonar/server/metric/MetricFinder.java index 513e7f70fb1..58237289bae 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/metric/MetricFinder.java @@ -26,22 +26,20 @@ import java.util.Collection; import java.util.List; import javax.annotation.Nonnull; import org.sonar.api.measures.Metric; -import org.sonar.api.measures.MetricFinder; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.metric.MetricDto; import static com.google.common.collect.FluentIterable.from; -public class DefaultMetricFinder implements MetricFinder { +public class MetricFinder { private final DbClient dbClient; - public DefaultMetricFinder(DbClient dbClient) { + public MetricFinder(DbClient dbClient) { this.dbClient = dbClient; } - @Override public Metric findByUuid(String uuid) { try (DbSession session = dbClient.openSession(false)) { MetricDto dto = dbClient.metricDao().selectByUuid(session, uuid); @@ -52,7 +50,6 @@ public class DefaultMetricFinder implements MetricFinder { } } - @Override public Metric findByKey(String key) { try (DbSession session = dbClient.openSession(false)) { MetricDto dto = dbClient.metricDao().selectByKey(session, key); @@ -63,7 +60,6 @@ public class DefaultMetricFinder implements MetricFinder { } } - @Override public Collection<Metric> findAll(List<String> metricKeys) { try (DbSession session = dbClient.openSession(false)) { List<MetricDto> dtos = dbClient.metricDao().selectByKeys(session, metricKeys); @@ -71,7 +67,6 @@ public class DefaultMetricFinder implements MetricFinder { } } - @Override public Collection<Metric> findAll() { try (DbSession session = dbClient.openSession(false)) { List<MetricDto> dtos = dbClient.metricDao().selectEnabled(session); diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerImpl.java index bb3ef612cae..3196c73a5db 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerImpl.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerImpl.java @@ -72,11 +72,6 @@ public class ServerImpl extends Server { } @Override - public File getRootDir() { - return fs.getHomeDir(); - } - - @Override public String getContextPath() { return urlSettings.getContextPath(); } @@ -87,18 +82,8 @@ public class ServerImpl extends Server { } @Override - public boolean isDev() { - return false; - } - - @Override public boolean isSecured() { return urlSettings.isSecured(); } - @Override - public String getURL() { - return urlSettings.getBaseUrl(); - } - } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java b/server/sonar-server-common/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java index 9783b690c90..238efdada59 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java @@ -24,9 +24,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import java.lang.annotation.Annotation; import java.util.Collection; -import java.util.Map; import java.util.Set; -import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; @@ -38,7 +36,6 @@ import org.sonar.core.platform.PluginRepository; import static java.lang.String.format; import static java.util.Objects.requireNonNull; -import static org.sonar.core.extension.ExtensionProviderSupport.isExtensionProvider; /** * Loads the plugins server extensions and injects them to DI container @@ -69,7 +66,7 @@ public abstract class ServerExtensionInstaller { .build(); plugin.define(context); for (Object extension : context.getExtensions()) { - if (installExtension(container, pluginInfo, extension, true) != null) { + if (installExtension(container, pluginInfo, extension) != null) { installedExtensionsByPlugin.put(pluginInfo, extension); } else { container.declareExtension(pluginInfo, extension); @@ -80,40 +77,11 @@ public abstract class ServerExtensionInstaller { throw new IllegalStateException(format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e); } } - for (Map.Entry<PluginInfo, Object> entry : installedExtensionsByPlugin.entries()) { - PluginInfo pluginInfo = entry.getKey(); - try { - Object extension = entry.getValue(); - if (isExtensionProvider(extension)) { - ExtensionProvider provider = (ExtensionProvider) container.getComponentByKey(extension); - installProvider(container, pluginInfo, provider); - } - } catch (Throwable e) { - // catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...) - throw new IllegalStateException(format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e); - } - } } - private void installProvider(ComponentContainer container, PluginInfo pluginInfo, ExtensionProvider provider) { - Object obj = provider.provide(); - if (obj != null) { - if (obj instanceof Iterable) { - for (Object ext : (Iterable) obj) { - installExtension(container, pluginInfo, ext, false); - } - } else { - installExtension(container, pluginInfo, obj, false); - } - } - } - - private Object installExtension(ComponentContainer container, PluginInfo pluginInfo, Object extension, boolean acceptProvider) { + private Object installExtension(ComponentContainer container, PluginInfo pluginInfo, Object extension) { for (Class<? extends Annotation> supportedAnnotationType : supportedAnnotationTypes) { if (AnnotationUtils.getAnnotation(extension, supportedAnnotationType) != null) { - if (!acceptProvider && isExtensionProvider(extension)) { - throw new IllegalStateException("ExtensionProvider can not include providers itself: " + extension); - } container.addExtension(pluginInfo, extension); return extension; } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/metric/MetricFinderTest.java index b340a59ddbc..f2c429fc212 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/metric/MetricFinderTest.java @@ -30,13 +30,12 @@ import org.sonar.db.metric.MetricDto; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.db.metric.MetricTesting.newMetricDto; - -public class DefaultMetricFinderTest { +public class MetricFinderTest { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private DefaultMetricFinder underTest = new DefaultMetricFinder(db.getDbClient()); + private final MetricFinder underTest = new MetricFinder(db.getDbClient()); @Test public void findAll_enabled() { @@ -70,6 +69,24 @@ public class DefaultMetricFinderTest { } @Test + public void findById_filters_out_disabled() { + MetricDto firstMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto().setEnabled(false)); + db.commit(); + + assertThat(underTest.findByUuid(secondMetric.getUuid())).isNull(); + } + + @Test + public void findById_doesnt_find_anything() { + MetricDto firstMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + db.commit(); + + assertThat(underTest.findByUuid("non existing")).isNull(); + } + + @Test public void findByKey() { MetricDto firstMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); @@ -77,4 +94,22 @@ public class DefaultMetricFinderTest { assertThat(underTest.findByKey(secondMetric.getKey())).extracting(Metric::getKey).isEqualTo(secondMetric.getKey()); } + + @Test + public void findByKey_filters_out_disabled() { + MetricDto firstMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto().setEnabled(false)); + db.commit(); + + assertThat(underTest.findByKey(secondMetric.getKey())).isNull(); + } + + @Test + public void findByKey_doesnt_find_anything() { + MetricDto firstMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); + db.commit(); + + assertThat(underTest.findByKey("doesnt exist")).isNull(); + } } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerImplTest.java index 77f4b1739b2..79657e160ea 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerImplTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerImplTest.java @@ -46,20 +46,13 @@ public class ServerImplTest { public TemporaryFolder temp = new TemporaryFolder(); @Test - public void isDev_always_returns_false() { - assertThat(underTest.isDev()).isFalse(); - } - - @Test public void test_url_information() { when(urlSettings.getContextPath()).thenReturn("/foo"); when(urlSettings.getBaseUrl()).thenReturn("http://localhost:9000/foo"); when(urlSettings.isSecured()).thenReturn(false); assertThat(underTest.getContextPath()).isEqualTo("/foo"); - assertThat(underTest.getURL()).isEqualTo("http://localhost:9000/foo"); assertThat(underTest.getPublicRootUrl()).isEqualTo("http://localhost:9000/foo"); - assertThat(underTest.isDev()).isFalse(); assertThat(underTest.isSecured()).isFalse(); } @@ -67,8 +60,6 @@ public class ServerImplTest { public void test_file_system_information() throws IOException { File home = temp.newFolder(); when(fs.getHomeDir()).thenReturn(home); - - assertThat(underTest.getRootDir()).isEqualTo(home); } @Test diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java index d70c2a9a6d1..c536cd865e5 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java @@ -102,11 +102,6 @@ class FakeServer extends Server { } @Override - public File getRootDir() { - return null; - } - - @Override public String getContextPath() { return null; } @@ -117,21 +112,11 @@ class FakeServer extends Server { } @Override - public boolean isDev() { - return false; - } - - @Override public boolean isSecured() { return false; } @Override - public String getURL() { - return null; - } - - @Override public String getPermanentServerId() { return null; } diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java deleted file mode 100644 index 525b1cbefc6..00000000000 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.server.qualityprofile; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRuleParam; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; -import org.sonar.api.utils.ValidationMessages; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.api.utils.log.Profiler; - -import static java.lang.String.format; - -/** - * Bridge between deprecated {@link ProfileDefinition} API and new {@link BuiltInQualityProfilesDefinition} - */ -public class BuiltInQProfileDefinitionsBridge implements BuiltInQualityProfilesDefinition { - private static final Logger LOGGER = Loggers.get(BuiltInQProfileDefinitionsBridge.class); - - private final List<ProfileDefinition> definitions; - - /** - * Requires for pico container when no {@link ProfileDefinition} is defined at all - */ - public BuiltInQProfileDefinitionsBridge() { - this(new ProfileDefinition[0]); - } - - public BuiltInQProfileDefinitionsBridge(ProfileDefinition... definitions) { - this.definitions = ImmutableList.copyOf(definitions); - } - - @Override - public void define(Context context) { - Profiler profiler = Profiler.create(Loggers.get(getClass())); - for (ProfileDefinition definition : definitions) { - profiler.start(); - ValidationMessages validation = ValidationMessages.create(); - RulesProfile profile = definition.createProfile(validation); - validation.log(LOGGER); - if (profile == null) { - profiler.stopDebug(format("Loaded definition %s that return no profile", definition)); - } else { - if (!validation.hasErrors()) { - define(context, profile); - } - profiler.stopDebug(format("Loaded deprecated profile definition %s for language %s", profile.getName(), profile.getLanguage())); - } - } - } - - private static void define(Context context, RulesProfile profile) { - NewBuiltInQualityProfile newQp = context.createBuiltInQualityProfile(profile.getName(), profile.getLanguage()) - .setDefault(profile.getDefaultProfile()); - - for (org.sonar.api.rules.ActiveRule ar : profile.getActiveRules()) { - NewBuiltInActiveRule newActiveRule = newQp.activateRule(ar.getRepositoryKey(), ar.getRuleKey()); - RulePriority overriddenSeverity = ar.getOverriddenSeverity(); - if (overriddenSeverity != null) { - newActiveRule.overrideSeverity(overriddenSeverity.name()); - } - for (ActiveRuleParam param : ar.getActiveRuleParams()) { - newActiveRule.overrideParam(param.getKey(), param.getValue()); - } - } - newQp.done(); - } - -} diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java deleted file mode 100644 index 476fcb45c07..00000000000 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.server.qualityprofile; - -import java.util.Arrays; -import org.junit.Test; -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rule.Severity; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleParam; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; -import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInActiveRule; -import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile; -import org.sonar.api.utils.ValidationMessages; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; - -public class BuiltInQProfileDefinitionsBridgeTest { - - @Test - public void noProfileDefinitions() { - BuiltInQProfileDefinitionsBridge bridge = new BuiltInQProfileDefinitionsBridge(); - - BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context(); - bridge.define(context); - - assertThat(context.profilesByLanguageAndName()).isEmpty(); - } - - @Test - public void bridgeProfileDefinitions() { - BuiltInQProfileDefinitionsBridge bridge = new BuiltInQProfileDefinitionsBridge(new Profile1(), new NullProfile(), new ProfileWithError()); - - BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context(); - bridge.define(context); - - assertThat(context.profilesByLanguageAndName()).hasSize(1); - assertThat(context.profilesByLanguageAndName().get("xoo")).hasSize(1); - - BuiltInQualityProfile profile1 = context.profile("xoo", "Profile 1"); - assertThat(profile1).isNotNull(); - assertThat(profile1.rules()).hasSize(3); - BuiltInActiveRule defaultSeverity = profile1.rule(RuleKey.of("repo1", "defaultSeverity")); - assertThat(defaultSeverity).isNotNull(); - assertThat(defaultSeverity.overriddenSeverity()).isNull(); - assertThat(defaultSeverity.overriddenParams()).isEmpty(); - - assertThat(profile1.rule(RuleKey.of("repo1", "overrideSeverity")).overriddenSeverity()).isEqualTo(Severity.CRITICAL); - - assertThat(profile1.rule(RuleKey.of("repo1", "overrideParam")).overriddenParams()) - .extracting(BuiltInQualityProfilesDefinition.OverriddenParam::key, BuiltInQualityProfilesDefinition.OverriddenParam::overriddenValue).containsOnly(tuple("param", "value")); - } - - private static class Profile1 extends ProfileDefinition { - @Override - public RulesProfile createProfile(ValidationMessages validation) { - RulesProfile profile1 = RulesProfile.create("Profile 1", "xoo"); - - profile1.activateRule(Rule.create("repo1", "defaultSeverity"), null); - profile1.activateRule(Rule.create("repo1", "overrideSeverity"), RulePriority.CRITICAL); - Rule ruleWithParam = Rule.create("repo1", "overrideParam"); - ruleWithParam.setParams(Arrays.asList(new RuleParam(ruleWithParam, "param", "", ""))); - ActiveRule arWithParam = profile1.activateRule(ruleWithParam, null); - arWithParam.setParameter("param", "value"); - - return profile1; - } - } - - private static class NullProfile extends ProfileDefinition { - @Override - public RulesProfile createProfile(ValidationMessages validation) { - return null; - } - } - - private static class ProfileWithError extends ProfileDefinition { - @Override - public RulesProfile createProfile(ValidationMessages validation) { - validation.addErrorText("Foo"); - return RulesProfile.create("Profile with errors", "xoo"); - } - } -} diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java index ce0fc6e48e0..be384165d5f 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -115,7 +115,7 @@ public class RegisterRules implements Startable { Profiler profiler = Profiler.create(LOG).startInfo("Register rules"); try (DbSession dbSession = dbClient.openSession(false)) { RulesDefinition.Context ruleDefinitionContext = defLoader.load(); - List<RulesDefinition.ExtendedRepository> repositories = getRepositories(ruleDefinitionContext); + List<RulesDefinition.Repository> repositories = ruleDefinitionContext.repositories(); RegisterRulesContext registerRulesContext = createRegisterRulesContext(dbSession); verifyRuleKeyConsistency(repositories, registerRulesContext); @@ -149,18 +149,6 @@ public class RegisterRules implements Startable { } } - private static List<RulesDefinition.ExtendedRepository> getRepositories(RulesDefinition.Context context) { - List<RulesDefinition.ExtendedRepository> repositories = new ArrayList<>(context.repositories()); - for (RulesDefinition.ExtendedRepository extendedRepoDef : context.extendedRepositories()) { - if (context.repository(extendedRepoDef.key()) == null) { - LOG.warn(format("Extension is ignored, repository %s does not exist", extendedRepoDef.key())); - } else { - repositories.add(extendedRepoDef); - } - } - return repositories; - } - private RegisterRulesContext createRegisterRulesContext(DbSession dbSession) { Map<RuleKey, RuleDefinitionDto> allRules = dbClient.ruleDao().selectAllDefinitions(dbSession).stream() .collect(uniqueIndex(RuleDefinitionDto::getKey)); @@ -736,7 +724,7 @@ public class RegisterRules implements Startable { * If an extended repository do not exists anymore, then related active rules will be removed. */ private List<ActiveRuleChange> removeActiveRulesOnStillExistingRepositories(DbSession dbSession, RegisterRulesContext recorder, - List<RulesDefinition.ExtendedRepository> context) { + List<RulesDefinition.Repository> context) { List<String> repositoryKeys = context.stream() .map(RulesDefinition.ExtendedRepository::key) .collect(MoreCollectors.toList(context.size())); @@ -759,7 +747,7 @@ public class RegisterRules implements Startable { dbClient.ruleDao().update(session, rule); } - private static void verifyRuleKeyConsistency(List<RulesDefinition.ExtendedRepository> repositories, RegisterRulesContext registerRulesContext) { + private static void verifyRuleKeyConsistency(List<RulesDefinition.Repository> repositories, RegisterRulesContext registerRulesContext) { List<RulesDefinition.Rule> definedRules = repositories.stream() .flatMap(r -> r.rules().stream()) .collect(toList()); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index aa8077c7f40..07b785376a7 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -1151,7 +1151,7 @@ public class RegisterRulesTest { static class FbContribRepository implements RulesDefinition { @Override public void define(Context context) { - NewExtendedRepository repo = context.extendRepository("findbugs", "java"); + NewExtendedRepository repo = context.createRepository("findbugs", "java"); repo.createRule("rule2") .setName("Rule Two") .setHtmlDescription("Description of Rule Two"); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java index 8e154025a20..0818032103b 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java @@ -19,7 +19,6 @@ */ package org.sonar.server.telemetry; -import java.io.File; import java.util.Date; import javax.annotation.CheckForNull; import org.sonar.api.platform.Server; @@ -67,11 +66,6 @@ class FakeServer extends Server { } @Override - public File getRootDir() { - return null; - } - - @Override public String getContextPath() { return null; } @@ -82,17 +76,8 @@ class FakeServer extends Server { } @Override - public boolean isDev() { - return false; - } - - @Override public boolean isSecured() { return false; } - @Override - public String getURL() { - return null; - } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/metric/ws/UserMetricsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/metric/ws/UserMetricsAction.java index 39ac920474a..6e2cec8030c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/metric/ws/UserMetricsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/metric/ws/UserMetricsAction.java @@ -22,11 +22,11 @@ package org.sonar.server.metric.ws; import java.util.Collection; import org.sonar.api.measures.Metric; import org.sonar.api.measures.Metric.ValueType; -import org.sonar.api.measures.MetricFinder; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.text.JsonWriter; +import org.sonar.server.metric.MetricFinder; public class UserMetricsAction implements MetricsWsAction { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UserMetricsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UserMetricsActionTest.java index e2c0c14bf5e..68caa6a557a 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UserMetricsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UserMetricsActionTest.java @@ -23,7 +23,7 @@ import com.google.common.collect.Lists; import org.junit.Test; import org.sonar.api.measures.Metric; import org.sonar.api.measures.Metric.ValueType; -import org.sonar.api.measures.MetricFinder; +import org.sonar.server.metric.MetricFinder; import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java index 013c619ea90..86a1ac178b6 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java @@ -19,7 +19,6 @@ */ package org.sonar.server.platform.ws; -import java.io.File; import java.util.Date; import java.util.Set; import org.junit.Test; @@ -187,11 +186,6 @@ public class StatusActionTest { } @Override - public File getRootDir() { - throw new UnsupportedOperationException(); - } - - @Override public String getContextPath() { throw new UnsupportedOperationException(); } @@ -202,21 +196,11 @@ public class StatusActionTest { } @Override - public boolean isDev() { - throw new UnsupportedOperationException(); - } - - @Override public boolean isSecured() { throw new UnsupportedOperationException(); } @Override - public String getURL() { - throw new UnsupportedOperationException(); - } - - @Override public String getPermanentServerId() { throw new UnsupportedOperationException(); } diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 75b374c1fc0..b210e24fa18 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -28,7 +28,6 @@ import org.sonar.alm.client.github.GithubApplicationClientImpl; import org.sonar.alm.client.github.GithubApplicationHttpClientImpl; import org.sonar.alm.client.github.security.GithubAppSecurityImpl; import org.sonar.alm.client.gitlab.GitlabHttpClient; -import org.sonar.api.profiles.AnnotationProfileParser; import org.sonar.api.profiles.XMLProfileParser; import org.sonar.api.profiles.XMLProfileSerializer; import org.sonar.api.resources.Languages; @@ -117,7 +116,7 @@ import org.sonar.server.measure.index.ProjectsEsModule; import org.sonar.server.measure.live.LiveMeasureModule; import org.sonar.server.measure.ws.MeasuresWsModule; import org.sonar.server.metric.CoreCustomMetrics; -import org.sonar.server.metric.DefaultMetricFinder; +import org.sonar.server.metric.MetricFinder; import org.sonar.server.metric.UnanalyzedLanguageMetrics; import org.sonar.server.metric.ws.MetricsWsModule; import org.sonar.server.newcodeperiod.ws.NewCodePeriodsWsModule; @@ -168,7 +167,6 @@ import org.sonar.server.qualitygate.notification.QGChangeNotificationHandler; import org.sonar.server.qualitygate.ws.QualityGateWsModule; import org.sonar.server.qualityprofile.BuiltInQPChangeNotificationHandler; import org.sonar.server.qualityprofile.BuiltInQPChangeNotificationTemplate; -import org.sonar.server.qualityprofile.BuiltInQProfileDefinitionsBridge; import org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl; import org.sonar.server.qualityprofile.QProfileBackuperImpl; import org.sonar.server.qualityprofile.QProfileComparison; @@ -276,12 +274,10 @@ public class PlatformLevel4 extends PlatformLevel { UpdateCenterModule.class, // quality profile - BuiltInQProfileDefinitionsBridge.class, BuiltInQProfileRepositoryImpl.class, ActiveRuleIndexer.class, XMLProfileParser.class, XMLProfileSerializer.class, - AnnotationProfileParser.class, QProfileComparison.class, QProfileTreeImpl.class, QProfileRulesImpl.class, @@ -330,7 +326,7 @@ public class PlatformLevel4 extends PlatformLevel { MeasuresWsModule.class, CustomMeasuresWsModule.class, CoreCustomMetrics.class, - DefaultMetricFinder.class, + MetricFinder.class, UnanalyzedLanguageMetrics.class, QualityGateModule.class, diff --git a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java index 2190c7f60f6..f71405004db 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java @@ -74,13 +74,11 @@ public final class IssueExclusionProperties { .name(PROPERTY_RULE_KEY_PATTERN) .description("Pattern to match rules which should be ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .name(PROPERTY_FILE_PATH_PATTERN) .description("Pattern to match files which should be ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -97,13 +95,11 @@ public final class IssueExclusionProperties { .name("Regular Expression for Start of Block") .description("If this regular expression is found in a file, then following lines are ignored until end of block.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(END_BLOCK_REGEXP) .name("Regular Expression for End of Block") .description("If specified, this regular expression is used to determine the end of code blocks to ignore. If not, then block ends at the end of file.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -119,7 +115,6 @@ public final class IssueExclusionProperties { .name("Regular Expression") .description("If this regular expression is found in a file, then the whole file is ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -135,16 +130,14 @@ public final class IssueExclusionProperties { .name(PROPERTY_RULE_KEY_PATTERN) .description("Pattern used to match rules which should be restricted.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .name(PROPERTY_FILE_PATH_PATTERN) .description("Pattern used to match files to which the rules should be restricted.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build() - ); + ); } } diff --git a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java index b902b1da811..41fa24cd5e0 100644 --- a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java +++ b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java @@ -20,13 +20,10 @@ package org.sonar.core.extension; import java.lang.annotation.Annotation; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import org.sonar.api.ExtensionProvider; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; import org.sonar.api.config.internal.MapSettings; @@ -74,8 +71,7 @@ public abstract class CoreExtensionsInstaller { private void install(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, CoreExtension coreExtension) { String coreExtensionName = coreExtension.getName(); try { - List<Object> providerKeys = addDeclaredExtensions(container, extensionFilter, additionalSideFilter, coreExtension); - addProvidedExtensions(container, additionalSideFilter, coreExtensionName, providerKeys); + addDeclaredExtensions(container, extensionFilter, additionalSideFilter, coreExtension); LOG.debug("Installed core extension: " + coreExtensionName); coreExtensionRepository.installed(coreExtension); @@ -84,32 +80,10 @@ public abstract class CoreExtensionsInstaller { } } - private List<Object> addDeclaredExtensions(ComponentContainer container, Predicate<Object> extensionFilter, + private void addDeclaredExtensions(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, CoreExtension coreExtension) { ContextImpl context = new ContextImpl(container, extensionFilter, additionalSideFilter, coreExtension.getName()); coreExtension.load(context); - return context.getProviders(); - } - - private void addProvidedExtensions(ComponentContainer container, Predicate<Object> additionalSideFilter, - String extensionCategory, List<Object> providerKeys) { - providerKeys.stream() - .map(providerKey -> (ExtensionProvider) container.getComponentByKey(providerKey)) - .forEach(provider -> addFromProvider(container, additionalSideFilter, extensionCategory, provider)); - } - - private void addFromProvider(ComponentContainer container, Predicate<Object> additionalSideFilter, - String extensionCategory, ExtensionProvider provider) { - Object obj = provider.provide(); - if (obj != null) { - if (obj instanceof Iterable) { - for (Object ext : (Iterable) obj) { - addSupportedExtension(container, additionalSideFilter, extensionCategory, ext); - } - } else { - addSupportedExtension(container, additionalSideFilter, extensionCategory, obj); - } - } } private <T> boolean addSupportedExtension(ComponentContainer container, Predicate<Object> additionalSideFilter, @@ -130,7 +104,6 @@ public abstract class CoreExtensionsInstaller { private final Predicate<Object> extensionFilter; private final Predicate<Object> additionalSideFilter; private final String extensionCategory; - private final List<Object> providers = new ArrayList<>(); public ContextImpl(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, String extensionCategory) { @@ -160,8 +133,6 @@ public abstract class CoreExtensionsInstaller { if (!addSupportedExtension(container, additionalSideFilter, extensionCategory, component)) { container.declareExtension(extensionCategory, component); - } else if (ExtensionProviderSupport.isExtensionProvider(component)) { - providers.add(component); } return this; } @@ -179,9 +150,5 @@ public abstract class CoreExtensionsInstaller { components.forEach(this::addExtension); return this; } - - public List<Object> getProviders() { - return providers; - } } } diff --git a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java b/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java index 82ca1d870bf..fa6809cc717 100644 --- a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java +++ b/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java @@ -19,17 +19,11 @@ */ package org.sonar.core.extension; -import org.sonar.api.ExtensionProvider; - public final class ExtensionProviderSupport { private ExtensionProviderSupport() { // prevents implementation } - public static boolean isExtensionProvider(Object extension) { - return isType(extension, ExtensionProvider.class) || extension instanceof ExtensionProvider; - } - private static boolean isType(Object extension, Class extensionClass) { Class clazz = extension instanceof Class ? (Class) extension : extension.getClass(); return extensionClass.isAssignableFrom(clazz); diff --git a/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java b/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java index 8f3d0e75773..9b21a33d1df 100644 --- a/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java @@ -40,7 +40,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mockito; import org.picocontainer.ComponentAdapter; -import org.sonar.api.ExtensionProvider; import org.sonar.api.Property; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; @@ -225,21 +224,6 @@ public class CoreExtensionsInstallerTest { assertPropertyDefinitions(container, coreExtension, propertyDefinitionNoCategory, propertyDefinitionWithCategory); } - @Test - @UseDataProvider("allMethodsToAddExtension") - public void install_adds_providers_to_container_and_install_extensions_they_provide_when_annotated_with_expected_annotation( - BiConsumer<CoreExtension.Context, Collection<Object>> extensionAdder) { - List<Object> extensions = ImmutableList.of(WestSideProvider.class, PartiallyWestSideProvider.class, EastSideProvider.class); - CoreExtension coreExtension = newCoreExtension(context -> extensionAdder.accept(context, extensions)); - when(coreExtensionRepository.loadedCoreExtensions()).thenReturn(Stream.of(coreExtension)); - ComponentContainer container = new ComponentContainer(); - - underTest.install(container, noExtensionFilter(), noAdditionalSideFilter()); - - assertAddedExtensions(container, WestSideProvider.class, WestSideProvided.class, PartiallyWestSideProvider.class); - assertPropertyDefinitions(container); - } - @DataProvider public static Object[][] allMethodsToAddExtension() { BiConsumer<CoreExtension.Context, Collection<Object>> addExtension = (context, objects) -> objects.forEach(context::addExtension); @@ -358,42 +342,6 @@ public class CoreExtensionsInstallerTest { } - @WestSide - public static class WestSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - return WestSideProvided.class; - } - } - - @WestSide - public static class WestSideProvided { - - } - - @WestSide - public static class PartiallyWestSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - return NotWestSideProvided.class; - } - } - - public static class NotWestSideProvided { - - } - - @EastSide - public static class EastSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - throw new IllegalStateException("EastSideProvider#provide should not be called"); - } - } - @Property(key = "westKey", name = "westName") @WestSide public static class WestSidePropertyDefinition { diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java index 34758d387e5..b513c8f55bf 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java @@ -25,7 +25,6 @@ import java.util.TreeMap; import javax.annotation.Nullable; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.coverage.CoverageType; import org.sonar.api.batch.sensor.coverage.NewCoverage; import org.sonar.api.batch.sensor.internal.DefaultStorable; import org.sonar.api.batch.sensor.internal.SensorStorage; @@ -36,7 +35,6 @@ import static org.sonar.api.utils.Preconditions.checkState; public class DefaultCoverage extends DefaultStorable implements NewCoverage { private InputFile inputFile; - private CoverageType type; private int totalCoveredLines = 0; private int totalConditions = 0; private int totalCoveredConditions = 0; @@ -63,16 +61,6 @@ public class DefaultCoverage extends DefaultStorable implements NewCoverage { } @Override - public NewCoverage ofType(CoverageType type) { - this.type = requireNonNull(type, "type can't be null"); - return this; - } - - public CoverageType type() { - return type; - } - - @Override public NewCoverage lineHits(int line, int hits) { validateFile(); if (isExcluded()) { diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java index 34a74bb2d40..84ca63f5586 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java @@ -76,18 +76,6 @@ public class DefaultHighlighting extends DefaultStorable implements NewHighlight } @Override - public DefaultHighlighting highlight(int startOffset, int endOffset, TypeOfText typeOfText) { - checkInputFileNotNull(); - TextRange newRange; - try { - newRange = inputFile.newRange(startOffset, endOffset); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to highlight file " + inputFile, e); - } - return highlight(newRange, typeOfText); - } - - @Override public DefaultHighlighting highlight(int startLine, int startLineOffset, int endLine, int endLineOffset, TypeOfText typeOfText) { checkInputFileNotNull(); TextRange newRange; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java index 29de3ad4ece..ee5ced6886b 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java @@ -96,17 +96,6 @@ public class DefaultSensorDescriptor implements SensorDescriptor { } @Override - public DefaultSensorDescriptor requireProperty(String... propertyKey) { - return requireProperties(propertyKey); - } - - @Override - public DefaultSensorDescriptor requireProperties(String... propertyKeys) { - this.configurationPredicate = config -> Arrays.stream(propertyKeys).allMatch(config::hasKey); - return this; - } - - @Override public SensorDescriptor global() { this.global = true; return this; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java index a79813f243f..87a820b06d3 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java @@ -74,18 +74,6 @@ public class DefaultSymbolTable extends DefaultStorable implements NewSymbolTabl } @Override - public NewSymbol newSymbol(int startOffset, int endOffset) { - checkInputFileNotNull(); - TextRange declarationRange; - try { - declarationRange = inputFile.newRange(startOffset, endOffset); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to create symbol on file " + inputFile, e); - } - return newSymbol(declarationRange); - } - - @Override public NewSymbol newSymbol(TextRange range) { checkInputFileNotNull(); TreeSet<TextRange> references = new TreeSet<>((o1, o2) -> o1.start().compareTo(o2.start())); @@ -106,17 +94,6 @@ public class DefaultSymbolTable extends DefaultStorable implements NewSymbolTabl } @Override - public NewSymbol newReference(int startOffset, int endOffset) { - TextRange referenceRange; - try { - referenceRange = inputFile.newRange(startOffset, endOffset); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to create symbol reference on file " + inputFile, e); - } - return newReference(referenceRange); - } - - @Override public NewSymbol newReference(int startLine, int startLineOffset, int endLine, int endLineOffset) { TextRange referenceRange; try { diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java index ecb2caacca8..90140b89905 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java @@ -30,7 +30,6 @@ import org.sonar.api.server.rule.RulesDefinition; import org.sonar.api.server.rule.internal.DefaultNewRepository; import org.sonar.api.server.rule.internal.DefaultRepository; -import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableList; import static org.sonar.api.utils.Preconditions.checkState; @@ -49,12 +48,6 @@ public class RulesDefinitionContext extends RulesDefinition.Context { } @Override - @Deprecated - public RulesDefinition.NewRepository extendRepository(String key, String language) { - return createRepository(key, language); - } - - @Override @CheckForNull public RulesDefinition.Repository repository(String key) { return repositoriesByKey.get(key); @@ -65,18 +58,6 @@ public class RulesDefinitionContext extends RulesDefinition.Context { return unmodifiableList(new ArrayList<>(repositoriesByKey.values())); } - @Override - @Deprecated - public List<RulesDefinition.ExtendedRepository> extendedRepositories(String repositoryKey) { - return emptyList(); - } - - @Override - @Deprecated - public List<RulesDefinition.ExtendedRepository> extendedRepositories() { - return emptyList(); - } - public void registerRepository(DefaultNewRepository newRepository) { RulesDefinition.Repository existing = repositoriesByKey.get(newRepository.key()); if (existing != null) { diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java index d042facca99..7a3c09c3a5b 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java @@ -34,7 +34,6 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.SensorStorage; import static org.sonar.api.batch.sensor.highlighting.TypeOfText.COMMENT; -import static org.sonar.api.batch.sensor.highlighting.TypeOfText.CPP_DOC; import static org.sonar.api.batch.sensor.highlighting.TypeOfText.KEYWORD; public class DefaultHighlightingTest { @@ -56,12 +55,12 @@ public class DefaultHighlightingTest { DefaultHighlighting highlightingDataBuilder = new DefaultHighlighting(Mockito.mock(SensorStorage.class)) .onFile(INPUT_FILE) - .highlight(0, 10, COMMENT) + .highlight(1, 0, 1, 10, COMMENT) .highlight(1, 10, 1, 12, KEYWORD) - .highlight(24, 38, KEYWORD) - .highlight(42, 50, KEYWORD) - .highlight(24, 65, CPP_DOC) - .highlight(12, 20, COMMENT); + .highlight(1, 24, 1, 38, KEYWORD) + .highlight(1, 42, 2, 0, KEYWORD) + .highlight(1, 24, 2, 15, COMMENT) + .highlight(1, 12, 1, 20, COMMENT); highlightingDataBuilder.save(); @@ -86,15 +85,15 @@ public class DefaultHighlightingTest { rangeOf(1, 24, 2, 15), rangeOf(1, 24, 1, 38), rangeOf(1, 42, 2, 0)); - Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, CPP_DOC, KEYWORD, KEYWORD); + Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, COMMENT, KEYWORD, KEYWORD); } @Test public void should_support_overlapping() { new DefaultHighlighting(Mockito.mock(SensorStorage.class)) .onFile(INPUT_FILE) - .highlight(0, 15, KEYWORD) - .highlight(8, 12, CPP_DOC) + .highlight(1, 0, 1, 15, KEYWORD) + .highlight(1, 8, 1, 12, COMMENT) .save(); } @@ -106,7 +105,7 @@ public class DefaultHighlightingTest { new DefaultHighlighting(Mockito.mock(SensorStorage.class)) .onFile(INPUT_FILE) - .highlight(10, 10, KEYWORD) + .highlight(1, 10, 1, 10, KEYWORD) .save(); } @@ -118,8 +117,8 @@ public class DefaultHighlightingTest { new DefaultHighlighting(Mockito.mock(SensorStorage.class)) .onFile(INPUT_FILE) - .highlight(0, 10, KEYWORD) - .highlight(8, 15, KEYWORD) + .highlight(1, 0, 1, 10, KEYWORD) + .highlight(1, 8, 1, 15, KEYWORD) .save(); } diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java index 719b042b277..ac6c72c24dd 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java @@ -34,7 +34,7 @@ public class DefaultSensorDescriptorTest { .name("Foo") .onlyOnLanguage("java") .onlyOnFileType(InputFile.Type.MAIN) - .requireProperty("sonar.foo.reportPath", "sonar.foo.reportPath2") + .onlyWhenConfiguration(c -> c.hasKey("sonar.foo.reportPath2") && c.hasKey("sonar.foo.reportPath")) .createIssuesForRuleRepository("squid-java"); assertThat(descriptor.name()).isEqualTo("Foo"); diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java index 62f5a7ffb67..7f9aa09466d 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java @@ -198,8 +198,8 @@ public class SensorContextTesterTest { tester.newHighlighting() .onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build()) .highlight(1, 0, 1, 5, TypeOfText.ANNOTATION) - .highlight(8, 10, TypeOfText.CONSTANT) - .highlight(9, 10, TypeOfText.COMMENT) + .highlight(1, 8, 1, 10, TypeOfText.CONSTANT) + .highlight(1, 9, 1, 10, TypeOfText.COMMENT) .save(); assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 3)).containsExactly(TypeOfText.ANNOTATION); assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 9)).containsExactly(TypeOfText.CONSTANT, TypeOfText.COMMENT); @@ -228,15 +228,15 @@ public class SensorContextTesterTest { symbolTable .newSymbol(1, 1, 1, 5) - .newReference(6, 9) .newReference(1, 10, 1, 13); symbolTable.save(); assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 0)).isNull(); assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 8)).isEmpty(); - assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3)).extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset").containsExactly(tuple(1, 6, 1, 9), - tuple(1, 10, 1, 13)); + assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3)) + .extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset") + .containsExactly(tuple(1, 10, 1, 13)); } @Test(expected = UnsupportedOperationException.class) diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java index 2aad9aeb42e..6db2e987d54 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java @@ -27,8 +27,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.TextRange; -import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.batch.fs.internal.TestInputFileBuilder; +import org.sonar.api.batch.sensor.internal.SensorStorage; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -53,11 +53,13 @@ public class DefaultSymbolTableTest { DefaultSymbolTable symbolTableBuilder = new DefaultSymbolTable(mock(SensorStorage.class)) .onFile(INPUT_FILE); symbolTableBuilder - .newSymbol(0, 10) - .newReference(12, 15) - .newReference(2, 10, 2, 15); + .newSymbol(1, 0, 1, 10) + .newReference(2, 10, 2, 15) + .newReference(1, 16, 1, 20); - symbolTableBuilder.newSymbol(1, 12, 1, 15).newReference(52, 55); + symbolTableBuilder + .newSymbol(1, 12, 1, 15) + .newReference(2, 1, 2, 5); symbolTableBuilder.save(); 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 b3ef7e3050e..9911d89b275 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 @@ -248,7 +248,7 @@ public interface CoreProperties { /** * This property defines the SonarQubeServer base url, such as <i>http://yourhost.yourdomain/sonar</i>. - * When this property is not set, the base url of the SonarQube server is provided by {@link Server#getURL()}. + * When this property is not set, the base url of the SonarQube server is provided by {@link Server#getPublicRootUrl()}. * * @since 2.10 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ExtensionProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/ExtensionProvider.java deleted file mode 100644 index 9db2573859e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ExtensionProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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; - -import org.sonar.api.ce.ComputeEngineSide; -import org.sonar.api.server.ServerSide; - -/** - * Factory of extensions. It allows to dynamically create extensions depending upon runtime context. One use-case is - * to create one rule repository by language. - * - * <p>Notes : - * <ul> - * <li>the provider is declared in Plugin.getExtensions()</li> - * <li>the provider must also add annotation {@link ServerSide}, {@link ComputeEngineSide} and/or {@link BatchSide}</li> - * <li>the provider can accept dependencies (parameters) in its constructors.</li> - * <li>the method provide() is executed once by the platform</li> - * <li>the method provide() must return an object, a class or an Iterable of objects. <strong>Arrays are excluded</strong>.</li> - * </ul> - * - * - * <p>Example: - * <pre> - * {@code - * {@literal @}ServerSide - * public class RuleRepositoryProvider extends ExtensionProvider { - * private Language[] languages; - * - * public RuleRepositoryProvider(Language[] languages) { - * this.languages = languages; - * } - * - * public List<RuleRepository> provide() { - * List<RuleRepository> result = new ArrayList<RuleRepository>(); - * for(Language language: languages) { - * result.add(new RuleRepository(..., language, ...)); - * } - * return result; - * } - * } - * } - * </pre> - * - * - * @since 2.3 - * @deprecated since 6.0 should no more be used - */ -@Deprecated -@ExtensionPoint -public abstract class ExtensionProvider { - - public abstract Object provide(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java index fc8258d2022..db7a16935a2 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java @@ -52,15 +52,6 @@ public @interface PropertyField { */ String description() default ""; - /** - * Indicative size of the field value in characters. This size is not validated, it is merely used by the GUI - * to size the different input fields of a property set. - * - * @deprecated since 6.1, as it was only used for UI. - */ - @Deprecated - int indicativeSize() default 20; - PropertyType type() default PropertyType.STRING; /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AnalysisMode.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AnalysisMode.java deleted file mode 100644 index 5397812fde1..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AnalysisMode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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; - -import org.sonarsource.api.sonarlint.SonarLintSide; - -/** - * Use this component to find the current running mode. - * @since 5.1 - * @deprecated since 7.3 preview mode deprecated since 6.6 - */ -@ScannerSide -@SonarLintSide -@Deprecated -public interface AnalysisMode { - boolean isPreview(); - - /** - * @since 5.2 - */ - boolean isIssues(); - - boolean isPublish(); - -} 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 27477366631..8a51f715955 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,8 +19,6 @@ */ package org.sonar.api.batch.postjob; -import org.sonar.api.batch.AnalysisMode; -import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.config.Configuration; /** @@ -34,29 +32,4 @@ public interface PostJobContext { * @since 6.5 */ Configuration config(); - - /** - * @deprecated since 7.3 preview mode deprecated since 6.6 - */ - @Deprecated - AnalysisMode analysisMode(); - - // ----------- Only available in preview mode -------------- - - /** - * All the unresolved issues of the project, including the issues reported by end-users. Only available in preview/issues mode. - * @throw {@link UnsupportedOperationException} if not in preview/issues mode. To test the mode you can use {@link #analysisMode()}. - * @deprecated since 7.3 the preview/issues mode is deprecated since 6.7 - */ - @Deprecated - Iterable<PostJobIssue> issues(); - - /** - * All the issues of this project that have been marked as resolved during this scan. Only available in preview/issues mode. - * @throw {@link UnsupportedOperationException} if not in preview mode. To test the mode you can use {@link #analysisMode()}. - * @deprecated since 7.3 the preview/issues mode is deprecated since 6.7 - */ - @Deprecated - Iterable<PostJobIssue> resolvedIssues(); - } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java index 82b2b2db482..360488d1085 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java @@ -112,14 +112,6 @@ public class Checks<C> { return addAnnotatedChecks((Iterable) Arrays.asList(checkClassesOrObjects)); } - /** - * @deprecated since 5.2 use {@link #addAnnotatedChecks(Iterable)} - */ - @Deprecated - public Checks<C> addAnnotatedChecks(Collection checkClassesOrObjects) { - return addAnnotatedChecks((Iterable) checkClassesOrObjects); - } - public Checks<C> addAnnotatedChecks(Iterable checkClassesOrObjects) { Map<String, Object> checksByEngineKey = new HashMap<>(); for (Object checkClassesOrObject : checkClassesOrObjects) { 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 4a95a52e6fc..97c6c61efc7 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 @@ -57,7 +57,6 @@ public interface SensorContext { */ @Deprecated Settings settings(); - /** * Get settings of the project. * @since 6.5 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 5c001e1ab93..0117afae923 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 @@ -71,22 +71,6 @@ public interface SensorDescriptor { SensorDescriptor createIssuesForRuleRepositories(String... repositoryKeys); /** - * Property this {@link Sensor} depends on. Used by the platform to skip execution of the {@link Sensor} when - * property is not set. - * @deprecated since 6.5 use {@link #onlyWhenConfiguration(Predicate)} - */ - @Deprecated - SensorDescriptor requireProperty(String... propertyKey); - - /** - * List properties this {@link Sensor} depends on. Used by the platform to skip execution of the {@link Sensor} when - * property is not set. - * @deprecated since 6.5 use {@link #onlyWhenConfiguration(Predicate)} - */ - @Deprecated - SensorDescriptor requireProperties(String... propertyKeys); - - /** * This sensor should be executed at the project level, instead of per-module. * @since 6.4 * @deprecated since 7.6 change your {@link Sensor} to a {@link ProjectSensor} instead 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 deleted file mode 100644 index a24b2e19844..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.coverage; - -/** - * Different coverage categories. - * @since 5.2 - * - * @deprecated since 6.2 SonarQube merge all coverage reports and don't keep track of different test category - */ -@Deprecated -public enum CoverageType { - - UNIT, - IT, - OVERALL - -} 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 4f40e9426be..aed416ea521 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 @@ -55,12 +55,6 @@ public interface NewCoverage { NewCoverage onFile(InputFile inputFile); /** - * @deprecated since 6.2 SonarQube merge all coverage reports and don't keep track of different test category - */ - @Deprecated - NewCoverage ofType(CoverageType type); - - /** * Call this method as many time as needed to report coverage hits per line. This method should only be called for executable lines. * @param line Line number (starts at 1). * @param hits Number of time the line was hit. 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 8e9263258fa..0f7de907ade 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 @@ -47,16 +47,6 @@ public interface NewHighlighting { /** * Call this method to indicate the type of text in a range. - * @param startOffset Starting position in file for this type of text. Beginning of a file starts with offset '0'. - * @param endOffset End position in file for this type of text. - * @param typeOfText see {@link TypeOfText} values. - * @deprecated since 5.6 Only supported to ease migration from old API. Please prefer other {@code highlight()} methods. - */ - @Deprecated - NewHighlighting highlight(int startOffset, int endOffset, TypeOfText typeOfText); - - /** - * Call this method to indicate the type of text in a range. * @param range Range of text to highlight. See for example {@link InputFile#newRange(int, int, int, int)}. * @param typeOfText see {@link TypeOfText} values. * @since 5.6 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 40e800cfa53..7a2d0bc9e72 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 @@ -27,11 +27,7 @@ public enum TypeOfText { ANNOTATION("a"), CONSTANT("c"), COMMENT("cd"), - /** - * @deprecated use {@link #COMMENT} - */ - @Deprecated - CPP_DOC("cppd"), + /** * For example Javadoc */ 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 22077458384..480c668d856 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 @@ -27,16 +27,6 @@ import org.sonar.api.batch.fs.TextRange; * @since 5.6 */ public interface NewSymbol { - - /** - * Register a new symbol reference. - * @param startOffset Starting position in file for the declaration of this symbol. Beginning of a file starts with offset '0'. - * @param endOffset End position in file for this symbol declaration. - * @deprecated since 6.1 Only supported to ease migration from old API. Please prefer other {@code newReference()} methods. - */ - @Deprecated - NewSymbol newReference(int startOffset, int endOffset); - /** * Register a new symbol. * @param range Range of text for the symbol declaration. See for example {@link InputFile#newRange(int, int, int, int)}. 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 f61965eb410..2d2d851ee2b 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 @@ -50,15 +50,6 @@ public interface NewSymbolTable { /** * Register a new symbol declaration. - * @param startOffset Starting position in file for the declaration of this symbol. Beginning of a file starts with offset '0'. - * @param endOffset End position in file for this symbol declaration. - * @deprecated since 5.6 Only supported to ease migration from old API. Please prefer {@link #newSymbol(int, int, int, int)}. - */ - @Deprecated - NewSymbol newSymbol(int startOffset, int endOffset); - - /** - * Register a new symbol declaration. * @param range Range of text for the symbol declaration. See for example {@link InputFile#newRange(int, int, int, int)}. */ NewSymbol newSymbol(TextRange range); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/Perspective.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/Perspective.java deleted file mode 100644 index 146f63a9275..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/Perspective.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.component; - -/** - * @deprecated since 5.2 - */ -@Deprecated -public interface Perspective { -} 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 deleted file mode 100644 index 1f313aebac6..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.component; - -import javax.annotation.CheckForNull; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputPath; -import org.sonar.api.batch.sensor.SensorContext; - -/** - * @since 3.5 - * @deprecated since 5.6 all features are available on {@link SensorContext} - */ -@Deprecated -public interface ResourcePerspectives { - - /** - * Allow to create perspective from {@link InputPath}. In particular from {@link InputFile}. - * - * @since 4.5.2 - */ - @CheckForNull <P extends Perspective> P as(Class<P> perspectiveClass, InputPath inputPath); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/package-info.java deleted file mode 100644 index 4d16a11fe39..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/component/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.api.component; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java index da3f1cc1c8c..c5870c1eba7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java @@ -28,7 +28,6 @@ import java.util.Set; import java.util.function.Function; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import java.util.stream.Stream; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; @@ -42,7 +41,6 @@ import org.sonar.api.server.ServerSide; import org.sonarsource.api.sonarlint.SonarLintSide; import static java.util.Arrays.asList; -import static java.util.Arrays.stream; import static java.util.Collections.unmodifiableSet; import static java.util.Objects.requireNonNull; import static org.apache.commons.lang.StringUtils.isBlank; @@ -110,7 +108,6 @@ public final class PropertyDefinition { private List<String> qualifiers; private boolean global; private boolean multiValues; - private String propertySetKey; private String deprecatedKey; private List<PropertyFieldDefinition> fields; /** @@ -130,7 +127,6 @@ public final class PropertyDefinition { this.type = builder.type; this.options = builder.options; this.multiValues = builder.multiValues; - this.propertySetKey = builder.propertySetKey; this.fields = builder.fields; this.deprecatedKey = builder.deprecatedKey; this.qualifiers = builder.onQualifiers; @@ -155,7 +151,6 @@ public final class PropertyDefinition { .type(annotation.type()) .options(asList(annotation.options())) .multiValues(annotation.multiValues()) - .propertySetKey(annotation.propertySetKey()) .fields(PropertyFieldDefinition.create(annotation.fields())) .deprecatedKey(annotation.deprecatedKey()); List<String> qualifiers = new ArrayList<>(); @@ -312,14 +307,6 @@ public final class PropertyDefinition { return multiValues; } - /** - * @deprecated since 6.1, as it was not used and too complex to maintain. - */ - @Deprecated - public String propertySetKey() { - return propertySetKey; - } - public List<PropertyFieldDefinition> fields() { return fields; } @@ -338,10 +325,7 @@ public final class PropertyDefinition { @Override public String toString() { - if (isEmpty(propertySetKey)) { - return key; - } - return new StringBuilder().append(propertySetKey).append('|').append(key).toString(); + return key; } public static final class Result { @@ -386,7 +370,6 @@ public final class PropertyDefinition { private PropertyType type = PropertyType.STRING; private List<String> options = new ArrayList<>(); private boolean multiValues = false; - private String propertySetKey = ""; private List<PropertyFieldDefinition> fields = new ArrayList<>(); private String deprecatedKey = ""; private boolean hidden = false; @@ -552,15 +535,6 @@ public final class PropertyDefinition { return this; } - /** - * @deprecated since 6.1, as it was not used and too complex to maintain. - */ - @Deprecated - public Builder propertySetKey(String propertySetKey) { - this.propertySetKey = propertySetKey; - return this; - } - public Builder fields(PropertyFieldDefinition first, PropertyFieldDefinition... rest) { this.fields.add(first); this.fields.addAll(asList(rest)); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java index c22b458ba57..8233148f96a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java @@ -36,7 +36,6 @@ public final class PropertyFieldDefinition { private final String key; private final String name; private final String description; - private final int indicativeSize; private final PropertyType type; private final List<String> options; @@ -44,7 +43,6 @@ public final class PropertyFieldDefinition { this.key = builder.key; this.name = builder.name; this.description = builder.description; - this.indicativeSize = builder.indicativeSize; this.type = builder.type; this.options = builder.options; } @@ -55,7 +53,6 @@ public final class PropertyFieldDefinition { definitions.add(PropertyFieldDefinition.build(field.key()) .name(field.name()) .description(field.description()) - .indicativeSize(field.indicativeSize()) .type(field.type()) .options(field.options()) .build()); @@ -79,14 +76,6 @@ public final class PropertyFieldDefinition { return description; } - /** - * @deprecated since 6.1, as it was only used for UI. - */ - @Deprecated - public int indicativeSize() { - return indicativeSize; - } - public PropertyType type() { return type; } @@ -103,7 +92,6 @@ public final class PropertyFieldDefinition { private String key; private String name; private String description; - private int indicativeSize; private PropertyType type; private List<String> options; @@ -111,7 +99,6 @@ public final class PropertyFieldDefinition { this.key = key; this.name = ""; this.description = ""; - this.indicativeSize = 20; this.type = PropertyType.STRING; this.options = new ArrayList<>(); } @@ -126,15 +113,6 @@ public final class PropertyFieldDefinition { return this; } - /** - * @deprecated since 6.1, as it was only used for UI. - */ - @Deprecated - public Builder indicativeSize(int indicativeSize) { - this.indicativeSize = indicativeSize; - return this; - } - public Builder type(PropertyType type) { this.type = type; return this; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java deleted file mode 100644 index 1bb809f57da..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measures; - -import java.util.Collection; -import java.util.List; -import javax.annotation.CheckForNull; -import org.sonar.api.scanner.ScannerSide; -import org.sonar.api.ce.ComputeEngineSide; -import org.sonar.api.server.ServerSide; - -/** - * @since 2.5 - * @deprecated since 5.1 use {@link org.sonar.api.batch.measure.MetricFinder} on scanner side. - */ -@Deprecated -@ScannerSide -@ServerSide -@ComputeEngineSide -public interface MetricFinder { - - @CheckForNull - Metric findByUuid(String uuid); - - @CheckForNull - Metric findByKey(String key); - - Collection<Metric> findAll(List<String> metricKeys); - - Collection<Metric> findAll(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java index 856c9236864..ed512c862c7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java @@ -70,13 +70,6 @@ public abstract class Server { public abstract Date getStartedAt(); /** - * @deprecated in 6.0. Replaced by {@link ServerFileSystem#getHomeDir()} - * @return an existing directory in server and CE environments, {@code null} in scanner. - */ - @Deprecated - public abstract File getRootDir(); - - /** * Context path of web server. Value is blank {@code ""} by default. When defined by * the property {@code sonar.web.context} of conf/sonar.properties, then value starts but does * not end with slash {@code '/'}, for instance {@code "/sonarqube"}. @@ -93,15 +86,6 @@ public abstract class Server { public abstract String getPublicRootUrl(); /** - * Before version 6.6, the dev mode is enabled when the property {@code sonar.web.dev} is {@code true}. - * Since 6.6, {@code false} is always returned. - * @deprecated in 6.6 - * @since 5.4 - */ - @Deprecated - public abstract boolean isDev(); - - /** * Return whether or not the {#getPublicRootUrl} is started with https. * * @since 5.4 @@ -109,12 +93,4 @@ public abstract class Server { */ @Deprecated public abstract boolean isSecured(); - - /** - * @return the server URL - * @since since 2.4 on batch side only, since 5.6 on both batch side and server side (WebServer and Compute Engine) - * @deprecated since 6.5, please use {@link #getPublicRootUrl()} instead - */ - @Deprecated - public abstract String getURL(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java deleted file mode 100644 index ab6e1acec56..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.profiles; - -import java.util.Collection; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.ce.ComputeEngineSide; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleAnnotationUtils; -import org.sonar.api.rules.RuleFinder; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.server.ServerSide; -import org.sonar.api.server.profile.BuiltInQualityProfileAnnotationLoader; -import org.sonar.api.utils.ValidationMessages; -import org.sonar.check.BelongsToProfile; - -/** - * @since 2.3 - * @deprecated since 6.6 use {@link BuiltInQualityProfileAnnotationLoader} - */ -@ServerSide -@ComputeEngineSide -@Deprecated -public final class AnnotationProfileParser { - - private final RuleFinder ruleFinder; - - public AnnotationProfileParser(RuleFinder ruleFinder) { - this.ruleFinder = ruleFinder; - } - - public RulesProfile parse(String repositoryKey, String profileName, String language, Collection<Class> annotatedClasses, ValidationMessages messages) { - RulesProfile profile = RulesProfile.create(profileName, language); - for (Class<?> aClass : annotatedClasses) { - BelongsToProfile belongsToProfile = aClass.getAnnotation(BelongsToProfile.class); - addRule(aClass, belongsToProfile, profile, repositoryKey, messages); - } - return profile; - } - - private void addRule(Class aClass, BelongsToProfile annotation, RulesProfile profile, String repositoryKey, ValidationMessages messages) { - if ((annotation != null) && StringUtils.equals(annotation.title(), profile.getName())) { - String ruleKey = RuleAnnotationUtils.getRuleKey(aClass); - Rule rule = ruleFinder.findByKey(repositoryKey, ruleKey); - if (rule == null) { - messages.addWarningText("Rule not found: [repository=" + repositoryKey + ", key=" + ruleKey + "]"); - - } else { - RulePriority priority = null; - if (annotation.priority() != null) { - priority = RulePriority.fromCheckPriority(annotation.priority()); - } - profile.activateRule(rule, priority); - } - } - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileDefinition.java deleted file mode 100644 index 893b2bf0eec..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileDefinition.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.profiles; - -import org.sonar.api.ExtensionPoint; -import org.sonar.api.server.ServerSide; -import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; -import org.sonar.api.utils.ValidationMessages; - -/** - * Define a profile which is automatically registered during sonar startup. - * The components <code>AnnotationProfileParser</code> and <code>XMLProfileParser</code> can be used to help implementing the method create(). - * - * @since 2.3 - * @deprecated since 6.6 use {@link BuiltInQualityProfilesDefinition} - */ -@ServerSide -@ExtensionPoint -@Deprecated -public abstract class ProfileDefinition { - - public abstract RulesProfile createProfile(ValidationMessages validation); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java index dce5f21559e..c7d408b6d19 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java @@ -36,28 +36,6 @@ import org.sonar.api.utils.MessageException; * This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too. */ public class RulesProfile implements Cloneable { - - /** - * Name of the default profile "Sonar Way" - * @deprecated in 4.2. Use your own constant. - */ - @Deprecated - public static final String SONAR_WAY_NAME = "Sonar way"; - - /** - * Name of the default java profile "Sonar way with Findbugs" - * @deprecated in 4.2. Use your own constant. - */ - @Deprecated - public static final String SONAR_WAY_FINDBUGS_NAME = "Sonar way with Findbugs"; - - /** - * Name of the default java profile "Sun checks" - * @deprecated in 4.2. Use your own constant. - */ - @Deprecated - public static final String SUN_CONVENTIONS_NAME = "Sun checks"; - private String name; private Boolean defaultProfile = Boolean.FALSE; private String language; @@ -213,28 +191,6 @@ public class RulesProfile implements Cloneable { } /** - * Does nothing. - * - * @return {@code null} - * @deprecated in 6.5 - */ - @Deprecated - @CheckForNull - public String getParentName() { - return null; - } - - /** - * Does nothing. - * - * @deprecated in 6.5 - */ - @Deprecated - public void setParentName(String parentName) { - // does nothing - } - - /** * Note: disabled rules are excluded. * * @return the list of active rules for a given severity diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java index ff6b5250357..698c039d06b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java @@ -20,10 +20,8 @@ package org.sonar.api.rules; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; @@ -139,22 +137,6 @@ public class ActiveRule implements Cloneable { this.severity = severity; } - /** - * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.sonarsource.com/browse/SONAR-1829 - */ - @Deprecated - public RulePriority getPriority() { - return severity; - } - - /** - * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.sonarsource.com/browse/SONAR-1829 - */ - @Deprecated - public void setPriority(RulePriority priority) { - this.severity = priority; - } - public RulesProfile getRulesProfile() { return rulesProfile; } @@ -224,46 +206,6 @@ public class ActiveRule implements Cloneable { return rule.getKey(); } - /** - * @since 4.2 - * @deprecated in 4.4. Feature dropped. - */ - @CheckForNull - @Deprecated - public String getNoteData() { - return null; - } - - /** - * @since 4.2 - * @deprecated in 4.4. Feature dropped. - */ - @CheckForNull - @Deprecated - public String getNoteUserLogin() { - return null; - } - - /** - * @since 4.2 - * @deprecated in 4.4. Feature dropped. - */ - @CheckForNull - @Deprecated - public Date getNoteCreatedAt() { - return null; - } - - /** - * @since 4.2 - * @deprecated in 4.4. Feature dropped. - */ - @CheckForNull - @Deprecated - public Date getNoteUpdatedAt() { - return null; - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java index 67e2584c93e..321869833af 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java @@ -397,52 +397,6 @@ public class Rule { return this; } - /** - * For internal use only. - * - * @since 4.3 - * @deprecated since 4.4, use {@link #getCharacteristicKey()} - */ - @CheckForNull - @Deprecated - public Integer getCharacteristicId() { - return null; - } - - /** - * For internal use only. - * - * @since 4.3 - * @deprecated since 4.4, use {@link #setCharacteristicKey(String)} - */ - @Deprecated - public Rule setCharacteristicId(@Nullable Integer characteristicId) { - return this; - } - - /** - * For internal use only. - * - * @since 4.3 - * @deprecated since 4.4, use {@link #getDefaultCharacteristicKey()} - */ - @CheckForNull - @Deprecated - public Integer getDefaultCharacteristicId() { - return null; - } - - /** - * For internal use only. - * - * @since 4.3 - * @deprecated since 4.4, use {@link #setDefaultCharacteristicKey(String)} - */ - @Deprecated - public Rule setDefaultCharacteristicId(@Nullable Integer defaultCharacteristicId) { - return this; - } - @Override public boolean equals(Object obj) { if (!(obj instanceof Rule)) { @@ -518,79 +472,4 @@ public class Rule { return RuleKey.of(getRepositoryKey(), getKey()); } - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @CheckForNull - @Deprecated - public String getDefaultCharacteristicKey() { - return null; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @Deprecated - public Rule setDefaultCharacteristicKey(@Nullable String defaultCharacteristicKey) { - return this; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @CheckForNull - @Deprecated - public String getDefaultSubCharacteristicKey() { - return null; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @Deprecated - public Rule setDefaultSubCharacteristicKey(@Nullable String defaultSubCharacteristicKey) { - return this; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @CheckForNull - @Deprecated - public String getCharacteristicKey() { - return null; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @Deprecated - public Rule setCharacteristicKey(@Nullable String characteristicKey) { - return this; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @CheckForNull - @Deprecated - public String getSubCharacteristicKey() { - return null; - } - - /** - * @since 4.4 - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - */ - @Deprecated - public Rule setSubCharacteristicKey(@Nullable String subCharacteristicKey) { - return this; - } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java index e101296cec3..eb83eba50bd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java @@ -20,6 +20,7 @@ package org.sonar.api.security; import java.util.Collection; +import javax.annotation.CheckForNull; import javax.servlet.http.HttpServletRequest; /** @@ -31,24 +32,15 @@ import javax.servlet.http.HttpServletRequest; public abstract class ExternalGroupsProvider { /** - * @return list of groups associated with specified user, or null if such user doesn't exist - * @throws RuntimeException in case of unexpected error such as connection failure - * @deprecated replaced by {@link #doGetGroups(org.sonar.api.security.ExternalGroupsProvider.Context)} since v. 5.2 - */ - @Deprecated - public Collection<String> doGetGroups(String username) { - return null; - } - - /** * Override this method in order to load user group information. * * @return list of groups associated with specified user, or null if such user doesn't exist * @throws RuntimeException in case of unexpected error such as connection failure * @since 5.2 */ + @CheckForNull public Collection<String> doGetGroups(Context context) { - return doGetGroups(context.getUsername()); + return null; } public static final class Context { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalUsersProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalUsersProvider.java index 78db7a119e2..de353cea13c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalUsersProvider.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalUsersProvider.java @@ -29,20 +29,6 @@ import javax.servlet.http.HttpServletRequest; * @since 2.14 */ public abstract class ExternalUsersProvider { - - /** - * This method is overridden by old versions of plugins such as LDAP 1.1. It should not be overridden anymore. - * - * @param username the username - * @return details for specified user, or null if such user doesn't exist - * @throws RuntimeException in case of unexpected error such as connection failure - * @deprecated replaced by {@link #doGetUserDetails(org.sonar.api.security.ExternalUsersProvider.Context)} since v. 3.1 - */ - @Deprecated - public UserDetails doGetUserDetails(@Nullable String username) { - return null; - } - /** * Override this method in order load user information. * @@ -51,7 +37,7 @@ public abstract class ExternalUsersProvider { * @since 3.1 */ public UserDetails doGetUserDetails(Context context) { - return doGetUserDetails(context.getUsername()); + return null; } public static final class Context { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java index d7d1afd3eb6..9e63f079bad 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java @@ -72,14 +72,6 @@ public interface DebtRemediationFunction { } /** - * @deprecated since 5.5, replaced by {@link #usesGapMultiplier()} - */ - @Deprecated - public boolean usesCoefficient() { - return usesGapMultiplier(); - } - - /** * @since 5.5 */ public boolean usesGapMultiplier() { @@ -87,14 +79,6 @@ public interface DebtRemediationFunction { } /** - * @deprecated since 5.5, replaced by {@link #usesBaseEffort()} - */ - @Deprecated - public boolean usesOffset() { - return usesBaseEffort(); - } - - /** * @since 5.5 */ public boolean usesBaseEffort() { @@ -109,13 +93,6 @@ public interface DebtRemediationFunction { Type type(); /** - * @deprecated since 5.5, replaced by {@link #gapMultiplier()} - */ - @Deprecated - @CheckForNull - String coefficient(); - - /** * Non-null value on {@link Type#LINEAR} and {@link Type#LINEAR_OFFSET} functions, else {@code null}. * * @since 5.5 @@ -124,13 +101,6 @@ public interface DebtRemediationFunction { String gapMultiplier(); /** - * @deprecated since 5.5, replaced by {@link #baseEffort()} - */ - @Deprecated - @CheckForNull - String offset(); - - /** * Non-null value on {@link Type#LINEAR_OFFSET} and {@link Type#CONSTANT_ISSUE} functions, else {@code null}. * * @since 5.5 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java index 660be9f01e0..c97ed0dfbc4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java @@ -61,32 +61,12 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction { return type; } - /** - * @deprecated since 5.5, replaced by {@link #gapMultiplier} - */ - @Override - @CheckForNull - @Deprecated - public String coefficient() { - return gapMultiplier(); - } - @Override @CheckForNull public String gapMultiplier() { return gapMultiplier; } - /** - * @deprecated since 5.5, replaced by {@link #baseEffort} - */ - @Override - @CheckForNull - @Deprecated - public String offset() { - return baseEffort(); - } - @Override public String baseEffort() { return baseEffort; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 7c79672c5c4..82b7e3d6f11 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -41,7 +41,6 @@ import org.sonar.api.server.rule.internal.DefaultNewRepository; import org.sonar.api.server.rule.internal.DefaultRepository; import org.sonarsource.api.sonarlint.SonarLintSide; -import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableList; import static org.sonar.api.utils.Preconditions.checkState; @@ -129,230 +128,6 @@ import static org.sonar.api.utils.Preconditions.checkState; @SonarLintSide @ExtensionPoint public interface RulesDefinition { - - /** - * Default sub-characteristics of technical debt model. See http://www.sqale.org - * - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. - * See https://jira.sonarsource.com/browse/MMF-184 - */ - @Deprecated - final class SubCharacteristics { - /** - * Related to characteristic REUSABILITY - */ - public static final String MODULARITY = "MODULARITY"; - - /** - * Related to characteristic REUSABILITY - */ - public static final String TRANSPORTABILITY = "TRANSPORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String COMPILER_RELATED_PORTABILITY = "COMPILER_RELATED_PORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String HARDWARE_RELATED_PORTABILITY = "HARDWARE_RELATED_PORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String LANGUAGE_RELATED_PORTABILITY = "LANGUAGE_RELATED_PORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String OS_RELATED_PORTABILITY = "OS_RELATED_PORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String SOFTWARE_RELATED_PORTABILITY = "SOFTWARE_RELATED_PORTABILITY"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String TIME_ZONE_RELATED_PORTABILITY = "TIME_ZONE_RELATED_PORTABILITY"; - - /** - * Related to characteristic MAINTAINABILITY - */ - public static final String READABILITY = "READABILITY"; - - /** - * Related to characteristic MAINTAINABILITY - */ - public static final String UNDERSTANDABILITY = "UNDERSTANDABILITY"; - - /** - * Related to characteristic SECURITY - */ - public static final String API_ABUSE = "API_ABUSE"; - - /** - * Related to characteristic SECURITY - */ - public static final String ERRORS = "ERRORS"; - - /** - * Related to characteristic SECURITY - */ - public static final String INPUT_VALIDATION_AND_REPRESENTATION = "INPUT_VALIDATION_AND_REPRESENTATION"; - - /** - * Related to characteristic SECURITY - */ - public static final String SECURITY_FEATURES = "SECURITY_FEATURES"; - - /** - * Related to characteristic EFFICIENCY - */ - public static final String CPU_EFFICIENCY = "CPU_EFFICIENCY"; - - /** - * Related to characteristic EFFICIENCY - */ - public static final String MEMORY_EFFICIENCY = "MEMORY_EFFICIENCY"; - - /** - * Related to characteristic EFFICIENCY - */ - public static final String NETWORK_USE = "NETWORK_USE"; - - /** - * Related to characteristic CHANGEABILITY - */ - public static final String ARCHITECTURE_CHANGEABILITY = "ARCHITECTURE_CHANGEABILITY"; - - /** - * Related to characteristic CHANGEABILITY - */ - public static final String DATA_CHANGEABILITY = "DATA_CHANGEABILITY"; - - /** - * Related to characteristic CHANGEABILITY - */ - public static final String LOGIC_CHANGEABILITY = "LOGIC_CHANGEABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String ARCHITECTURE_RELIABILITY = "ARCHITECTURE_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String DATA_RELIABILITY = "DATA_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String EXCEPTION_HANDLING = "EXCEPTION_HANDLING"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String FAULT_TOLERANCE = "FAULT_TOLERANCE"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String INSTRUCTION_RELIABILITY = "INSTRUCTION_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String LOGIC_RELIABILITY = "LOGIC_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String RESOURCE_RELIABILITY = "RESOURCE_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String SYNCHRONIZATION_RELIABILITY = "SYNCHRONIZATION_RELIABILITY"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String UNIT_TESTS = "UNIT_TESTS"; - - /** - * Related to characteristic TESTABILITY - */ - public static final String INTEGRATION_TESTABILITY = "INTEGRATION_TESTABILITY"; - - /** - * Related to characteristic TESTABILITY - */ - public static final String UNIT_TESTABILITY = "UNIT_TESTABILITY"; - - /** - * Related to characteristic ACCESSIBILITY - */ - public static final String USABILITY_ACCESSIBILITY = "USABILITY_ACCESSIBILITY"; - - /** - * Related to characteristic ACCESSIBILITY - */ - public static final String USABILITY_COMPLIANCE = "USABILITY_COMPLIANCE"; - - /** - * Related to characteristic ACCESSIBILITY - */ - public static final String USABILITY_EASE_OF_USE = "USABILITY_EASE_OF_USE"; - - /** - * Related to characteristic REUSABILITY - */ - public static final String REUSABILITY_COMPLIANCE = "REUSABILITY_COMPLIANCE"; - - /** - * Related to characteristic PORTABILITY - */ - public static final String PORTABILITY_COMPLIANCE = "PORTABILITY_COMPLIANCE"; - - /** - * Related to characteristic MAINTAINABILITY - */ - public static final String MAINTAINABILITY_COMPLIANCE = "MAINTAINABILITY_COMPLIANCE"; - - /** - * Related to characteristic SECURITY - */ - public static final String SECURITY_COMPLIANCE = "SECURITY_COMPLIANCE"; - - /** - * Related to characteristic EFFICIENCY - */ - public static final String EFFICIENCY_COMPLIANCE = "EFFICIENCY_COMPLIANCE"; - - /** - * Related to characteristic CHANGEABILITY - */ - public static final String CHANGEABILITY_COMPLIANCE = "CHANGEABILITY_COMPLIANCE"; - - /** - * Related to characteristic RELIABILITY - */ - public static final String RELIABILITY_COMPLIANCE = "RELIABILITY_COMPLIANCE"; - - /** - * Related to characteristic TESTABILITY - */ - public static final String TESTABILITY_COMPLIANCE = "TESTABILITY_COMPLIANCE"; - - private SubCharacteristics() { - // only constants - } - } - /** * This implementation will be removed as soon as analyzers stop instantiating it. * Use RulesDefinitionContext in sonar-plugin-api-impl. @@ -372,12 +147,6 @@ public interface RulesDefinition { } @Override - @Deprecated - public RulesDefinition.NewRepository extendRepository(String key, String language) { - return createRepository(key, language); - } - - @Override @CheckForNull public RulesDefinition.Repository repository(String key) { return repositoriesByKey.get(key); @@ -388,18 +157,6 @@ public interface RulesDefinition { return unmodifiableList(new ArrayList<>(repositoriesByKey.values())); } - @Override - @Deprecated - public List<RulesDefinition.ExtendedRepository> extendedRepositories(String repositoryKey) { - return emptyList(); - } - - @Override - @Deprecated - public List<RulesDefinition.ExtendedRepository> extendedRepositories() { - return emptyList(); - } - public void registerRepository(DefaultNewRepository newRepository) { RulesDefinition.Repository existing = repositoriesByKey.get(newRepository.key()); if (existing != null) { @@ -442,31 +199,11 @@ public interface RulesDefinition { */ public abstract NewRepository createExternalRepository(String engineId, String language); - /** - * @deprecated since 5.2. Simply use {@link #createRepository(String, String)} - */ - @Deprecated - public abstract NewRepository extendRepository(String key, String language); - @CheckForNull public abstract Repository repository(String key); public abstract List<Repository> repositories(); - /** - * @deprecated returns empty list since 5.2. Concept of "extended repository" was misleading and not valuable. Simply declare - * repositories and use {@link #repositories()}. See http://jira.sonarsource.com/browse/SONAR-6709 - */ - @Deprecated - public abstract List<ExtendedRepository> extendedRepositories(String repositoryKey); - - /** - * @deprecated returns empty list since 5.2. Concept of "extended repository" was misleading and not valuable. Simply declare - * repositories and use {@link #repositories()}. See http://jira.sonarsource.com/browse/SONAR-6709 - */ - @Deprecated - public abstract List<ExtendedRepository> extendedRepositories(); - public abstract void setCurrentPluginKey(@Nullable String pluginKey); } @@ -640,17 +377,6 @@ public interface RulesDefinition { public abstract NewRule setStatus(RuleStatus status); /** - * SQALE sub-characteristic. See http://www.sqale.org - * - * @see org.sonar.api.server.rule.RulesDefinition.SubCharacteristics for constant values - * @see #setType(RuleType) - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. This method does nothing. - * See https://jira.sonarsource.com/browse/MMF-184 - */ - @Deprecated - public abstract NewRule setDebtSubCharacteristic(@Nullable String s); - - /** * Factory of {@link org.sonar.api.server.debt.DebtRemediationFunction} */ public abstract DebtRemediationFunctions debtRemediationFunctions(); @@ -661,12 +387,6 @@ public interface RulesDefinition { public abstract NewRule setDebtRemediationFunction(@Nullable DebtRemediationFunction fn); /** - * @deprecated since 5.5, replaced by {@link #setGapDescription(String)} - */ - @Deprecated - public abstract NewRule setEffortToFixDescription(@Nullable String s); - - /** * For rules that use LINEAR or LINEAR_OFFSET remediation functions, the meaning * of the function parameter (= "gap") must be set. This description * explains what 1 point of "gap" represents for the rule. @@ -772,25 +492,9 @@ public interface RulesDefinition { public abstract RuleStatus status(); - /** - * @see #type() - * @deprecated in 5.5. SQALE Quality Model is replaced by SonarQube Quality Model. {@code null} is - * always returned. See https://jira.sonarsource.com/browse/MMF-184 - */ - @CheckForNull - @Deprecated - public abstract String debtSubCharacteristic(); - @CheckForNull public abstract DebtRemediationFunction debtRemediationFunction(); - /** - * @deprecated since 5.5, replaced by {@link #gapDescription()} - */ - @Deprecated - @CheckForNull - public abstract String effortToFixDescription(); - @CheckForNull public abstract String gapDescription(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java index 22761952985..2f3397736cb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java @@ -130,25 +130,25 @@ import static org.apache.commons.lang.StringUtils.trim; * * <!-- Quality Model - type of debt remediation function --> * <!-- See enum {@link org.sonar.api.server.debt.DebtRemediationFunction.Type} for supported values --> - * <!-- It was previously named 'debtRemediationFunction' which is still supported but deprecated since 5.5 --> + * <!-- It was previously named 'debtRemediationFunction'. --> * <!-- Since 5.5 --> * <remediationFunction>LINEAR_OFFSET</remediationFunction> * * <!-- Quality Model - raw description of the "gap", used for some types of remediation functions. --> * <!-- See {@link org.sonar.api.server.rule.RulesDefinition.NewRule#setGapDescription(String)} --> - * <!-- It was previously named 'effortToFixDescription' which is still supported but deprecated since 5.5 --> + * <!-- It was previously named 'effortToFixDescription'. --> * <!-- Since 5.5 --> * <gapDescription>Effort to test one uncovered condition</gapFixDescription> * * <!-- Quality Model - gap multiplier of debt remediation function. Must be defined only for some function types. --> * <!-- See {@link org.sonar.api.server.rule.RulesDefinition.DebtRemediationFunctions} --> - * <!-- It was previously named 'debtRemediationFunctionCoefficient' which is still supported but deprecated since 5.5 --> + * <!-- It was previously named 'debtRemediationFunctionCoefficient'. --> * <!-- Since 5.5 --> * <remediationFunctionGapMultiplier>10min</remediationFunctionGapMultiplier> * * <!-- Quality Model - base effort of debt remediation function. Must be defined only for some function types. --> * <!-- See {@link org.sonar.api.server.rule.RulesDefinition.DebtRemediationFunctions} --> - * <!-- It was previously named 'debtRemediationFunctionOffset' which is still supported but deprecated since 5.5 --> + * <!-- It was previously named 'debtRemediationFunctionOffset'. --> * <!-- Since 5.5 --> * <remediationFunctionBaseEffort>2min</remediationFunctionBaseEffort> * diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultNewRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultNewRule.java index b20bda996fb..317952fda9a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultNewRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultNewRule.java @@ -173,11 +173,6 @@ class DefaultNewRule extends RulesDefinition.NewRule { } @Override - public DefaultNewRule setDebtSubCharacteristic(@Nullable String s) { - return this; - } - - @Override public RulesDefinition.DebtRemediationFunctions debtRemediationFunctions() { return functions; } @@ -188,12 +183,6 @@ class DefaultNewRule extends RulesDefinition.NewRule { return this; } - @Deprecated - @Override - public DefaultNewRule setEffortToFixDescription(@Nullable String s) { - return setGapDescription(s); - } - @Override public DefaultNewRule setGapDescription(@Nullable String s) { this.gapDescription = s; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultRule.java index 9f2ea372229..0a43784f5af 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/internal/DefaultRule.java @@ -155,25 +155,11 @@ public class DefaultRule extends RulesDefinition.Rule { } @CheckForNull - @Deprecated - @Override - public String debtSubCharacteristic() { - return null; - } - - @CheckForNull @Override public DebtRemediationFunction debtRemediationFunction() { return debtRemediationFunction; } - @Deprecated - @CheckForNull - @Override - public String effortToFixDescription() { - return gapDescription(); - } - @CheckForNull @Override public String gapDescription() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java index 00b576a3165..7a7e6f0889a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java @@ -33,7 +33,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.DateUtils; import static java.lang.String.format; @@ -149,45 +148,6 @@ public abstract class Request { return part; } - /** - * @deprecated to be dropped in 4.4. Default values are declared in ws metadata - */ - @CheckForNull - @Deprecated - public String param(String key, @CheckForNull String defaultValue) { - return StringUtils.defaultString(param(key), defaultValue); - } - - /** - * @deprecated to be dropped in 4.4. Default values must be declared in {@link org.sonar.api.server.ws.WebService} then - * this method can be replaced by {@link #mandatoryParamAsBoolean(String)}. - */ - @Deprecated - public boolean paramAsBoolean(String key, boolean defaultValue) { - String value = param(key); - return value == null ? defaultValue : parseBoolean(key, value); - } - - /** - * @deprecated to be dropped in 4.4. Default values must be declared in {@link org.sonar.api.server.ws.WebService} then - * this method can be replaced by {@link #mandatoryParamAsInt(String)}. - */ - @Deprecated - public int paramAsInt(String key, int defaultValue) { - String s = param(key); - return s == null ? defaultValue : parseInt(key, s); - } - - /** - * @deprecated to be dropped in 4.4. Default values must be declared in {@link org.sonar.api.server.ws.WebService} then - * this method can be replaced by {@link #mandatoryParamAsLong(String)}. - */ - @Deprecated - public long paramAsLong(String key, long defaultValue) { - String s = param(key); - return s == null ? defaultValue : parseLong(key, s); - } - @CheckForNull public Boolean paramAsBoolean(String key) { String value = param(key); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index 91ecd219408..6e4e59b84a7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -674,17 +674,6 @@ public interface WebService extends Definable<WebService.Context> { } /** - * @see #setDeprecatedKey(String, String) - * @since 5.0 - * @deprecated since 6.4 - */ - @Deprecated - public NewParam setDeprecatedKey(@Nullable String s) { - this.deprecatedKey = s; - return this; - } - - /** * @param deprecatedSince Version when the old key was replaced/deprecated. Ex: 5.6 * @see Param#deprecatedKey() * @since 6.4 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskComponent.java b/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskComponent.java deleted file mode 100644 index d6ec4dcd4b0..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskComponent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.task; - -import org.sonar.api.batch.ScannerSide; -import org.sonar.api.batch.InstantiationStrategy; - -/** - * All the classes implementing this interface can be injected in public constructors of {@link TaskExtension}. - * - * @since 3.6 - * @deprecated since 5.1. Use {@link ScannerSide} and {@link InstantiationStrategy#PER_TASK} - */ -@Deprecated -@ScannerSide -@InstantiationStrategy(InstantiationStrategy.PER_TASK) -public interface TaskComponent { -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskExtension.java b/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskExtension.java deleted file mode 100644 index 256c3303c51..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskExtension.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.task; - -import org.sonar.api.batch.ScannerSide; -import org.sonar.api.batch.InstantiationStrategy; - -/** - * Task extension point - * - * @since 3.6 - * @deprecated since 5.1. Not used. - */ -@Deprecated -@ScannerSide -@InstantiationStrategy(InstantiationStrategy.PER_TASK) -public interface TaskExtension { -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/CoverageBlock.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/CoverageBlock.java deleted file mode 100644 index e5705cfb4da..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/CoverageBlock.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import java.util.List; - -/** - * @deprecated since 5.6. Feature will be removed without any alternatives. - */ -@Deprecated -public interface CoverageBlock { - - TestCase testCase(); - - Testable testable(); - - List<Integer> lines(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java deleted file mode 100644 index 238122e87f3..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import java.util.List; -import javax.annotation.Nullable; -import org.sonar.api.batch.fs.InputFile; - -/** - * @deprecated since 5.6. Feature will be removed without any alternatives. - */ -@Deprecated -public interface MutableTestCase extends TestCase { - MutableTestCase setStatus(@Nullable Status s); - - MutableTestCase setDurationInMs(@Nullable Long l); - - MutableTestCase setMessage(@Nullable String s); - - MutableTestCase setStackTrace(@Nullable String s); - - /** - * @deprecated since 5.2 not used - */ - @Deprecated - MutableTestCase setType(@Nullable String s); - - /** - * @deprecated since 5.2. Use {@link #setCoverageBlock(InputFile, List)} - */ - @Deprecated - MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines); - - MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java deleted file mode 100644 index 69b90697ded..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -/** - * @deprecated since 5.6. Feature will be removed without any alternatives. - */ -@Deprecated -public interface MutableTestPlan extends TestPlan<MutableTestCase> { - - /** - * Add a {@link TestCase} to this test file. - * Note that a same physical test (for example in Java a single method annotated with @Test) - * can be executed several times (parameterized tests, different test suites, ...). As a result it is perfectly valid to register several - * tests with the same name. Anyway in this situation the coverage per test will be merged for all tests with the same name. - * @param name - * @return - */ - MutableTestCase addTestCase(String name); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestable.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestable.java deleted file mode 100644 index d98f72a9a57..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -/** - * @deprecated since 5.6. Feature will be removed without any alternatives. - */ -@Deprecated -public interface MutableTestable extends Testable { - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java deleted file mode 100644 index 92d732a957e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import java.util.Locale; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @deprecated since 5.2 not used - */ -@Deprecated -public interface TestCase { - enum Status { - OK, FAILURE, ERROR, SKIPPED; - - public static Status of(@Nullable String s) { - return s == null ? null : valueOf(s.toUpperCase(Locale.ENGLISH)); - } - } - - /** - * @deprecated since 5.2 not used - */ - @Deprecated - String TYPE_UNIT = "UNIT"; - /** - * @deprecated since 5.2 not used - */ - @Deprecated - String TYPE_INTEGRATION = "INTEGRATION"; - - /** - * Duration in milliseconds - */ - @CheckForNull - Long durationInMs(); - - /** - * @deprecated since 5.2 not used - */ - @Deprecated - String type(); - - Status status(); - - String name(); - - @CheckForNull - String message(); - - @CheckForNull - String stackTrace(); - - TestPlan testPlan(); - - boolean doesCover(); - - int countCoveredLines(); - - Iterable<CoverageBlock> coverageBlocks(); - - @CheckForNull - CoverageBlock coverageBlock(Testable testable); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java deleted file mode 100644 index bcf78350e5f..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import org.sonar.api.component.Perspective; - -/** - * @deprecated since 5.2 not used - */ -@Deprecated -public interface TestPlan<T extends TestCase> extends Perspective { - Iterable<T> testCases(); - - Iterable<T> testCasesByName(String name); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java deleted file mode 100644 index bb33fa54587..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import org.sonar.api.component.Perspective; - -/** - * @deprecated since 5.2 - */ -@Deprecated -public interface Testable extends Perspective { - - List<TestCase> testCases(); - - TestCase testCaseByName(String key); - - int countTestCasesOfLine(Integer line); - - Map<Integer, Integer> testCasesByLines(); - - List<TestCase> testCasesOfLine(int line); - - SortedSet<Integer> testedLines(); - - CoverageBlock coverageBlock(TestCase testCase); - - Iterable<CoverageBlock> coverageBlocks(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/CoverageAlreadyExistsException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/CoverageAlreadyExistsException.java deleted file mode 100644 index 64179bb3d3b..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/CoverageAlreadyExistsException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test.exception; - -/** - * @deprecated since 5.6 feature will be removed soon - */ -@Deprecated -public class CoverageAlreadyExistsException extends TestException { - public CoverageAlreadyExistsException(String message) { - super(message); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java deleted file mode 100644 index 51f40ae767e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test.exception; - -/** - * @deprecated since 5.6 feature will be removed soon - */ -@Deprecated -public class IllegalDurationException extends TestException { - public IllegalDurationException(String message) { - super(message); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java deleted file mode 100644 index b5f4dba1464..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test.exception; - -/** - * @deprecated since 5.6 feature will be removed soon - */ -@Deprecated -public class TestException extends RuntimeException { - public TestException(String message) { - super(message); - } - - public TestException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/package-info.java deleted file mode 100644 index 54c99e78d83..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.api.test.exception; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/package-info.java deleted file mode 100644 index b7fe3d16fc0..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/test/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.api.test; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java index ed10b6ef86b..eb98a6ca8fd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/AnnotationUtils.java @@ -58,14 +58,4 @@ public final class AnnotationUtils { return null; } - - /** - * Searches for a class annotation. All inheritance tree is analysed. - * - * @deprecated As of 3.1, replaced by {@link #getAnnotation(Object,Class)} - */ - @Deprecated - public static <A> A getClassAnnotation(Object object, Class<A> annotationClass) { - return (A) getAnnotation(object, (Class<? extends Annotation>) annotationClass); - } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java index f535a3889f8..2ebe6b25896 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java @@ -19,7 +19,6 @@ */ package org.sonar.api.utils; -import java.util.Locale; import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.server.ServerSide; @@ -37,18 +36,6 @@ public class Durations { private static final int HOURS_IN_DAY = 8; /** - * @deprecated since 6.3, only one format is available - */ - @Deprecated - public enum DurationFormat { - /** - * Display duration with only one or two members. - * For instance, Duration.decode("1d 1h 10min", 8) will return "1d 1h" and Duration.decode("12d 5h", 8) will return "12d" - */ - SHORT - } - - /** * Create a Duration object from a number of minutes */ public Duration create(long minutes) { @@ -76,28 +63,6 @@ public class Durations { } /** - * Return the formatted work duration. - * - * @deprecated since 6.3 as the {@link Locale#ENGLISH} is always used. Use {@link #format(Duration)} instead - */ - @Deprecated - public String format(Locale locale, Duration duration, DurationFormat format) { - return format(duration); - } - - /** - * Return the formatted work duration. - * <br> - * Example : format(Locale.FRENCH, Duration.encode("9d 10h"), DurationFormat.SHORT) -> 10d 2d - * - * @deprecated since 6.3 as the {@link Locale#ENGLISH} is always used. Use {@link #format(Duration)} instead - */ - @Deprecated - public String format(Locale locale, Duration duration) { - return format(duration); - } - - /** * Return the formatted work duration using the english bundles. * <br> * Example : format(Duration.encode("9d 10h")) -> 10d 2h diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Paging.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Paging.java index dc3b62c190a..c554fe561e6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Paging.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Paging.java @@ -39,14 +39,6 @@ public class Paging { this.total = total; } - /** - * @deprecated since 5.2 please use the #forPgeIndex(...) builder method - */ - @Deprecated - public static Paging create(int pageSize, int pageIndex, int totalItems) { - return new Paging(pageSize, pageIndex, totalItems); - } - public static Builder forPageIndex(int pageIndex) { return new Builder(pageIndex); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/System2.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/System2.java index dc0ae87db7d..c324b1ccc75 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/System2.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/System2.java @@ -133,17 +133,6 @@ public class System2 { return SystemUtils.IS_OS_MAC; } - /** - * True if Java 7 or Java 8 runtime environment - * - * @since 4.3 - * @deprecated in 6.4. Java 8+ is required, so this method always returns {@code true}. - */ - @Deprecated - public boolean isJavaAtLeast17() { - return true; - } - public void println(String obj) { System.out.print(obj); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java index 3a0c867afab..9a1e939a64a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java @@ -152,14 +152,6 @@ public class Version implements Comparable<Version> { return new Version(major, minor, patch, DEFAULT_BUILD_NUMBER, DEFAULT_QUALIFIER); } - /** - * @deprecated in 6.3 to avoid ambiguity with build number (see {@link #buildNumber()} - */ - @Deprecated - public static Version create(int major, int minor, int patch, String qualifier) { - return new Version(major, minor, patch, DEFAULT_BUILD_NUMBER, qualifier); - } - private static int parseFieldAsInt(String field) { if (field.isEmpty()) { return 0; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java index 119da1876b1..3b311f22cce 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java @@ -64,14 +64,6 @@ public final class ZipUtils { } /** - * @deprecated replaced by {@link #unzip(InputStream, File, Predicate)} in 6.2. - */ - @Deprecated - public static File unzip(InputStream stream, File toDir, ZipEntryFilter filter) throws IOException { - return unzip(stream, toDir, new ZipEntryFilterDelegate(filter)); - } - - /** * Unzip a file to a directory. * * @param stream the zip input file @@ -118,14 +110,6 @@ public final class ZipUtils { } /** - * @deprecated replaced by {@link #unzip(File, File, Predicate)} in 6.2. - */ - @Deprecated - public static File unzip(File zip, File toDir, ZipEntryFilter filter) throws IOException { - return unzip(zip, toDir, new ZipEntryFilterDelegate(filter)); - } - - /** * Unzip a file to a directory. * * @param zip the zip file. It must exist. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/ServletFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/ServletFilter.java index ee66144d880..6270bef1cf6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/ServletFilter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/ServletFilter.java @@ -91,19 +91,6 @@ public abstract class ServletFilter implements Filter { return exclusions; } - /** - * @deprecated replaced in version 6.0 by {@link #getInclusions()} and {@link #getExclusions()} - * @throws IllegalStateException if at least one exclusion or more than one inclusions are defined - */ - @Deprecated - public String getUrl() { - // Before 6.0, it was only possible to include one url - if (exclusions.isEmpty() && inclusions.size() == 1) { - return inclusions.get(0); - } - throw new IllegalStateException("this method is deprecated and should not be used anymore"); - } - public String label() { return "UrlPattern{" + "inclusions=[" + convertPatternsToString(inclusions) + "]" + diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java index 61aa1a20882..c0d90ca2d34 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java @@ -59,7 +59,6 @@ public class PropertyDefinitionTest { .type(PropertyType.FLOAT) .onlyOnQualifiers(Qualifiers.MODULE) .multiValues(true) - .propertySetKey("set") .build(); assertThat(def.key()).isEqualTo("hello"); @@ -72,7 +71,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isFalse(); assertThat(def.qualifiers()).containsOnly(Qualifiers.MODULE); assertThat(def.multiValues()).isTrue(); - assertThat(def.propertySetKey()).isEqualTo("set"); assertThat(def.fields()).isEmpty(); } @@ -93,7 +91,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isFalse(); assertThat(def.qualifiers()).containsOnly(Qualifiers.PROJECT, Qualifiers.MODULE); assertThat(def.multiValues()).isTrue(); - assertThat(def.propertySetKey()).isEqualTo("set"); assertThat(def.fields()).isEmpty(); } @@ -125,7 +122,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isTrue(); assertThat(def.qualifiers()).isEmpty(); assertThat(def.multiValues()).isFalse(); - assertThat(def.propertySetKey()).isEmpty(); assertThat(def.fields()).isEmpty(); } @@ -146,7 +142,6 @@ public class PropertyDefinitionTest { assertThat(def.global()).isTrue(); assertThat(def.qualifiers()).isEmpty(); assertThat(def.multiValues()).isFalse(); - assertThat(def.propertySetKey()).isEmpty(); assertThat(def.fields()).isEmpty(); } @@ -156,7 +151,7 @@ public class PropertyDefinitionTest { .name("Hello") .fields( PropertyFieldDefinition.build("first").name("First").description("Description").options("A", "B").build(), - PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).indicativeSize(5).build()) + PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).build()) .build(); assertThat(def.type()).isEqualTo(PropertyType.PROPERTY_SET); @@ -166,12 +161,10 @@ public class PropertyDefinitionTest { assertThat(def.fields().get(0).description()).isEqualTo("Description"); assertThat(def.fields().get(0).type()).isEqualTo(PropertyType.STRING); assertThat(def.fields().get(0).options()).containsOnly("A", "B"); - assertThat(def.fields().get(0).indicativeSize()).isEqualTo(20); assertThat(def.fields().get(1).key()).isEqualTo("second"); assertThat(def.fields().get(1).name()).isEqualTo("Second"); assertThat(def.fields().get(1).type()).isEqualTo(PropertyType.INTEGER); assertThat(def.fields().get(1).options()).isEmpty(); - assertThat(def.fields().get(1).indicativeSize()).isEqualTo(5); } @Test @@ -188,12 +181,10 @@ public class PropertyDefinitionTest { assertThat(def.fields().get(0).description()).isEqualTo("Description"); assertThat(def.fields().get(0).type()).isEqualTo(PropertyType.STRING); assertThat(def.fields().get(0).options()).containsOnly("A", "B"); - assertThat(def.fields().get(0).indicativeSize()).isEqualTo(20); assertThat(def.fields().get(1).key()).isEqualTo("second"); assertThat(def.fields().get(1).name()).isEqualTo("Second"); assertThat(def.fields().get(1).type()).isEqualTo(PropertyType.INTEGER); assertThat(def.fields().get(1).options()).isEmpty(); - assertThat(def.fields().get(1).indicativeSize()).isEqualTo(5); } @Test @@ -458,7 +449,7 @@ public class PropertyDefinitionTest { @Properties(@Property(key = "hello", name = "Hello", fields = { @PropertyField(key = "first", name = "First", description = "Description", options = {"A", "B"}), - @PropertyField(key = "second", name = "Second", type = PropertyType.INTEGER, indicativeSize = 5)})) + @PropertyField(key = "second", name = "Second", type = PropertyType.INTEGER)})) static class WithPropertySet { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java deleted file mode 100644 index 9536c53f76a..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.profiles; - -import com.google.common.collect.Lists; -import org.junit.Test; -import org.mockito.stubbing.Answer; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleFinder; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; -import org.sonar.check.BelongsToProfile; -import org.sonar.check.Priority; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class AnnotationProfileParserTest { - - @Test - public void shouldParseAnnotatedClasses() { - RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer( - (Answer) iom -> Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1])); - - ValidationMessages messages = ValidationMessages.create(); - RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.newArrayList(FakeRule.class), messages); - - assertThat(profile.getName()).isEqualTo("Foo way"); - assertThat(profile.getLanguage()).isEqualTo("java"); - assertThat(profile.getActiveRule("squid", "fake").getSeverity()).isEqualTo(RulePriority.BLOCKER); - assertThat(messages.hasErrors()).isFalse(); - } - - @Test - public void shouldParseOnlyWantedProfile() { - RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer( - (Answer<Rule>) iom -> Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1])); - - ValidationMessages messages = ValidationMessages.create(); - RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.newArrayList(FakeRule.class, RuleOnOtherProfile.class), messages); - - assertThat(profile.getActiveRule("squid", "fake")).isNotNull(); - assertThat(profile.getActiveRule("squid", "other")).isNull(); - } -} - -@BelongsToProfile(title = "Other profile", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "other", priority = Priority.CRITICAL) -class RuleOnOtherProfile { -} - -@BelongsToProfile(title = "Foo way", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "fake", priority = Priority.CRITICAL) -class FakeRule { -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java index 94ffb2ef1cc..bd1bc4c722f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalGroupsProviderTest.java @@ -39,7 +39,6 @@ public class ExternalGroupsProviderTest { }; String userName = "foo"; - assertThat(groupsProvider.doGetGroups(userName)).isNull(); assertThat(groupsProvider.doGetGroups(new ExternalGroupsProvider.Context(userName, mock(HttpServletRequest.class)))).isNull(); } @@ -61,22 +60,6 @@ public class ExternalGroupsProviderTest { runDoGetGroupsTests(groupsProvider, userGroupsMap); } - @Test - public void doGetGroupsDeprecatedApi() { - final Map<String, Collection<String>> userGroupsMap = getTestUserGroupMapping(); - - ExternalGroupsProvider groupsProvider = new ExternalGroupsProvider() { - @Override - public Collection<String> doGetGroups(String username) { - Preconditions.checkNotNull(username); - - return userGroupsMap.get(username); - } - }; - - runDoGetGroupsTests(groupsProvider, userGroupsMap); - } - private static void runDoGetGroupsTests(ExternalGroupsProvider groupsProvider, Map<String, Collection<String>> userGroupsMap) { for (Map.Entry<String, Collection<String>> userGroupMapEntry : userGroupsMap.entrySet()) { Collection<String> groups = groupsProvider.doGetGroups(new ExternalGroupsProvider.Context( diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java index 9437518f57a..90552931374 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/security/ExternalUsersProviderTest.java @@ -47,21 +47,4 @@ public class ExternalUsersProviderTest { assertThat(user.getName()).isEqualTo("foo"); assertThat(user.getEmail()).isEqualTo("foo@bar.com"); } - - @Test - public void doGetUserDetails_deprecated_api() { - ExternalUsersProvider provider = new ExternalUsersProvider() { - @Override - public UserDetails doGetUserDetails(String username) { - UserDetails user = new UserDetails(); - user.setName(username); - user.setEmail("foo@bar.com"); - return user; - } - }; - UserDetails user = provider.doGetUserDetails(new ExternalUsersProvider.Context("foo", mock(HttpServletRequest.class))); - - assertThat(user.getName()).isEqualTo("foo"); - assertThat(user.getEmail()).isEqualTo("foo@bar.com"); - } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java index fe17affc6db..a965ce51e76 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java @@ -29,13 +29,12 @@ import java.net.URL; import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Assume; import org.junit.Rule; import org.junit.Test; -import org.junit.jupiter.api.Assertions; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.sonar.api.impl.server.RulesDefinitionContext; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleScope; import org.sonar.api.rule.RuleStatus; @@ -43,12 +42,9 @@ import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.api.server.debt.DebtRemediationFunction; import org.sonar.api.utils.log.LogTester; -import org.sonar.api.impl.server.RulesDefinitionContext; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.useDefaultDateFormatsOnly; import static org.junit.Assert.fail; -import static org.junit.jupiter.api.Assertions.assertEquals; @RunWith(DataProviderRunner.class) public class RulesDefinitionTest { @@ -577,17 +573,6 @@ public class RulesDefinitionTest { } @Test - public void sqale_characteristic_is_deprecated_and_is_ignored() { - RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); - newRepository.createRule("NPE").setName("NPE").setHtmlDescription("desc") - .setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.API_ABUSE); - newRepository.done(); - - RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); - assertThat(rule.debtSubCharacteristic()).isNull(); - } - - @Test public void type_is_defined() { RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription("desc") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java index c45475af3a9..47a80d25b28 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionXmlLoaderTest.java @@ -230,25 +230,6 @@ public class RulesDefinitionXmlLoaderTest { } @Test - public void ignore_deprecated_sqale_characteristic() { - String xml = "" + - "<rules>" + - " <rule>" + - " <key>1</key>" + - " <name>One</name>" + - " <description>Desc</description>" + - " <effortToFixDescription>lines</effortToFixDescription>" + - " <debtSubCharacteristic>BUG</debtSubCharacteristic>" + - " <remediationFunction>LINEAR_OFFSET</remediationFunction>" + - " <remediationFunctionGapMultiplier>2d 3h</remediationFunctionGapMultiplier>" + - " <remediationFunctionBaseEffort>5min</remediationFunctionBaseEffort>" + - " </rule>" + - "</rules>"; - RulesDefinition.Rule rule = load(xml).rule("1"); - assertThat(rule.debtSubCharacteristic()).isNull(); - } - - @Test public void markdown_description() { String xml = "" + "<rules>" + diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java index c482d9c6945..a8eb9d21bae 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultNewRuleTest.java @@ -67,12 +67,9 @@ public class DefaultNewRuleTest { rule.addTags("tag3"); assertThat(rule.tags()).containsExactly("tag1", "tag2", "tag3"); - rule.setEffortToFixDescription("effort"); + rule.setGapDescription("effort"); assertThat(rule.gapDescription()).isEqualTo("effort"); - rule.setGapDescription("gap"); - assertThat(rule.gapDescription()).isEqualTo("gap"); - rule.setInternalKey("internal"); assertThat(rule.internalKey()).isEqualTo("internal"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java index a8b6a1b5ec8..4d266504e4f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/internal/DefaultRuleTest.java @@ -44,7 +44,6 @@ public class DefaultRuleTest { RulesDefinition.NewParam param1 = rule.createParam("param1"); rule.setTags("tag1", "tag2"); rule.addTags("tag3"); - rule.setEffortToFixDescription("effort"); rule.setGapDescription("gap"); rule.setInternalKey("internal"); rule.addDeprecatedRuleKey("deprecatedrepo", "deprecatedkey"); @@ -64,7 +63,6 @@ public class DefaultRuleTest { assertThat(defaultRule.activatedByDefault()).isTrue(); assertThat(defaultRule.params()).containsOnly(new DefaultParam(new DefaultNewParam("param1"))); assertThat(defaultRule.tags()).containsOnly("tag1", "tag2", "tag3"); - assertThat(defaultRule.effortToFixDescription()).isEqualTo("gap"); assertThat(defaultRule.gapDescription()).isEqualTo("gap"); assertThat(defaultRule.internalKey()).isEqualTo("internal"); assertThat(defaultRule.deprecatedRuleKeys()).containsOnly(RuleKey.of("deprecatedrepo", "deprecatedkey")); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java index 2cb3d37f714..2baebb55587 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java @@ -227,8 +227,6 @@ public class RequestTest { @Test public void paramAsInt() { assertThat(underTest.setParam("a_number", "123").paramAsInt("a_number")).isEqualTo(123); - assertThat(underTest.setParam("a_number", "123").paramAsInt("a_number", 42)).isEqualTo(123); - assertThat(underTest.setParam("a_number", null).paramAsInt("a_number", 42)).isEqualTo(123); } @Test @@ -240,18 +238,8 @@ public class RequestTest { } @Test - public void fail_when_param_is_not_an_int_with_default_value() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The 'a_number' parameter cannot be parsed as an integer value: not_an_int"); - - underTest.setParam("a_number", "not_an_int").paramAsInt("a_number", 42); - } - - @Test public void param_as_long() { assertThat(underTest.setParam("a_number", "123").paramAsLong("a_number")).isEqualTo(123L); - assertThat(underTest.setParam("a_number", "123").paramAsLong("a_number", 42L)).isEqualTo(123L); - assertThat(underTest.setParam("a_number", null).paramAsLong("a_number", 42L)).isEqualTo(123L); } @Test @@ -263,14 +251,6 @@ public class RequestTest { } @Test - public void fail_when_param_is_not_a_long_with_default_value() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The 'a_number' parameter cannot be parsed as a long value: not_a_long"); - - underTest.setParam("a_number", "not_a_long").paramAsLong("a_number", 42L); - } - - @Test public void param_as_boolean() { assertThat(underTest.setParam("a_boolean", "true").paramAsBoolean("a_boolean")).isTrue(); assertThat(underTest.setParam("a_boolean", "yes").paramAsBoolean("a_boolean")).isTrue(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java deleted file mode 100644 index 5f2b44aefe3..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/TestCaseTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.test; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TestCaseTest { - @Test - public void value_of_status() { - assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); - assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); - assertThat(TestCase.Status.of(null)).isNull(); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java index ae241088844..b0b487cf2a4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/AnnotationUtilsTest.java @@ -37,12 +37,6 @@ public class AnnotationUtilsTest { } @Test - public void getClassAnnotationWithDeprecatedMethod() { - FakeAnnotation annotation = AnnotationUtils.getClassAnnotation(new SuperClass(), FakeAnnotation.class); - assertThat(annotation.value()).isEqualTo("foo"); - } - - @Test public void searchClassAnnotationInSuperClass() { FakeAnnotation annotation = AnnotationUtils.getAnnotation(new ChildClass(), FakeAnnotation.class); assertThat(annotation.value()).isEqualTo("foo"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java index 395b6566c9b..6fcd1f07d24 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/System2Test.java @@ -89,11 +89,6 @@ public class System2Test { } @Test - public void isJavaAtLeast17_always_returns_true() { - assertThat(System2.INSTANCE.isJavaAtLeast17()).isTrue(); - } - - @Test public void testPrintln() { // well, how to assert that ? Adding a System3 dependency to System2 ? :-) System2.INSTANCE.println("foo"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java index 2c71bfd18e0..c7b904292e6 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java @@ -123,9 +123,6 @@ public class VersionTest { public void test_create() { assertVersion(Version.create(1, 2), 1, 2, 0, 0, ""); assertVersion(Version.create(1, 2, 3), 1, 2, 3, 0, ""); - assertVersion(Version.create(1, 2, 0, ""), 1, 2, 0, 0, ""); - assertVersion(Version.create(1, 2, 3, "build1"), 1, 2, 3, 0, "build1"); - assertThat(Version.create(1, 2, 3, "build1").toString()).isEqualTo("1.2.3-build1"); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java index 7e498be7e10..bcdad396650 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ZipUtilsTest.java @@ -92,24 +92,6 @@ public class ZipUtilsTest { } @Test - public void unzipping_file_extracts_subset_of_files() throws IOException { - File zip = FileUtils.toFile(urlToZip()); - File toDir = temp.newFolder(); - - ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt")); - assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt")); - } - - @Test - public void unzipping_stream_extracts_subset_of_files() throws IOException { - InputStream zip = urlToZip().openStream(); - File toDir = temp.newFolder(); - - ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt")); - assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt")); - } - - @Test public void fail_if_unzipping_file_outside_target_directory() throws Exception { File zip = new File(getClass().getResource("ZipUtilsTest/zip-slip.zip").toURI()); File toDir = temp.newFolder(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java index 15acc0ae17b..5fe2fdfc1b8 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/web/ServletFilterTest.java @@ -208,19 +208,8 @@ public class ServletFilterTest { @Test public void getUrl_returns_single_inclusion() { - assertThat(ServletFilter.UrlPattern.create("/*").getUrl()).isEqualTo("/*"); - assertThat(ServletFilter.UrlPattern.create("/foo/bar").getUrl()).isEqualTo("/foo/bar"); - } - - @Test - public void getUrl_throws_ISE_if_many_urls() { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("this method is deprecated and should not be used anymore"); - - ServletFilter.UrlPattern.builder() - .includes("/foo/*", "/foo/lo*") - .excludes("/foo/login", "/foo/logout", "/foo/list") - .build().getUrl(); + assertThat(ServletFilter.UrlPattern.create("/*").getInclusions()).containsOnly("/*"); + assertThat(ServletFilter.UrlPattern.create("/foo/bar").getInclusions()).containsOnly("/foo/bar"); } @Test diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java deleted file mode 100644 index 62cc69b4485..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.analysis; - -import javax.annotation.concurrent.Immutable; -import org.sonar.api.batch.AnalysisMode; - -@Immutable -public class DefaultAnalysisMode implements AnalysisMode { - - @Override - public boolean isPreview() { - return false; - } - - @Override - public boolean isIssues() { - return false; - } - - @Override - public boolean isPublish() { - return true; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java index 1330bda7efb..952d4003950 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java @@ -25,6 +25,7 @@ import java.util.List; import org.sonar.core.component.DefaultResourceTypes; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.scanner.cpd.JavaCpdBlockIndexerSensor; +import org.sonar.scanner.deprecated.test.TestPlanBuilder; import org.sonar.scanner.externalissue.ExternalIssuesImportSensor; import org.sonar.scanner.genericcoverage.GenericCoverageSensor; import org.sonar.scanner.genericcoverage.GenericTestExecutionSensor; @@ -47,6 +48,7 @@ public class BatchComponents { components.addAll(GenericCoverageSensor.properties()); components.add(GenericTestExecutionSensor.class); components.addAll(GenericTestExecutionSensor.properties()); + components.add(TestPlanBuilder.class); // External issues components.add(ExternalIssuesImportSensor.class); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java index 9374cf8704e..15c8b376e07 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java @@ -19,9 +19,7 @@ */ package org.sonar.scanner.bootstrap; -import java.util.List; import javax.annotation.Nullable; -import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; @@ -62,17 +60,7 @@ public class ExtensionInstaller { doInstall(container, matcher, pluginInfo, extension); } } - List<ExtensionProvider> providers = container.getComponentsByType(ExtensionProvider.class); - for (ExtensionProvider provider : providers) { - Object object = provider.provide(); - if (object instanceof Iterable) { - for (Object extension : (Iterable) object) { - doInstall(container, matcher, null, extension); - } - } else { - doInstall(container, matcher, null, object); - } - } + return this; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MetricProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MetricProvider.java deleted file mode 100644 index 1feaf6acd84..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MetricProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.bootstrap; - -import java.util.ArrayList; -import java.util.List; -import org.sonar.api.ExtensionProvider; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.Metrics; -import org.sonar.api.scanner.ScannerSide; - -@ScannerSide -public class MetricProvider extends ExtensionProvider { - - private Metrics[] factories; - - public MetricProvider(Metrics[] factories) { - this.factories = factories; - } - - public MetricProvider() { - this.factories = new Metrics[0]; - } - - @Override - public List<Metric> provide() { - List<Metric> metrics = new ArrayList<>(CoreMetrics.getMetrics()); - for (Metrics factory : factories) { - metrics.addAll(factory.getMetrics()); - } - return metrics; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilder.java deleted file mode 100644 index bc898b6d7b8..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.perspectives; - -import javax.annotation.CheckForNull; -import org.sonar.api.batch.fs.InputComponent; -import org.sonar.api.component.Perspective; - -public abstract class PerspectiveBuilder<T extends Perspective> { - - private final Class<T> perspectiveClass; - - protected PerspectiveBuilder(Class<T> perspectiveClass) { - this.perspectiveClass = perspectiveClass; - } - - public Class<T> getPerspectiveClass() { - return perspectiveClass; - } - - @CheckForNull - public abstract T loadPerspective(Class<T> perspectiveClass, InputComponent component); -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/ScannerPerspectives.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/ScannerPerspectives.java deleted file mode 100644 index 6805e27f3ea..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/ScannerPerspectives.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.perspectives; - -import java.util.HashMap; -import java.util.Map; -import org.sonar.api.batch.fs.InputPath; -import org.sonar.api.component.Perspective; -import org.sonar.api.component.ResourcePerspectives; - -public class ScannerPerspectives implements ResourcePerspectives { - - private final Map<Class<?>, PerspectiveBuilder<?>> builders = new HashMap<>(); - - public ScannerPerspectives(PerspectiveBuilder[] builders) { - for (PerspectiveBuilder builder : builders) { - this.builders.put(builder.getPerspectiveClass(), builder); - } - } - - @Override - public <P extends Perspective> P as(Class<P> perspectiveClass, InputPath inputPath) { - PerspectiveBuilder<P> builder = builderFor(perspectiveClass); - return builder.loadPerspective(perspectiveClass, inputPath); - } - - private <T extends Perspective> PerspectiveBuilder<T> builderFor(Class<T> clazz) { - PerspectiveBuilder<T> builder = (PerspectiveBuilder<T>) builders.get(clazz); - if (builder == null) { - throw new IllegalStateException("Perspective class is not registered: " + clazz); - } - return builder; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/package-info.java deleted file mode 100644 index 25ff7b8a4dc..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/perspectives/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.perspectives; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java deleted file mode 100644 index 5bebdb68679..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.test; - -import java.util.List; -import org.sonar.api.test.CoverageBlock; -import org.sonar.api.test.TestCase; -import org.sonar.api.test.Testable; -import org.sonar.api.batch.fs.internal.DefaultInputFile; - -public class DefaultCoverageBlock implements CoverageBlock { - - private final TestCase testCase; - private final DefaultInputFile testable; - private final List<Integer> lines; - - public DefaultCoverageBlock(TestCase testCase, DefaultInputFile testable, List<Integer> lines) { - this.testCase = testCase; - this.testable = testable; - this.lines = lines; - } - - @Override - public TestCase testCase() { - return testCase; - } - - @Override - public Testable testable() { - return new DefaultTestable(testable); - } - - @Override - public List<Integer> lines() { - return lines; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java index 35116b6ef2d..f7aff95dcfd 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java @@ -19,146 +19,69 @@ */ package org.sonar.scanner.deprecated.test; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.Locale; import javax.annotation.Nullable; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.test.CoverageBlock; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.TestPlan; -import org.sonar.api.test.Testable; -import org.sonar.api.test.exception.CoverageAlreadyExistsException; -import org.sonar.api.test.exception.IllegalDurationException; -import static org.sonar.api.utils.Preconditions.checkArgument; +public class DefaultTestCase { + public enum Status { + OK, FAILURE, ERROR, SKIPPED; -public class DefaultTestCase implements MutableTestCase { + public static Status of(@Nullable String s) { + return s == null ? null : valueOf(s.toUpperCase(Locale.ENGLISH)); + } + } - private final DefaultTestPlan testPlan; private String type; private Long durationInMs; private Status status; private String name; private String message; - private String stackTrace; - private Map<DefaultInputFile, CoverageBlock> coverageBlocksByTestedFile = new LinkedHashMap<>(); - - public DefaultTestCase(DefaultTestPlan testPlan) { - this.testPlan = testPlan; - } - @Override public String type() { return type; } - @Override - public MutableTestCase setType(@Nullable String s) { + public DefaultTestCase setType(@Nullable String s) { this.type = s; return this; } - @Override public Long durationInMs() { return durationInMs; } - @Override - public MutableTestCase setDurationInMs(@Nullable Long l) { + public DefaultTestCase setDurationInMs(@Nullable Long l) { if (l != null && l < 0) { - throw new IllegalDurationException("Test duration must be positive (got: " + l + ")"); + throw new IllegalStateException("Test duration must be positive (got: " + l + ")"); } this.durationInMs = l; return this; } - @Override public Status status() { return status; } - @Override - public MutableTestCase setStatus(@Nullable Status s) { + public DefaultTestCase setStatus(@Nullable Status s) { this.status = s; return this; } - @Override public String name() { return name; } - public MutableTestCase setName(String s) { + public DefaultTestCase setName(String s) { this.name = s; return this; } - @Override public String message() { return message; } - @Override - public MutableTestCase setMessage(String s) { + public DefaultTestCase setMessage(String s) { this.message = s; return this; } - - @Override - public String stackTrace() { - return stackTrace; - } - - @Override - public MutableTestCase setStackTrace(String s) { - this.stackTrace = s; - return this; - } - - @Override - public MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines) { - DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile(); - return setCoverageBlock(coveredFile, lines); - } - - @Override - public MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines) { - checkArgument(mainFile.type() == Type.MAIN, "Test file can only cover a main file"); - DefaultInputFile coveredFile = (DefaultInputFile) mainFile; - if (coverageBlocksByTestedFile.containsKey(coveredFile)) { - throw new CoverageAlreadyExistsException("The link between " + name() + " and " + coveredFile.key() + " already exists"); - } - coverageBlocksByTestedFile.put(coveredFile, new DefaultCoverageBlock(this, coveredFile, lines)); - return this; - } - - @Override - public TestPlan testPlan() { - return testPlan; - } - - @Override - public boolean doesCover() { - return !coverageBlocksByTestedFile.isEmpty(); - } - - @Override - public int countCoveredLines() { - throw new UnsupportedOperationException("Not supported since SQ 5.2"); - } - - @Override - public Iterable<CoverageBlock> coverageBlocks() { - return coverageBlocksByTestedFile.values(); - } - - @Override - public CoverageBlock coverageBlock(final Testable testable) { - DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile(); - return coverageBlocksByTestedFile.get(coveredFile); - } - } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java index dc4e553947c..5a2a23a273f 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java @@ -21,35 +21,18 @@ package org.sonar.scanner.deprecated.test; import java.util.ArrayList; import java.util.List; -import javax.annotation.CheckForNull; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.MutableTestPlan; -public class DefaultTestPlan implements MutableTestPlan { - private List<MutableTestCase> testCases = new ArrayList<>(); +public class DefaultTestPlan { + private final List<DefaultTestCase> testCases = new ArrayList<>(); - @Override - @CheckForNull - public Iterable<MutableTestCase> testCasesByName(String name) { - List<MutableTestCase> result = new ArrayList<>(); - for (MutableTestCase testCase : testCases()) { - if (name.equals(testCase.name())) { - result.add(testCase); - } - } - return result; - } - - @Override - public MutableTestCase addTestCase(String name) { - DefaultTestCase testCase = new DefaultTestCase(this); + public DefaultTestCase addTestCase(String name) { + DefaultTestCase testCase = new DefaultTestCase(); testCase.setName(name); testCases.add(testCase); return testCase; } - @Override - public Iterable<MutableTestCase> testCases() { + public Iterable<DefaultTestCase> testCases() { return testCases; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java deleted file mode 100644 index 87b0ff7e890..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.test; - -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import org.sonar.api.test.CoverageBlock; -import org.sonar.api.test.MutableTestable; -import org.sonar.api.test.TestCase; -import org.sonar.api.batch.fs.internal.DefaultInputFile; - -public class DefaultTestable implements MutableTestable { - - private final DefaultInputFile inputFile; - - public DefaultTestable(DefaultInputFile inputFile) { - this.inputFile = inputFile; - } - - public DefaultInputFile inputFile() { - return inputFile; - } - - @Override - public List<TestCase> testCases() { - throw unsupported(); - } - - @Override - public TestCase testCaseByName(final String name) { - throw unsupported(); - } - - @Override - public int countTestCasesOfLine(Integer line) { - throw unsupported(); - } - - @Override - public Map<Integer, Integer> testCasesByLines() { - throw unsupported(); - } - - @Override - public List<TestCase> testCasesOfLine(int line) { - throw unsupported(); - } - - @Override - public SortedSet<Integer> testedLines() { - throw unsupported(); - } - - @Override - public CoverageBlock coverageBlock(final TestCase testCase) { - throw unsupported(); - } - - @Override - public Iterable<CoverageBlock> coverageBlocks() { - throw unsupported(); - } - - private static UnsupportedOperationException unsupported() { - return new UnsupportedOperationException("No more available since SQ 5.2"); - } - -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java index 2dff6dc9960..b121f63246e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java @@ -22,40 +22,25 @@ package org.sonar.scanner.deprecated.test; import java.util.HashMap; import java.util.Map; import javax.annotation.CheckForNull; -import org.sonar.api.batch.fs.InputComponent; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.scanner.ScannerSide; -public class TestPlanBuilder extends PerspectiveBuilder<MutableTestPlan> { +@ScannerSide +public class TestPlanBuilder { + private final Map<InputFile, DefaultTestPlan> testPlanByFile = new HashMap<>(); - private Map<InputFile, DefaultTestPlan> testPlanByFile = new HashMap<>(); - - public TestPlanBuilder() { - super(MutableTestPlan.class); - } - - @CheckForNull - @Override - public MutableTestPlan loadPerspective(Class<MutableTestPlan> perspectiveClass, InputComponent component) { - if (component.isFile()) { - DefaultInputFile inputFile = (DefaultInputFile) component; - if (inputFile.type() == Type.TEST) { - inputFile.setPublished(true); - if (!testPlanByFile.containsKey(inputFile)) { - testPlanByFile.put(inputFile, new DefaultTestPlan()); - } - return testPlanByFile.get(inputFile); - } + public DefaultTestPlan getTestPlan(InputFile component) { + DefaultInputFile inputFile = (DefaultInputFile) component; + inputFile.setPublished(true); + if (!testPlanByFile.containsKey(inputFile)) { + testPlanByFile.put(inputFile, new DefaultTestPlan()); } - return null; + return testPlanByFile.get(inputFile); } @CheckForNull public DefaultTestPlan getTestPlanByFile(InputFile inputFile) { return testPlanByFile.get(inputFile); } - } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java deleted file mode 100644 index e83253b5746..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.test; - -import javax.annotation.CheckForNull; -import org.sonar.api.batch.fs.InputComponent; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.test.MutableTestable; -import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder; -import org.sonar.api.batch.fs.internal.DefaultInputFile; - -public class TestableBuilder extends PerspectiveBuilder<MutableTestable> { - - public TestableBuilder() { - super(MutableTestable.class); - } - - @CheckForNull - @Override - public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, InputComponent component) { - if (component.isFile()) { - InputFile inputFile = (InputFile) component; - if (inputFile.type() == Type.MAIN) { - return new DefaultTestable((DefaultInputFile) inputFile); - } - } - return null; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java index 49c4093980e..e4cb78be0c4 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParser.java @@ -31,12 +31,12 @@ import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.api.test.TestCase; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; +import org.sonar.scanner.deprecated.test.DefaultTestCase; +import org.sonar.scanner.deprecated.test.DefaultTestCase.Status; +import org.sonar.scanner.deprecated.test.DefaultTestPlan; import org.sonar.scanner.deprecated.test.TestPlanBuilder; import static org.sonar.api.utils.Preconditions.checkState; @@ -128,7 +128,7 @@ public class GenericTestExecutionReportParser { filePath); matchedFileKeys.add(inputFile.absolutePath()); - MutableTestPlan testPlan = testPlanBuilder.loadPerspective(MutableTestPlan.class, inputFile); + DefaultTestPlan testPlan = testPlanBuilder.getTestPlan(inputFile); SMInputCursor testCaseCursor = fileCursor.childElementCursor(); while (testCaseCursor.getNext() != null) { parseTestCase(testCaseCursor, testPlan); @@ -136,25 +136,24 @@ public class GenericTestExecutionReportParser { } } - private void parseTestCase(SMInputCursor cursor, MutableTestPlan testPlan) throws XMLStreamException { + private static void parseTestCase(SMInputCursor cursor, DefaultTestPlan testPlan) throws XMLStreamException { checkElementName(cursor, "testCase"); - MutableTestCase testCase = testPlan.addTestCase(mandatoryAttribute(cursor, NAME_ATTR)); - TestCase.Status status = TestCase.Status.OK; + DefaultTestCase testCase = testPlan.addTestCase(mandatoryAttribute(cursor, NAME_ATTR)); + Status status = Status.OK; testCase.setDurationInMs(longValue(mandatoryAttribute(cursor, DURATION_ATTR), cursor, DURATION_ATTR, 0)); SMInputCursor child = cursor.descendantElementCursor(); if (child.getNext() != null) { String elementName = child.getLocalName(); if (SKIPPED.equals(elementName)) { - status = TestCase.Status.SKIPPED; + status = Status.SKIPPED; } else if (FAILURE.equals(elementName)) { - status = TestCase.Status.FAILURE; + status = Status.FAILURE; } else if (ERROR.equals(elementName)) { - status = TestCase.Status.ERROR; + status = Status.ERROR; } - if (TestCase.Status.OK != status) { + if (Status.OK != status) { testCase.setMessage(mandatoryAttribute(child, MESSAGE_ATTR)); - testCase.setStackTrace(child.collectDescendantText()); } } testCase.setStatus(status); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java index 77e294a2ff5..b6239eef78f 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java @@ -60,11 +60,6 @@ public class DefaultServer extends Server { } @Override - public File getRootDir() { - return null; - } - - @Override public String getContextPath() { return null; } @@ -80,21 +75,11 @@ public class DefaultServer extends Server { } @Override - public boolean isDev() { - return false; - } - - @Override public boolean isSecured() { return false; } @Override - public String getURL() { - return StringUtils.removeEnd(client.baseUrl(), "/"); - } - - @Override public String getPermanentServerId() { return getId(); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java index e926c020c59..b22bdbc8cce 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java @@ -19,39 +19,19 @@ */ package org.sonar.scanner.postjob; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.postjob.PostJobContext; -import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.config.Configuration; public class DefaultPostJobContext implements PostJobContext { private final Configuration config; - private final AnalysisMode analysisMode; - public DefaultPostJobContext(Configuration config, AnalysisMode analysisMode) { + public DefaultPostJobContext(Configuration config) { this.config = config; - this.analysisMode = analysisMode; } @Override public Configuration config() { return config; } - - @Override - public AnalysisMode analysisMode() { - return analysisMode; - } - - @Override - public Iterable<PostJobIssue> issues() { - throw new UnsupportedOperationException("Preview mode was dropped."); - } - - @Override - public Iterable<PostJobIssue> resolvedIssues() { - throw new UnsupportedOperationException("Preview mode was dropped."); - } - } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ScannerReportUtils.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ScannerReportUtils.java index f62716810fb..16371f82e75 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ScannerReportUtils.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ScannerReportUtils.java @@ -35,8 +35,6 @@ public class ScannerReportUtils { return HighlightingType.COMMENT; case CONSTANT: return HighlightingType.CONSTANT; - case CPP_DOC: - return HighlightingType.CPP_DOC; case KEYWORD: return HighlightingType.KEYWORD; case KEYWORD_LIGHT: @@ -60,8 +58,6 @@ public class ScannerReportUtils { return TypeOfText.COMMENT; case CONSTANT: return TypeOfText.CONSTANT; - case CPP_DOC: - return TypeOfText.CPP_DOC; case HIGHLIGHTING_STRING: return TypeOfText.STRING; case KEYWORD: diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java index 5c1591b0bee..d152d2b4990 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java @@ -26,11 +26,10 @@ import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputComponent; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.api.test.TestCase; -import org.sonar.api.test.TestCase.Status; +import org.sonar.scanner.deprecated.test.DefaultTestCase; +import org.sonar.scanner.deprecated.test.DefaultTestCase.Status; +import org.sonar.scanner.deprecated.test.DefaultTestPlan; import org.sonar.scanner.deprecated.test.TestPlanBuilder; -import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReportWriter; import org.sonar.scanner.scan.filesystem.InputComponentStore; @@ -65,13 +64,14 @@ public class TestExecutionPublisher implements ReportPublisherStep { } private void updateTestExecutionFromTestPlan(final InputFile inputFile, ScannerReportWriter writer) { - final MutableTestPlan testPlan = testPlanBuilder.getTestPlanByFile(inputFile); + final DefaultTestPlan testPlan = testPlanBuilder.getTestPlanByFile(inputFile); if (testPlan == null || !testPlan.testCases().iterator().hasNext()) { return; } long nonSkippedTests = StreamSupport.stream(testPlan.testCases().spliterator(), false).filter(t -> t.status() != Status.SKIPPED).count(); appendMeasure(inputFile, writer, new DefaultMeasure<Integer>().forMetric(TESTS).withValue((int) nonSkippedTests)); - long executionTime = StreamSupport.stream(testPlan.testCases().spliterator(), false).map(TestCase::durationInMs).filter(Objects::nonNull).mapToLong(Long::longValue).sum(); + long executionTime = StreamSupport.stream(testPlan.testCases().spliterator(), false).map(DefaultTestCase::durationInMs).filter(Objects::nonNull).mapToLong(Long::longValue) + .sum(); appendMeasure(inputFile, writer, new DefaultMeasure<Long>().forMetric(TEST_EXECUTION_TIME).withValue(executionTime)); long errorTests = StreamSupport.stream(testPlan.testCases().spliterator(), false).filter(t -> t.status() == Status.ERROR).count(); appendMeasure(inputFile, writer, new DefaultMeasure<Integer>().forMetric(TEST_ERRORS).withValue((int) errorTests)); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java index e8f7ad17526..e67d65da9f1 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java @@ -19,11 +19,10 @@ */ package org.sonar.scanner.scan; +import org.sonar.api.batch.fs.internal.DefaultInputModule; import org.sonar.api.scan.filesystem.FileExclusions; import org.sonar.core.platform.ComponentContainer; import org.sonar.scanner.bootstrap.ExtensionInstaller; -import org.sonar.scanner.deprecated.perspectives.ScannerPerspectives; -import org.sonar.api.batch.fs.internal.DefaultInputModule; import org.sonar.scanner.scan.filesystem.DefaultModuleFileSystem; import org.sonar.scanner.scan.filesystem.ModuleInputComponentStore; import org.sonar.scanner.sensor.ModuleSensorContext; @@ -66,10 +65,8 @@ public class ModuleScanContainer extends ComponentContainer { ModuleSensorOptimizer.class, ModuleSensorContext.class, - ModuleSensorExtensionDictionnary.class, - - // Perspectives - ScannerPerspectives.class); + ModuleSensorExtensionDictionnary.class + ); } private void addExtensions() { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java index d6c494f76fb..e6bf8582814 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java @@ -38,11 +38,9 @@ import org.sonar.core.platform.ComponentContainer; import org.sonar.scanner.DefaultFileLinesContextFactory; import org.sonar.scanner.ProjectInfo; import org.sonar.scanner.analysis.AnalysisTempFolderProvider; -import org.sonar.scanner.analysis.DefaultAnalysisMode; import org.sonar.scanner.bootstrap.ExtensionInstaller; import org.sonar.scanner.bootstrap.ExtensionMatcher; import org.sonar.scanner.bootstrap.GlobalAnalysisMode; -import org.sonar.scanner.bootstrap.MetricProvider; import org.sonar.scanner.bootstrap.PostJobExtensionDictionnary; import org.sonar.scanner.ci.CiConfigurationProvider; import org.sonar.scanner.ci.vendors.AppVeyor; @@ -63,8 +61,6 @@ import org.sonar.scanner.ci.vendors.TravisCi; import org.sonar.scanner.cpd.CpdExecutor; import org.sonar.scanner.cpd.CpdSettings; import org.sonar.scanner.cpd.index.SonarCpdBlockIndex; -import org.sonar.scanner.deprecated.test.TestPlanBuilder; -import org.sonar.scanner.deprecated.test.TestableBuilder; import org.sonar.scanner.fs.InputModuleHierarchy; import org.sonar.scanner.issue.IssueFilters; import org.sonar.scanner.issue.IssuePublisher; @@ -168,13 +164,11 @@ public class ProjectScanContainer extends ComponentContainer { ProjectLock.class, ResourceTypes.class, ProjectReactorValidator.class, - MetricProvider.class, ProjectInfo.class, new RulesProvider(), new BranchConfigurationProvider(), new ProjectBranchesProvider(), new ProjectPullRequestsProvider(), - DefaultAnalysisMode.class, ProjectRepositoriesSupplier.class, new ProjectServerSettingsProvider(), @@ -211,10 +205,6 @@ public class ProjectScanContainer extends ComponentContainer { // metrics DefaultMetricFinder.class, - // tests - TestPlanBuilder.class, - TestableBuilder.class, - // lang Languages.class, DefaultLanguagesRepository.class, diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmConfiguration.java index 5e446aba869..a039a10d979 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmConfiguration.java @@ -29,7 +29,6 @@ import org.sonar.api.CoreProperties; import org.sonar.api.Properties; import org.sonar.api.Property; import org.sonar.api.PropertyType; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.scm.ScmProvider; import org.sonar.api.config.Configuration; import org.sonar.api.notifications.AnalysisWarnings; @@ -64,14 +63,12 @@ public class ScmConfiguration implements Startable { private final Configuration settings; private final AnalysisWarnings analysisWarnings; private final Map<String, ScmProvider> providerPerKey = new LinkedHashMap<>(); - private final AnalysisMode analysisMode; private final InputModuleHierarchy moduleHierarchy; private ScmProvider provider; - public ScmConfiguration(InputModuleHierarchy moduleHierarchy, AnalysisMode analysisMode, Configuration settings, AnalysisWarnings analysisWarnings, ScmProvider... providers) { + public ScmConfiguration(InputModuleHierarchy moduleHierarchy, Configuration settings, AnalysisWarnings analysisWarnings, ScmProvider... providers) { this.moduleHierarchy = moduleHierarchy; - this.analysisMode = analysisMode; this.settings = settings; this.analysisWarnings = analysisWarnings; for (ScmProvider scmProvider : providers) { @@ -79,15 +76,12 @@ public class ScmConfiguration implements Startable { } } - public ScmConfiguration(InputModuleHierarchy moduleHierarchy, AnalysisMode analysisMode, Configuration settings, AnalysisWarnings analysisWarnings) { - this(moduleHierarchy, analysisMode, settings, analysisWarnings, new ScmProvider[0]); + public ScmConfiguration(InputModuleHierarchy moduleHierarchy, Configuration settings, AnalysisWarnings analysisWarnings) { + this(moduleHierarchy, settings, analysisWarnings, new ScmProvider[0]); } @Override public void start() { - if (analysisMode.isIssues()) { - return; - } if (isDisabled()) { LOG.debug(MESSAGE_SCM_STEP_IS_DISABLED_BY_CONFIGURATION); return; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java index e60676ce65f..364567e4633 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java @@ -22,7 +22,6 @@ package org.sonar.scanner.bootstrap; import java.util.Arrays; import org.apache.commons.lang.ClassUtils; import org.junit.Test; -import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; import org.sonar.api.batch.ScannerSide; @@ -56,41 +55,9 @@ public class ExtensionInstallerTest { assertThat(container.getComponentByType(Bar.class)).isNull(); } - @Test - public void should_execute_extension_provider() { - when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo"))); - when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooProvider(), new BarProvider())); - ComponentContainer container = new ComponentContainer(); - ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, settings.asConfig()); - - installer.install(container, new FooMatcher()); - - assertThat(container.getComponentByType(Foo.class)).isNotNull(); - assertThat(container.getComponentByType(Bar.class)).isNull(); - } - - @Test - public void should_provide_list_of_extensions() { - when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo"))); - when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooBarProvider())); - ComponentContainer container = new ComponentContainer(); - ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, settings.asConfig()); - - installer.install(container, new TrueMatcher()); - - assertThat(container.getComponentByType(Foo.class)).isNotNull(); - assertThat(container.getComponentByType(Bar.class)).isNotNull(); - } - private static class FooMatcher implements ExtensionMatcher { public boolean accept(Object extension) { - return extension.equals(Foo.class) || ClassUtils.isAssignable(Foo.class, extension.getClass()) || ClassUtils.isAssignable(FooProvider.class, extension.getClass()); - } - } - - private static class TrueMatcher implements ExtensionMatcher { - public boolean accept(Object extension) { - return true; + return extension.equals(Foo.class) || ClassUtils.isAssignable(Foo.class, extension.getClass()); } } @@ -103,29 +70,4 @@ public class ExtensionInstallerTest { public static class Bar { } - - @ScannerSide - public static class FooProvider extends ExtensionProvider { - @Override - public Object provide() { - return new Foo(); - } - } - - @ScannerSide - public static class BarProvider extends ExtensionProvider { - @Override - public Object provide() { - return new Bar(); - } - } - - @ScannerSide - public static class FooBarProvider extends ExtensionProvider { - @Override - public Object provide() { - return Arrays.asList(new Foo(), new Bar()); - } - } - } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/MetricProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/MetricProviderTest.java deleted file mode 100644 index fbc809e8960..00000000000 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/MetricProviderTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.bootstrap; - -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.Metrics; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MetricProviderTest { - @Test - public void should_provide_at_least_core_metrics() { - MetricProvider provider = new MetricProvider(); - List<Metric> metrics = provider.provide(); - - assertThat(metrics).hasSize(CoreMetrics.getMetrics().size()); - assertThat(metrics).extracting("key").contains("ncloc"); - } - - @Test - public void should_provide_plugin_metrics() { - Metrics factory = () -> Arrays.asList(new Metric.Builder("custom", "Custom", Metric.ValueType.FLOAT).create()); - MetricProvider provider = new MetricProvider(new Metrics[] {factory}); - List<Metric> metrics = provider.provide(); - - assertThat(metrics.size()).isEqualTo(1 + CoreMetrics.getMetrics().size()); - assertThat(metrics).extracting("key").contains("custom"); - } -} diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilderTest.java deleted file mode 100644 index ce4cf0529c9..00000000000 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/perspectives/PerspectiveBuilderTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.deprecated.perspectives; - -import org.junit.Test; -import org.sonar.api.batch.fs.InputComponent; -import org.sonar.api.component.Perspective; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PerspectiveBuilderTest { - - @Test - public void testGetPerspectiveClass() { - PerspectiveBuilder<FakePerspective> builder = new PerspectiveBuilder<FakePerspective>(FakePerspective.class) { - @Override - public FakePerspective loadPerspective(Class<FakePerspective> perspectiveClass, InputComponent component) { - return null; - } - }; - - assertThat(builder.getPerspectiveClass()).isEqualTo(FakePerspective.class); - } - - interface FakePerspective extends Perspective { - - } -} diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/analysis/DefaultAnalysisModeTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java index 34f2d0d9e9d..27d4884a227 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/analysis/DefaultAnalysisModeTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/deprecated/test/DefaultTestCaseTest.java @@ -17,20 +17,28 @@ * 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.scanner.analysis; +package org.sonar.scanner.deprecated.test; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -public class DefaultAnalysisModeTest { +public class DefaultTestCaseTest { + private final DefaultTestCase testCase = new DefaultTestCase(); @Test - public void test() { - DefaultAnalysisMode mode = new DefaultAnalysisMode(); - assertThat(mode.isPublish()).isTrue(); - assertThat(mode.isIssues()).isFalse(); - assertThat(mode.isPreview()).isFalse(); - } + public void getters_after_setters() { + testCase + .setMessage("message") + .setName("name") + .setType("type") + .setDurationInMs(1234L) + .setStatus(DefaultTestCase.Status.FAILURE); + assertThat(testCase.status()).isEqualTo(DefaultTestCase.Status.FAILURE); + assertThat(testCase.name()).isEqualTo("name"); + assertThat(testCase.type()).isEqualTo("type"); + assertThat(testCase.durationInMs()).isEqualTo(1234L); + assertThat(testCase.message()).isEqualTo("message"); + } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java index dc3ee60b081..8afe338e6e3 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java @@ -27,19 +27,18 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.test.MutableTestCase; -import org.sonar.api.test.MutableTestPlan; -import org.sonar.api.utils.MessageException; -import org.sonar.scanner.deprecated.test.TestPlanBuilder; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.sensor.internal.SensorContextTester; +import org.sonar.api.utils.MessageException; +import org.sonar.scanner.deprecated.test.DefaultTestCase; +import org.sonar.scanner.deprecated.test.DefaultTestPlan; +import org.sonar.scanner.deprecated.test.TestPlanBuilder; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -53,7 +52,7 @@ public class GenericTestExecutionReportParserTest { private DefaultInputFile fileWithBranches; private DefaultInputFile emptyFile; private SensorContextTester context; - private MutableTestPlan testPlan; + private DefaultTestPlan testPlan; @Before public void before() { @@ -62,10 +61,10 @@ public class GenericTestExecutionReportParserTest { emptyFile = setupFile("src/main/java/com/example/EmptyClass.java"); testPlanBuilder = mock(TestPlanBuilder.class); - MutableTestCase testCase = mockMutableTestCase(); + DefaultTestCase testCase = mockMutableTestCase(); testPlan = mockMutableTestPlan(testCase); - when(testPlanBuilder.loadPerspective(eq(MutableTestPlan.class), any(InputFile.class))).thenReturn(testPlan); + when(testPlanBuilder.getTestPlan(any(InputFile.class))).thenReturn(testPlan); } @Test @@ -159,18 +158,17 @@ public class GenericTestExecutionReportParserTest { .build(); } - private MutableTestPlan mockMutableTestPlan(MutableTestCase testCase) { - MutableTestPlan testPlan = mock(MutableTestPlan.class); + private DefaultTestPlan mockMutableTestPlan(DefaultTestCase testCase) { + DefaultTestPlan testPlan = mock(DefaultTestPlan.class); when(testPlan.addTestCase(anyString())).thenReturn(testCase); return testPlan; } - private MutableTestCase mockMutableTestCase() { - MutableTestCase testCase = mock(MutableTestCase.class); + private DefaultTestCase mockMutableTestCase() { + DefaultTestCase testCase = mock(DefaultTestCase.class); when(testCase.setDurationInMs(anyLong())).thenReturn(testCase); - when(testCase.setStatus(any(org.sonar.api.test.TestCase.Status.class))).thenReturn(testCase); + when(testCase.setStatus(any(DefaultTestCase.Status.class))).thenReturn(testCase); when(testCase.setMessage(anyString())).thenReturn(testCase); - when(testCase.setStackTrace(anyString())).thenReturn(testCase); when(testCase.setType(anyString())).thenReturn(testCase); return testCase; } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/highlighting/HighlightingMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/highlighting/HighlightingMediumTest.java index 076a5309626..84eeccad942 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/highlighting/HighlightingMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/highlighting/HighlightingMediumTest.java @@ -60,7 +60,7 @@ public class HighlightingMediumTest { File xooFile = new File(srcDir, "sample.xoo"); File xoohighlightingFile = new File(srcDir, "sample.xoo.highlighting"); FileUtils.write(xooFile, "Sample xoo\ncontent plop"); - FileUtils.write(xoohighlightingFile, "0:10:s\n11:18:k"); + FileUtils.write(xoohighlightingFile, "1:0:2:0:s\n2:0:2:8:k"); AnalysisResult result = tester.newAnalysis() .properties(ImmutableMap.<String, String>builder() @@ -115,7 +115,7 @@ public class HighlightingMediumTest { File xooFile = new File(srcDir, "sample.xoo"); File xoohighlightingFile = new File(srcDir, "sample.xoo.highlighting"); FileUtils.write(xooFile, "Sample xoo\ncontent plop"); - FileUtils.write(xoohighlightingFile, "0:10:s\n18:18:k"); + FileUtils.write(xoohighlightingFile, "1:0:1:10:s\n2:18:2:18:k"); exception.expect(IllegalStateException.class); exception.expectMessage("Error processing line 2"); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/symbol/SymbolMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/symbol/SymbolMediumTest.java index f9d333716fd..085b1b3b5e6 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/symbol/SymbolMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/symbol/SymbolMediumTest.java @@ -55,7 +55,7 @@ public class SymbolMediumTest { File xooSymbolFile = new File(srcDir, "sample.xoo.symbol"); FileUtils.write(xooFile, "Sample xoo\ncontent\nanother xoo"); // Highlight xoo symbol - FileUtils.write(xooSymbolFile, "7:10,27"); + FileUtils.write(xooSymbolFile, "1:7:1:10,3:8:3:11"); AnalysisResult result = tester.newAnalysis() .properties(ImmutableMap.<String, String>builder() @@ -84,7 +84,7 @@ public class SymbolMediumTest { File xooSymbolFile = new File(srcDir, "sample.xoo.symbol"); FileUtils.write(xooFile, "Sample xoo\ncontent\nanother xoo\nyet another"); // Highlight xoo symbol - FileUtils.write(xooSymbolFile, "7:10,27:32"); + FileUtils.write(xooSymbolFile, "1:7:1:10,3:8:4:1"); AnalysisResult result = tester.newAnalysis() .properties(ImmutableMap.<String, String>builder() diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java index 246daa29d8c..09c043d88d3 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java @@ -19,12 +19,12 @@ */ package org.sonar.scanner.platform; -import org.sonar.api.SonarEdition; import org.junit.Test; import org.sonar.api.CoreProperties; +import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; -import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.Version; import org.sonar.scanner.bootstrap.DefaultScannerWsClient; @@ -49,12 +49,10 @@ public class DefaultServerTest { assertThat(metadata.getId()).isEqualTo("123"); assertThat(metadata.getVersion()).isEqualTo("2.2"); assertThat(metadata.getStartedAt()).isNotNull(); - assertThat(metadata.getURL()).isEqualTo("http://foo.com"); + assertThat(metadata.getPublicRootUrl()).isEqualTo("http://foo.com"); assertThat(metadata.getPermanentServerId()).isEqualTo("123"); - assertThat(metadata.getRootDir()).isNull(); assertThat(metadata.getContextPath()).isNull(); - assertThat(metadata.isDev()).isFalse(); assertThat(metadata.isSecured()).isFalse(); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java index ebce30b77dd..47ca50c01d3 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java @@ -21,30 +21,26 @@ package org.sonar.scanner.postjob; import org.junit.Before; import org.junit.Test; -import org.sonar.api.batch.AnalysisMode; +import org.sonar.api.config.Configuration; import org.sonar.api.config.internal.MapSettings; -import static org.mockito.Mockito.mock; +import static org.assertj.core.api.Assertions.assertThat; public class DefaultPostJobContextTest { private DefaultPostJobContext context; private MapSettings settings; + private Configuration configuration; @Before public void setUp() { settings = new MapSettings(); - AnalysisMode analysisMode = mock(AnalysisMode.class); - context = new DefaultPostJobContext(settings.asConfig(), analysisMode); + configuration = settings.asConfig(); + context = new DefaultPostJobContext(configuration); } - @Test(expected=UnsupportedOperationException.class) - public void testIssues() { - context.issues(); - } - - @Test(expected=UnsupportedOperationException.class) - public void testResolvedIssues() { - context.resolvedIssues(); + @Test + public void getConfig() { + assertThat(context.config()).isEqualTo(configuration); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java index ac730ff28da..9769c914d97 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java @@ -23,7 +23,6 @@ import org.junit.Test; import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.ScannerSide; import org.sonar.api.server.ServerSide; -import org.sonar.api.task.TaskExtension; import org.sonar.scanner.bootstrap.ExtensionMatcher; import static org.assertj.core.api.Assertions.assertThat; @@ -41,8 +40,6 @@ public class ProjectScanContainerTest { assertThat(filter.accept(MyProjectExtension.class)).isFalse(); assertThat(filter.accept(new MyServerExtension())).isFalse(); assertThat(filter.accept(MyServerExtension.class)).isFalse(); - assertThat(filter.accept(new MyTaskExtension())).isFalse(); - assertThat(filter.accept(MyTaskExtension.class)).isFalse(); } @ScannerSide @@ -61,8 +58,4 @@ public class ProjectScanContainerTest { static class MyServerExtension { } - - static class MyTaskExtension implements TaskExtension { - - } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java index 9e87bf87ae9..70dcfe524ee 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java @@ -31,7 +31,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Answers; import org.sonar.api.CoreProperties; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.scm.ScmProvider; import org.sonar.api.config.Configuration; import org.sonar.api.notifications.AnalysisWarnings; @@ -45,7 +44,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; import static org.sonar.scanner.scm.ScmConfiguration.MESSAGE_SCM_EXCLUSIONS_IS_DISABLED_BY_CONFIGURATION; @@ -55,7 +54,6 @@ import static org.sonar.scanner.scm.ScmConfiguration.MESSAGE_SCM_STEP_IS_DISABLE public class ScmConfigurationTest { private final InputModuleHierarchy inputModuleHierarchy = mock(InputModuleHierarchy.class, withSettings().defaultAnswer(Answers.RETURNS_MOCKS)); - private final AnalysisMode analysisMode = mock(AnalysisMode.class); private final AnalysisWarnings analysisWarnings = mock(AnalysisWarnings.class); private final Configuration settings = mock(Configuration.class); @@ -71,10 +69,9 @@ public class ScmConfigurationTest { public ExpectedException thrown = ExpectedException.none(); public ScmConfigurationTest() { - when(analysisMode.isIssues()).thenReturn(false); when(scmProvider.key()).thenReturn(scmProviderKey); - underTest = new ScmConfiguration(inputModuleHierarchy, analysisMode, settings, analysisWarnings, scmProvider); + underTest = new ScmConfiguration(inputModuleHierarchy, settings, analysisWarnings, scmProvider); } @Test @@ -84,7 +81,14 @@ public class ScmConfigurationTest { underTest.start(); assertThat(underTest.provider()).isNotNull(); - verifyZeroInteractions(analysisWarnings); + verifyNoInteractions(analysisWarnings); + } + + @Test + public void no_provider_if_no_provider_is_available() { + ScmConfiguration underTest = new ScmConfiguration(inputModuleHierarchy, settings, analysisWarnings); + assertThat(underTest.provider()).isNull(); + verifyNoInteractions(analysisWarnings); } @Test @@ -135,23 +139,12 @@ public class ScmConfigurationTest { } @Test - public void return_early_from_start_in_issues_mode() { - // return early = doesn't reach the logging when disabled - when(settings.getBoolean(CoreProperties.SCM_DISABLED_KEY)).thenReturn(Optional.of(true)); - when(analysisMode.isIssues()).thenReturn(true); - - underTest.start(); - - assertThat(logTester.logs()).isEmpty(); - } - - @Test public void fail_when_multiple_scm_providers_claim_support() { when(scmProvider.supports(any())).thenReturn(true); when(scmProvider.key()).thenReturn("key1", "key2"); ScmProvider[] providers = {scmProvider, scmProvider}; - ScmConfiguration underTest = new ScmConfiguration(inputModuleHierarchy, analysisMode, settings, analysisWarnings, providers); + ScmConfiguration underTest = new ScmConfiguration(inputModuleHierarchy, settings, analysisWarnings, providers); thrown.expect(MessageException.class); thrown.expectMessage( diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java index a9c2ebb510f..96b1b58dccb 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java @@ -213,7 +213,7 @@ public class DefaultSensorStorageTest { DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php") .setContents("// comment").build(); - DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(0, 1, TypeOfText.KEYWORD); + DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(1, 0, 1, 1, TypeOfText.KEYWORD); underTest.store(highlighting); assertThat(reportWriter.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, file.scannerId())).isTrue(); @@ -226,7 +226,7 @@ public class DefaultSensorStorageTest { .setStatus(InputFile.Status.SAME).build(); when(branchConfiguration.isPullRequest()).thenReturn(true); - DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(0, 1, TypeOfText.KEYWORD); + DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(1, 0, 1, 1, TypeOfText.KEYWORD); underTest.store(highlighting); assertThat(reportWriter.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, file.scannerId())).isFalse(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorOptimizerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorOptimizerTest.java index 08c1e3d97d7..f0054ef1546 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorOptimizerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorOptimizerTest.java @@ -25,14 +25,14 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.rule.ActiveRules; -import org.sonar.api.batch.rule.internal.NewActiveRule; -import org.sonar.api.config.internal.MapSettings; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.TestInputFileBuilder; +import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; +import org.sonar.api.batch.rule.internal.NewActiveRule; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; +import org.sonar.api.config.internal.MapSettings; import org.sonar.api.rule.RuleKey; -import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; import static org.assertj.core.api.Assertions.assertThat; @@ -123,8 +123,8 @@ public class ModuleSensorOptimizerTest { @Test public void should_optimize_on_settings() { - DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor() - .requireProperty("sonar.foo.reportPath"); + DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); + descriptor.onlyWhenConfiguration(c -> c.hasKey("sonar.foo.reportPath")); assertThat(optimizer.shouldExecute(descriptor)).isFalse(); settings.setProperty("sonar.foo.reportPath", "foo"); diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto index b2deb7be2f5..f800a28ba2d 100644 --- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto +++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto @@ -320,7 +320,6 @@ message SyntaxHighlightingRule { ANNOTATION = 1; CONSTANT = 2; COMMENT = 3; - CPP_DOC = 4; STRUCTURED_COMMENT = 5; KEYWORD = 6; HIGHLIGHTING_STRING = 7; |