diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-07 11:08:38 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-07 11:08:38 +0000 |
commit | 6b3ca3adbfb5bba54f706418151c8f35d5deda24 (patch) | |
tree | 349497f64339a44e07ea699ea9cad58c3803d1fc /sonar-server | |
parent | e51183ff04b26f3e6481233fe7243d2b28b2411e (diff) | |
download | sonarqube-6b3ca3adbfb5bba54f706418151c8f35d5deda24.tar.gz sonarqube-6b3ca3adbfb5bba54f706418151c8f35d5deda24.zip |
SONAR-440 Warning when some rules are not imported from a checkstyle and/or PMD configuration file(s)
SONAR-1229 Export/Import a given Sonar quality profile
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java index 12c3aa18c1b..a270e602beb 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java @@ -29,6 +29,7 @@ import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.ActiveRule; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleProvider; +import org.sonar.api.rules.RuleQuery; import org.sonar.api.utils.TimeProfiler; import org.sonar.jpa.session.DatabaseSessionFactory; import org.sonar.server.rules.DeprecatedProfiles; @@ -107,7 +108,7 @@ public final class RegisterProvidedProfiles { RulesProfile profile = findOrCreate(definition, session); for (ProfilePrototype.RulePrototype rulePrototype : prototype.getRules()) { - Rule rule = ruleProvider.findByKey(rulePrototype.getRepositoryKey(), rulePrototype.getKey()); + Rule rule = findRule(rulePrototype); if (rule == null) { LOGGER.warn("The profile " + definition + " defines an unknown rule: " + rulePrototype); @@ -124,6 +125,16 @@ public final class RegisterProvidedProfiles { } } + private Rule findRule(ProfilePrototype.RulePrototype rulePrototype) { + if (StringUtils.isNotBlank(rulePrototype.getKey())) { + return ruleProvider.findByKey(rulePrototype.getRepositoryKey(), rulePrototype.getKey()); + } + if (StringUtils.isNotBlank(rulePrototype.getConfigKey())) { + return ruleProvider.find(RuleQuery.create().withRepositoryKey(rulePrototype.getRepositoryKey()).withConfigKey(rulePrototype.getConfigKey())); + } + return null; + } + private RulesProfile findOrCreate(ProfileDefinition definition, DatabaseSession session) { RulesProfile profile = session.getSingleResult(RulesProfile.class, "name", definition.getName(), "language", definition.getLanguage()); if (profile == null) { |