aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-core
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-06-09 16:26:56 -0500
committersonartech <sonartech@sonarsource.com>2021-06-17 20:03:08 +0000
commit2754feca4e5fa8fdd804c827783250f48676296c (patch)
tree1ed9522bbc9eff9444fae6bf0a951d976da2b859 /server/sonar-webserver-core
parent97f2c01fdd4ae863134d4aa1bf32b7dcd512b10c (diff)
downloadsonarqube-2754feca4e5fa8fdd804c827783250f48676296c.tar.gz
sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.zip
SONAR-14925 Remove code deprecated before 7.0 in the Plugin API
Diffstat (limited to 'server/sonar-webserver-core')
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java18
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java15
3 files changed, 4 insertions, 31 deletions
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;
- }
}