diff options
Diffstat (limited to 'server/sonar-webserver-core')
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; - } } |