diff options
author | Godin <mandrikov@gmail.com> | 2010-12-07 16:12:03 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-07 16:12:03 +0000 |
commit | c1cfffea2098a53ab078deb9bebe47b627c389cf (patch) | |
tree | 7333070e02e4504ed48e8d550a6ae8de86b5de6a /sonar-server/src | |
parent | b09f170fa5cd8980019d6cf91251ab11970b1cc6 (diff) | |
download | sonarqube-c1cfffea2098a53ab078deb9bebe47b627c389cf.tar.gz sonarqube-c1cfffea2098a53ab078deb9bebe47b627c389cf.zip |
SONAR-1829: Use severity instead of priority
Diffstat (limited to 'sonar-server/src')
7 files changed, 20 insertions, 29 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java index 4eb135493a3..16f84aad306 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java @@ -28,12 +28,12 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.collections.CollectionUtils; import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; -import org.sonar.jpa.dao.RulesDao; -import org.sonar.jpa.dao.ProfilesDao; import org.sonar.api.measures.Metric; import org.sonar.api.profiles.Alert; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.*; +import org.sonar.jpa.dao.ProfilesDao; +import org.sonar.jpa.dao.RulesDao; import java.util.*; @@ -164,7 +164,7 @@ public class ProfilesBackup implements Backupable { ActiveRule rule = (ActiveRule) source; writeNode(writer, "key", rule.getRule().getKey()); writeNode(writer, "plugin", rule.getRule().getPluginName()); - writeNode(writer, "level", rule.getPriority().name()); + writeNode(writer, "level", rule.getSeverity().name()); if (!rule.getActiveRuleParams().isEmpty()) { writer.startNode("params"); diff --git a/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedProfiles.java b/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedProfiles.java index 90cf7cb0651..ee0628f76dc 100644 --- a/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedProfiles.java @@ -72,7 +72,7 @@ public final class DeprecatedProfiles { this.deprecatedCheckProfiles = new CheckProfile[0]; this.deprecatedCheckProfileProviders = new CheckProfileProvider[0]; } - + public DeprecatedProfiles(Plugins plugins, RuleFinder ruleFinder) { this.deprecatedRepositories = new RulesRepository[0]; this.plugins = plugins; @@ -110,7 +110,7 @@ public final class DeprecatedProfiles { } Rule rule = ruleFinder.findByKey(repositoryKey, deprecatedActiveRule.getRuleKey()); if (rule != null) { - ActiveRule activeRule = providedProfile.activateRule(rule, deprecatedActiveRule.getPriority()); + ActiveRule activeRule = providedProfile.activateRule(rule, deprecatedActiveRule.getSeverity()); for (ActiveRuleParam arp : deprecatedActiveRule.getActiveRuleParams()) { activeRule.setParameter(arp.getKey(), arp.getValue()); } @@ -164,7 +164,6 @@ public final class DeprecatedProfiles { return profile.getActiveRules(); } - public List<ActiveRule> getRulesByRepositoryKey(String repositoryKey) { return profile.getActiveRulesByRepository(repositoryKey); } diff --git a/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java b/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java index 20b9605c863..8217194761a 100644 --- a/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java +++ b/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java @@ -26,7 +26,6 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.profiles.*; import org.sonar.api.rules.ActiveRule; import org.sonar.api.rules.ActiveRuleParam; -import org.sonar.api.rules.RuleFinder; import org.sonar.api.utils.ValidationMessages; import org.sonar.jpa.session.DatabaseSessionFactory; @@ -143,7 +142,7 @@ public final class ProfilesConsole implements ServerComponent { DatabaseSession session = sessionFactory.getSession(); RulesProfile persistedProfile = session.getSingleResult(RulesProfile.class, "name", profileName, "language", language); for (ActiveRule activeRule : profile.getActiveRules()) { - ActiveRule persistedActiveRule = persistedProfile.activateRule(activeRule.getRule(), activeRule.getPriority()); + ActiveRule persistedActiveRule = persistedProfile.activateRule(activeRule.getRule(), activeRule.getSeverity()); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { persistedActiveRule.setParameter(activeRuleParam.getKey(), activeRuleParam.getValue()); } diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterMetrics.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterMetrics.java index 4e9ea3d96ca..769371519e6 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterMetrics.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterMetrics.java @@ -19,27 +19,23 @@ */
package org.sonar.server.startup;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metrics;
-import org.sonar.api.platform.PluginRepository;
import org.sonar.api.profiles.Alert;
import org.sonar.api.utils.Logs;
import org.sonar.api.utils.TimeProfiler;
import org.sonar.jpa.dao.MeasuresDao;
import org.sonar.server.platform.ServerStartException;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.persistence.Query;
-
public class RegisterMetrics {
private MeasuresDao measuresDao;
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 82f0c94de88..144e813f370 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 @@ -113,7 +113,6 @@ public final class RegisterProvidedProfiles { profiler.stop(); } - void saveProvidedProfiles(List<RulesProfile> profiles, DatabaseSession session) { for (RulesProfile profile : profiles) { TimeProfiler profiler = new TimeProfiler().start("Save profile " + profile); @@ -121,7 +120,7 @@ public final class RegisterProvidedProfiles { for (ActiveRule activeRule : profile.getActiveRules()) { Rule rule = getPersistedRule(activeRule); - ActiveRule persistedRule = persistedProfile.activateRule(rule, activeRule.getPriority()); + ActiveRule persistedRule = persistedProfile.activateRule(rule, activeRule.getSeverity()); for (RuleParam param : rule.getParams()) { String value = StringUtils.defaultString(activeRule.getParameter(param.getKey()), param.getDefaultValue()); if (value != null) { @@ -139,11 +138,11 @@ public final class RegisterProvidedProfiles { Rule getPersistedRule(ActiveRule activeRule) { Rule rule = activeRule.getRule(); - if (rule!=null && rule.getId()==null) { - if (rule.getKey()!=null) { + if (rule != null && rule.getId() == null) { + if (rule.getKey() != null) { rule = ruleFinder.findByKey(rule.getRepositoryKey(), rule.getKey()); - } else if (rule.getConfigKey()!=null) { + } else if (rule.getConfigKey() != null) { rule = ruleFinder.find(RuleQuery.create().withRepositoryKey(rule.getRepositoryKey()).withConfigKey(rule.getConfigKey())); } } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/CodeColorizers.java b/sonar-server/src/main/java/org/sonar/server/ui/CodeColorizers.java index cb43e13accb..87e5ca667ce 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/CodeColorizers.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/CodeColorizers.java @@ -19,22 +19,20 @@ */ package org.sonar.server.ui; -import java.io.StringReader; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerExtension; import org.sonar.api.utils.Logs; import org.sonar.api.web.CodeColorizerFormat; -import org.sonar.channel.Channel; import org.sonar.colorizer.CodeColorizer; -import org.sonar.colorizer.HtmlCodeBuilder; import org.sonar.colorizer.HtmlOptions; import org.sonar.colorizer.Tokenizer; +import java.io.StringReader; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class CodeColorizers implements ServerExtension { private Map<String, CodeColorizerFormat> formatPerLanguage; diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java index 4bcc6d92584..0a9029e2334 100644 --- a/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java +++ b/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java @@ -118,7 +118,7 @@ public class BackupTest { assertEquals(1, testProfile.getActiveRules().size()); ActiveRule testActiveRule = testProfile.getActiveRules().get(0); - assertEquals(RulePriority.MAJOR, testActiveRule.getPriority()); + assertEquals(RulePriority.MAJOR, testActiveRule.getSeverity()); assertNotNull(testActiveRule.getRule()); assertEquals("test key", testActiveRule.getRule().getKey()); assertEquals("test plugin", testActiveRule.getRule().getPluginName()); |