diff options
60 files changed, 219 insertions, 169 deletions
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml index 53b31f29464..469f1264661 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml @@ -1,11 +1,11 @@ <dataset> <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck" - plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml index 76d13a53489..b89bf3c4f36 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml @@ -1,11 +1,11 @@ <dataset> <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck" - plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml index 485a01a5977..156d636fcd3 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml @@ -1,10 +1,10 @@ <dataset> <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck" - plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/components/PastMeasuresLoaderTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/components/PastMeasuresLoaderTest/shared.xml index 8b66612aeac..5fcc8de67be 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/components/PastMeasuresLoaderTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/components/PastMeasuresLoaderTest/shared.xml @@ -7,11 +7,11 @@ <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck" - plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" + plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <!-- project --> diff --git a/sonar-check-api/src/main/java/org/sonar/check/Status.java b/sonar-check-api/src/main/java/org/sonar/check/Status.java index aa5d7e22506..2f74e8b1b22 100644 --- a/sonar-check-api/src/main/java/org/sonar/check/Status.java +++ b/sonar-check-api/src/main/java/org/sonar/check/Status.java @@ -17,7 +17,6 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ - package org.sonar.check; /** @@ -25,8 +24,4 @@ package org.sonar.check; */ public enum Status { READY, BETA, DEPRECATED; - - public static Status defaultValue() { - return Status.READY; - } } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/DefaultRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/DefaultRuleFinder.java index 834fe7080bd..e7c286d3761 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/DefaultRuleFinder.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/DefaultRuleFinder.java @@ -27,6 +27,7 @@ import org.sonar.api.rules.RuleQuery; import org.sonar.jpa.session.DatabaseSessionFactory; import javax.persistence.Query; + import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -44,7 +45,12 @@ public class DefaultRuleFinder implements RuleFinder { } protected final Rule doFindById(int ruleId) { - return sessionFactory.getSession().getSingleResult(Rule.class, "id", ruleId, "enabled", true); + DatabaseSession session = sessionFactory.getSession(); + return (Rule) session.getSingleResult( + session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.id=:id and r.status<>:status") + .setParameter("id", ruleId) + .setParameter("status", RuleStatus.REMOVED.name() + ), null); } public Rule findByKey(String repositoryKey, String key) { @@ -52,7 +58,13 @@ public class DefaultRuleFinder implements RuleFinder { } protected final Rule doFindByKey(String repositoryKey, String key) { - return sessionFactory.getSession().getSingleResult(Rule.class, "pluginName", repositoryKey, "key", key, "enabled", true); + DatabaseSession session = sessionFactory.getSession(); + return (Rule) session.getSingleResult( + session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.key=:key and r.pluginName=:pluginName and r.status<>:status") + .setParameter("key", key) + .setParameter("pluginName", repositoryKey) + .setParameter("status", RuleStatus.REMOVED.name() + ), null); } public final Rule find(RuleQuery query) { @@ -67,9 +79,9 @@ public class DefaultRuleFinder implements RuleFinder { } private Query createHqlQuery(DatabaseSession session, RuleQuery query) { - StringBuilder hql = new StringBuilder().append("from ").append(Rule.class.getSimpleName()).append(" where enabled=:enabled "); + StringBuilder hql = new StringBuilder().append("from ").append(Rule.class.getSimpleName()).append(" where status<>:status "); Map<String,Object> params = new HashMap<String,Object>(); - params.put("enabled", Boolean.TRUE); + params.put("status", RuleStatus.REMOVED.name()); if (StringUtils.isNotBlank(query.getRepositoryKey())) { hql.append("AND pluginName=:repositoryKey "); params.put("repositoryKey", query.getRepositoryKey()); diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index 8d9b1891f92..5c7b20b4004 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -24,7 +24,7 @@ public final class RuleDto { private String repositoryKey; private String ruleKey; private String description; - private boolean enabled; + private String status; private String name; public Long getId() { @@ -59,12 +59,12 @@ public final class RuleDto { this.description = description; } - public boolean isEnabled() { - return enabled; + public String getStatus() { + return status; } - public void setEnabled(boolean enabled) { - this.enabled = enabled; + public void setStatus(String status) { + this.status = status; } public String getName() { diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java new file mode 100644 index 00000000000..08938291178 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java @@ -0,0 +1,28 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.core.rule; + +public enum RuleStatus { + READY, BETA, DEPRECATED, REMOVED; + + public static RuleStatus defaultValue() { + return RuleStatus.READY; + } +} diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java index c1271f8e8a8..9915043d217 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java @@ -22,6 +22,7 @@ package org.sonar.jpa.dao; import org.sonar.api.database.DatabaseSession; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleParam; +import org.sonar.core.rule.RuleStatus; import java.util.List; @@ -32,11 +33,16 @@ public class RulesDao extends BaseDao { } public List<Rule> getRules() { - return getSession().getResults(Rule.class, "enabled", true); + return getSession().createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.status<>:status") + .setParameter("status", RuleStatus.REMOVED.name()) + .getResultList(); } public List<Rule> getRulesByRepository(String repositoryKey) { - return getSession().getResults(Rule.class, "pluginName", repositoryKey, "enabled", true); + return getSession().createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.pluginName=:pluginName and r.status<>:status") + .setParameter("pluginName", repositoryKey) + .setParameter("status", RuleStatus.REMOVED.name()) + .getResultList(); } /** @@ -48,7 +54,13 @@ public class RulesDao extends BaseDao { } public Rule getRuleByKey(String repositoryKey, String ruleKey) { - return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", repositoryKey, "enabled", true); + DatabaseSession session = getSession(); + return (Rule) session.getSingleResult( + session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.key=:key and r.pluginName=:pluginName and r.status<>:status") + .setParameter("key", ruleKey) + .setParameter("pluginName", repositoryKey) + .setParameter("status", RuleStatus.REMOVED.name() + ), null); } diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index e4629823669..cb27b0e16f1 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -149,7 +149,6 @@ CREATE TABLE "RULES" ( "PLUGIN_NAME" VARCHAR(255) NOT NULL, "DESCRIPTION" VARCHAR(16777215), "PRIORITY" INTEGER, - "ENABLED" BOOLEAN, "CARDINALITY" VARCHAR(10), "PARENT_ID" INTEGER, "PLUGIN_CONFIG_KEY" VARCHAR(500), diff --git a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml index 246e06da204..87c76785c9d 100644 --- a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml @@ -3,11 +3,11 @@ <mapper namespace="org.sonar.core.rule.RuleMapper"> <select id="selectAll" resultType="Rule"> - select id, plugin_rule_key as "ruleKey", plugin_name as "repositoryKey", description, enabled, name from rules + select id, plugin_rule_key as "ruleKey", plugin_name as "repositoryKey", description, status, name from rules </select> <select id="selectById" parameterType="long" resultType="Rule"> - select id, plugin_rule_key as "ruleKey", plugin_name as "repositoryKey", description, enabled, name from rules WHERE id=#{id} + select id, plugin_rule_key as "ruleKey", plugin_name as "repositoryKey", description, status, name from rules WHERE id=#{id} </select> </mapper> diff --git a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java index e5d3a50dcc0..682e4db4fac 100644 --- a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java @@ -47,7 +47,7 @@ public class RuleDaoTest extends AbstractDaoTestCase { assertThat(ruleDto.getId(), Is.is(1L)); assertThat(ruleDto.getName(), Is.is("Avoid Null")); assertThat(ruleDto.getDescription(), Is.is("Should avoid NULL")); - assertThat(ruleDto.isEnabled(), Is.is(true)); + assertThat(ruleDto.getStatus(), Is.is(RuleStatus.READY.name())); assertThat(ruleDto.getRepositoryKey(), Is.is("checkstyle")); } @@ -59,7 +59,7 @@ public class RuleDaoTest extends AbstractDaoTestCase { assertThat(ruleDto.getId(), Is.is(2L)); assertThat(ruleDto.getName(), Is.is("Avoid Null")); assertThat(ruleDto.getDescription(), Is.is("Should avoid NULL")); - assertThat(ruleDto.isEnabled(), Is.is(true)); + assertThat(ruleDto.getStatus(), Is.is(RuleStatus.READY.name())); assertThat(ruleDto.getRepositoryKey(), Is.is("checkstyle")); } diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/CacheRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/rule/CacheRuleFinderTest/shared.xml index 4e02fa9c0b3..f4b9ba30d12 100644 --- a/sonar-core/src/test/resources/org/sonar/core/rule/CacheRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/rule/CacheRuleFinderTest/shared.xml @@ -2,17 +2,17 @@ <!-- CHECKSTYLE --> <rules id="1" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <!-- disabled rule --> <rules id="2" name="Disabled checked" plugin_rule_key="DisabledCheck" - plugin_config_key="Checker/Treewalker/DisabledCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="false" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="Checker/Treewalker/DisabledCheck" plugin_name="checkstyle" description="[null]" priority="4" status="REMOVED" cardinality="SINGLE" parent_id="[null]" /> <rules id="3" name="Check Annotation" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck" - plugin_config_key="Checker/Treewalker/AnnotationUseStyleCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="Checker/Treewalker/AnnotationUseStyleCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]" /> <!-- PMD --> <rules id="4" name="Call Super First" plugin_rule_key="CallSuperFirst" - plugin_config_key="rulesets/android.xml/CallSuperFirst" plugin_name="pmd" description="[null]" priority="2" enabled="true" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="rulesets/android.xml/CallSuperFirst" plugin_name="pmd" description="[null]" priority="2" status="READY" cardinality="SINGLE" parent_id="[null]" /> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/DefaultRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/rule/DefaultRuleFinderTest/shared.xml index 4e02fa9c0b3..f4b9ba30d12 100644 --- a/sonar-core/src/test/resources/org/sonar/core/rule/DefaultRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/rule/DefaultRuleFinderTest/shared.xml @@ -2,17 +2,17 @@ <!-- CHECKSTYLE --> <rules id="1" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck" - plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]"/> <!-- disabled rule --> <rules id="2" name="Disabled checked" plugin_rule_key="DisabledCheck" - plugin_config_key="Checker/Treewalker/DisabledCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="false" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="Checker/Treewalker/DisabledCheck" plugin_name="checkstyle" description="[null]" priority="4" status="REMOVED" cardinality="SINGLE" parent_id="[null]" /> <rules id="3" name="Check Annotation" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck" - plugin_config_key="Checker/Treewalker/AnnotationUseStyleCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="Checker/Treewalker/AnnotationUseStyleCheck" plugin_name="checkstyle" description="[null]" priority="4" status="READY" cardinality="SINGLE" parent_id="[null]" /> <!-- PMD --> <rules id="4" name="Call Super First" plugin_rule_key="CallSuperFirst" - plugin_config_key="rulesets/android.xml/CallSuperFirst" plugin_name="pmd" description="[null]" priority="2" enabled="true" cardinality="SINGLE" parent_id="[null]" /> + plugin_config_key="rulesets/android.xml/CallSuperFirst" plugin_name="pmd" description="[null]" priority="2" status="READY" cardinality="SINGLE" parent_id="[null]" /> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectAll.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectAll.xml index bef45741abc..1fff3c95170 100644 --- a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectAll.xml +++ b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectAll.xml @@ -1,5 +1,5 @@ <dataset> - <rules id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" enabled="1"/> + <rules id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectById.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectById.xml index ed969e76e69..dc8fe1e2615 100644 --- a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectById.xml +++ b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectById.xml @@ -1,6 +1,6 @@ <dataset> - <rules id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" enabled="1"/> - <rules id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" enabled="1"/> + <rules id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY"/> + <rules id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml index dc6eb2966ef..f9753b86dbb 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldCountNumberOfRulesOfACategoryForGivenPlugins.xml @@ -1,14 +1,14 @@ <dataset> <rules id="1" name="rule one" description="desc" plugin_config_key="config" - plugin_rule_key="rule_one" plugin_name="plugin1" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_one" plugin_name="plugin1" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="rule two" description="desc" plugin_config_key="config" - plugin_rule_key="rule_two" plugin_name="plugin2" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_two" plugin_name="plugin2" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="3" name="rule three" description="desc" plugin_config_key="config" - plugin_rule_key="rule_three" plugin_name="plugin2" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_three" plugin_name="plugin2" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="4" name="rule 4" description="desc" plugin_config_key="config" - plugin_rule_key="rule_4" plugin_name="plugin2" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_4" plugin_name="plugin2" status="READY" cardinality="SINGLE" parent_id="[null]"/> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml index ed307037a07..d3643948265 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter-result.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="rule1" description="desc" plugin_config_key="config" - plugin_rule_key="key1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="key1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="REGULAR_EXPRESSION"/> diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml index 542bb36611b..28edad5e9f1 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRuleParametersFromARuleParameter.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="rule1" description="desc" plugin_config_key="config" - plugin_rule_key="key1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="key1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="param1" description="foo" param_type="REGULAR_EXPRESSION"/> <rules_parameters id="2" rule_id="1" name="param2" description="foo" param_type="REGULAR_EXPRESSION"/> diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml index f96135d6b0d..e133d524eea 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules-result.xml @@ -4,11 +4,11 @@ <rules_profiles id="2" name="profile two" language="java"/> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="3" name="baz" description="test" plugin_config_key="checker/baz" - plugin_rule_key="checkstyle.rule3" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule3" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/> <active_rules id="2" profile_id="1" rule_id="2" failure_level="2"/> diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml index 83b241727b8..7b01e946779 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldDeleteActiveRules.xml @@ -4,11 +4,11 @@ <rules_profiles id="2" name="profile two" language="java" /> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="3" name="baz" description="test" plugin_config_key="checker/baz" - plugin_rule_key="checkstyle.rule3" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule3" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/> <active_rules id="2" profile_id="1" rule_id="2" failure_level="2"/> diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml index 3a2d467806e..95931ae62bb 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetActiveRules.xml @@ -4,11 +4,11 @@ <rules_profiles id="2" name="profile two" language="java" /> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="3" name="baz" description="test" plugin_config_key="checker/baz" - plugin_rule_key="checkstyle.rule3" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule3" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/> <active_rules id="2" profile_id="1" rule_id="2" failure_level="2"/> diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml index fa092663e15..36b61fee0c4 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleParams.xml @@ -2,9 +2,9 @@ <!-- Rules --> <rules id="1" name="new1" description="test1" plugin_config_key="checker/new1" - plugin_rule_key="checkstyle.new1" plugin_name="PLUGIN_KEY" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.new1" plugin_name="PLUGIN_KEY" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="new2" description="test2" plugin_config_key="checker/new2" - plugin_rule_key="checkstyle.new2" plugin_name="PLUGIN_KEY" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.new2" plugin_name="PLUGIN_KEY" status="READY" cardinality="SINGLE" parent_id="[null]"/> <!-- Rules parameters --> <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="REGULAR_EXPRESSION" diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml index 4d4c0ba987f..861a86aa8e4 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRuleWithRuleKeyAndPluginKey.xml @@ -1,6 +1,6 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> </dataset>
\ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml index 04a15024e0a..c3c159f949b 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldGetRules.xml @@ -1,9 +1,9 @@ <dataset> <rules id="1" name="rule one" description="desc" plugin_config_key="other config" - plugin_rule_key="rule_one" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_one" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="rule two" description="desc" plugin_config_key="config" - plugin_rule_key="rule_two" plugin_name="other plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="rule_two" plugin_name="other plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="REGULAR_EXPRESSION" /> 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 f65ced89002..2a26e0d7e16 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 @@ -65,9 +65,6 @@ public final class Rule { @Column(name = "plugin_rule_key", updatable = false, nullable = true, length = 200) private String key; - @Column(name = "enabled", updatable = true, nullable = true) - private Boolean enabled = Boolean.TRUE; - @Column(name = "plugin_config_key", updatable = true, nullable = true, length = 500) private String configKey; @@ -87,7 +84,7 @@ public final class Rule { private Cardinality cardinality = Cardinality.SINGLE; @Column(name = "status", updatable = true, nullable = true) - private String status; + private String status = "READY"; @Column(name = "language", updatable = true, nullable = true) private String language; @@ -255,15 +252,7 @@ public final class Rule { } public Boolean isEnabled() { - return enabled; - } - - /** - * Do not call. Used only by sonar. - */ - public Rule setEnabled(Boolean b) { - this.enabled = b; - return this; + return !status.equals("REMOVED"); } public List<RuleParam> getParams() { @@ -476,7 +465,6 @@ public final class Rule { .append("key", key) .append("configKey", configKey) .append("plugin", pluginName) - .append("enabled", enabled) .append("severity", priority) .append("cardinality", cardinality) .append("status", status) diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java index e901d88a3b1..59bd9bf54bd 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java @@ -51,7 +51,7 @@ public class XMLRuleParserTest { assertThat(rule.getSeverity(), Is.is(RulePriority.BLOCKER)); assertThat(rule.getCardinality(), Is.is(Cardinality.MULTIPLE)); assertThat(rule.getConfigKey(), is("Checker/TreeWalker/LocalVariableName")); - assertThat(rule.getStatus(), nullValue()); + assertThat(rule.getStatus(), is("READY")); assertThat(rule.getParams().size(), is(2)); RuleParam prop = rule.getParam("ignore"); diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java index 60803e6b7c1..8617a9cfce0 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java @@ -31,6 +31,8 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleParam; import org.sonar.api.rules.RulePriority; +import org.sonar.check.Status; +import org.sonar.core.rule.RuleStatus; import org.sonar.jpa.dao.RulesDao; import java.util.Collection; @@ -83,7 +85,7 @@ public class RulesBackup implements Backupable { private void disableUserRules() { LoggerFactory.getLogger(getClass()).info("Disable rules created by user"); for (Rule rule : getUserRules()) { - rule.setEnabled(false); + rule.setStatus(RuleStatus.REMOVED.name()); session.save(rule); } } @@ -119,10 +121,10 @@ public class RulesBackup implements Backupable { matchingRuleInDb.setDescription(rule.getDescription()); matchingRuleInDb.setSeverity(rule.getSeverity()); matchingRuleInDb.setParams(rule.getParams()); - matchingRuleInDb.setEnabled(true); + matchingRuleInDb.setStatus(Status.READY.name()); session.save(matchingRuleInDb); } else { - rule.setEnabled(true); + rule.setStatus(Status.READY.name()); session.save(rule); } } diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java index 4c2bafdc86f..d00a336d507 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java @@ -35,8 +35,11 @@ import org.sonar.api.utils.SonarException; import org.sonar.api.utils.TimeProfiler; import org.sonar.check.Status; import org.sonar.core.i18n.RuleI18nManager; +import org.sonar.core.rule.RuleStatus; import org.sonar.jpa.session.DatabaseSessionFactory; +import javax.persistence.Query; + import java.util.Arrays; import java.util.Collection; import java.util.Date; @@ -88,20 +91,23 @@ public final class RegisterRules { deprecatedUserRuleIds.addAll(session.createQuery( "SELECT r.id FROM " + Rule.class.getSimpleName() + - " r WHERE r.parent IS NOT NULL AND EXISTS(FROM " + Rule.class.getSimpleName() + " p WHERE r.parent=p and p.enabled=false)").getResultList()); + " r WHERE r.parent IS NOT NULL AND EXISTS(FROM " + Rule.class.getSimpleName() + " p WHERE r.parent=p and p.status=:status)") + .setParameter("status", RuleStatus.REMOVED.name()) + .getResultList()); for (Integer deprecatedUserRuleId : deprecatedUserRuleIds) { Rule rule = session.getSingleResult(Rule.class, "id", deprecatedUserRuleId); - rule.setEnabled(false); + rule.setStatus(RuleStatus.REMOVED.name()); rule.setUpdatedAt(new Date()); session.saveWithoutFlush(rule); } - } private void disableAllRules(DatabaseSession session) { // the hardcoded repository "manual" is used for manual violations - session.createQuery("UPDATE " + Rule.class.getSimpleName() + " SET enabled=false, updated_at=current_timestamp WHERE parent IS NULL AND pluginName<>'manual' AND enabled=true").executeUpdate(); + Query query = session.createQuery("UPDATE " + Rule.class.getSimpleName() + " SET status=:status, updated_at=current_timestamp WHERE parent IS NULL AND pluginName<>'manual' AND status<>:status"); + query.setParameter("status", RuleStatus.REMOVED.name()); + query.executeUpdate(); } private void registerRepository(RuleRepository repository, DatabaseSession session) { @@ -110,7 +116,7 @@ public final class RegisterRules { validateRule(rule, repository.getKey()); rule.setRepositoryKey(repository.getKey()); rule.setLanguage(repository.getLanguage()); - rule.setStatus(!Strings.isNullOrEmpty(rule.getStatus()) ? rule.getStatus() : Status.defaultValue().name()); + rule.setStatus(!Strings.isNullOrEmpty(rule.getStatus()) ? rule.getStatus() : RuleStatus.defaultValue().name()); rulesByKey.put(rule.getKey(), rule); } LOG.info(rulesByKey.size() + " rules"); @@ -154,7 +160,6 @@ public final class RegisterRules { persistedRule.setConfigKey(rule.getConfigKey()); persistedRule.setDescription(rule.getDescription()); persistedRule.setSeverity(rule.getSeverity()); - persistedRule.setEnabled(true); persistedRule.setCardinality(rule.getCardinality()); persistedRule.setStatus(rule.getStatus()); persistedRule.setLanguage(rule.getLanguage()); @@ -200,7 +205,6 @@ public final class RegisterRules { private void saveNewRules(Collection<Rule> rules, DatabaseSession session) { for (Rule rule : rules) { - rule.setEnabled(true); rule.setCreatedAt(new Date()); session.saveWithoutFlush(rule); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb index 8b66f10adae..93ed44510bd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/rules_controller.rb @@ -27,10 +27,10 @@ class Api::RulesController < Api::RestController language = params[:language] || '' options= {} - options[:plugins]=params[:plugins].split(',') if params[:plugins] + options[:repositories]=params[:plugins].split(',') if params[:plugins] options[:language]=language options[:priorities]=params[:priorities].split(',') if params[:priorities] - options[:status]=params[:status] + options[:activation]=params[:status] options[:searchtext]=params[:searchtext] options[:include_parameters_and_notes]=true options[:inheritance]=params[:inheritance] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 0a9b2bd51bc..8cc741b9669 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -45,7 +45,7 @@ class RulesConfigurationController < ApplicationController init_params() - @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()] }.sort + @select_repositories = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()] }.sort @select_priority = ANY_SELECTION + RULE_PRIORITIES @select_activation = [[message('any'), 'any'], [message('active'), STATUS_ACTIVE], [message('inactive'), STATUS_INACTIVE]] @select_inheritance = [[message('any'), 'any'], [message('rules_configuration.not_inherited'), 'NOT'], [message('rules_configuration.inherited'), 'INHERITED'], @@ -57,12 +57,12 @@ class RulesConfigurationController < ApplicationController @rules = Rule.search(java_facade, { :profile => @profile, :activation => @activation, :priorities => @priorities, :inheritance => @inheritance, :status => @status, - :plugins => @plugins, :searchtext => @searchtext, :include_parameters_and_notes => true, :language => @profile.language, :sort_by => @sort_by}) + :repositories => @repositories, :searchtext => @searchtext, :include_parameters_and_notes => true, :language => @profile.language, :sort_by => @sort_by}) unless @searchtext.blank? @hidden_inactives = Rule.search(java_facade, { :profile => @profile, :activation => @activation==STATUS_ACTIVE ? STATUS_INACTIVE : STATUS_ACTIVE, :priorities => @priorities, :status => @status, - :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters_and_notes => false}).size + :repositories => @repositories, :language => @profile.language, :searchtext => @searchtext, :include_parameters_and_notes => false}).size end @pagination = Api::Pagination.new(params) @@ -376,7 +376,7 @@ class RulesConfigurationController < ApplicationController def init_params @id = params[:id] @priorities = filter_any(params[:priorities]) || [''] - @plugins = filter_any(params[:plugins]) || [''] + @repositories = filter_any(params[:repositories]) || [''] @activation = params[:rule_activation] || STATUS_ACTIVE @inheritance = params[:inheritance] || 'any' @status = params[:status] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index 1ce2b3f0d23..5608f891f46 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -126,7 +126,7 @@ class Profile < ActiveRecord::Base end def count_active_rules - active_rules.select { |ar| ar.rule.enabled }.size + active_rules.select { |ar| ar.rule.enabled? }.size end def ancestors diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb index a982ab0a8da..9dc46f26683 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb @@ -69,23 +69,31 @@ class Rule < ActiveRecord::Base end def ready? - enabled && status == STATUS_READY + status == STATUS_READY end def editable? !parent_id.nil? end + def enabled? + !removed? + end + def disabled? - !enabled + removed? + end + + def removed? + status == STATUS_REMOVED end def deprecated? - enabled && status == STATUS_DEPRECATED + status == STATUS_DEPRECATED end def beta? - enabled && status == STATUS_BETA + status == STATUS_BETA end def <=>(other) @@ -139,7 +147,7 @@ class Rule < ActiveRecord::Base if id<=0 && key_or_id parts=key_or_id.split(':') if parts.size==2 - rule=Rule.find(:first, :conditions => {:plugin_name => parts[0], :plugin_rule_key => parts[1]}) + rule=Rule.first(:conditions => {:plugin_name => parts[0], :plugin_rule_key => parts[1]}) id=rule.id if rule end end @@ -153,7 +161,7 @@ class Rule < ActiveRecord::Base if id<=0 parts=key_or_id.split(':') if parts.size==2 - rule=Rule.find(:first, :conditions => {:plugin_name => parts[0], :plugin_rule_key => parts[1]}) + rule=Rule.first(:conditions => {:plugin_name => parts[0], :plugin_rule_key => parts[1]}) end else rule=Rule.find(id) @@ -163,23 +171,23 @@ class Rule < ActiveRecord::Base end def self.manual_rules - rules = Rule.find(:all, :conditions => ['enabled=? and plugin_name=?', true, MANUAL_REPOSITORY_KEY]) + rules = Rule.all(:conditions => ['status=? and plugin_name=?', STATUS_READY, MANUAL_REPOSITORY_KEY]) Api::Utils.insensitive_sort(rules) { |rule| rule.name } end def self.manual_rule(id) - Rule.find(:first, :conditions => ['enabled=? and plugin_name=? and id=?', true, MANUAL_REPOSITORY_KEY, id]) + Rule.first(:conditions => ['status=? and plugin_name=? and id=?', STATUS_READY, MANUAL_REPOSITORY_KEY, id]) end def self.find_or_create_manual_rule(rule_id_or_name, create_if_not_found=false, options={}) if Api::Utils.is_integer?(rule_id_or_name) - rule = Rule.find(:first, :conditions => {:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :id => rule_id_or_name.to_i}) + rule = Rule.first(:conditions => {:status => STATUS_READY, :plugin_name => MANUAL_REPOSITORY_KEY, :id => rule_id_or_name.to_i}) else key = rule_id_or_name.strip.downcase.sub(/\s+/, '_') - rule = Rule.find(:first, :conditions => {:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key}) + rule = Rule.first(:conditions => {:status => STATUS_READY, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key}) if rule==nil && create_if_not_found description = options[:description] || Api::Utils.message('manual_rules.should_provide_real_description') - rule = Rule.create!(:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key, + rule = Rule.create!(:status => STATUS_READY, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key, :name => rule_id_or_name, :description => description) end end @@ -263,32 +271,28 @@ class Rule < ActiveRecord::Base end - # options :language => nil, :plugins => [], :searchtext => '', :profile => nil, :priorities => [], :activation => '', :status => [], :sort_by => nil + # options :language => nil, :repositories => [], :searchtext => '', :profile => nil, :priorities => [], :activation => '', :status => [], :sort_by => nil def self.search(java_facade, options={}) conditions = [] values = {} status = options[:status] if status.blank? - conditions << ['enabled=:enabled'] - values[:enabled] = true + conditions << ['status <> :status'] + values[:status] = STATUS_REMOVED else - if !status.include?(STATUS_REMOVED) - conditions << ['enabled=:enabled'] - values[:enabled] = true - else - # As we want the enabled and disabled rules, we do not filter on the enabled column - end + conditions << "status IN (:status)" + values[:status] = options[:status] end unless options[:language].blank? - conditions << ['language=:language'] + conditions << ['language = :language'] values[:language] = options[:language] end - if remove_blank(options[:plugins]) + if remove_blank(options[:repositories]) conditions << "plugin_name IN (:plugin_names)" - values[:plugin_names] = options[:plugins] + values[:plugin_names] = options[:repositories] end unless options[:searchtext].blank? @@ -325,18 +329,6 @@ class Rule < ActiveRecord::Base priorities = remove_blank(options[:priorities]) profile = options[:profile] inheritance = options[:inheritance] - status = options[:status] - - # The status cannot be filter in the SQL query because the disabled state is not set in the status column but in the disabled column. - # For instance, a rule can be disabled and in status BETA in database, but in real it has to be considered only as disabled and must be returned when searching only for DISABLED. - if status - rules = rules.reject do |rule| - include_rule = rule.beta? && status.include?(STATUS_BETA) || - rule.deprecated? && status.include?(STATUS_DEPRECATED) || - rule.disabled? && status.include?(STATUS_REMOVED) - !include_rule - end - end if profile inactive = (options[:activation]=='INACTIVE') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb index e78a243a253..8eb570079e6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb @@ -40,7 +40,7 @@ <div class="status-beta"><%= message('beta') %></div> <% elsif rule.deprecated? %> <div class="status-deprecated"><%= message('deprecated') %></div> - <% elsif rule.disabled? %> + <% elsif rule.removed? %> <div class="status-removed"><%= message('removed') %></div> <% end %> </div> @@ -114,7 +114,7 @@ <div style="float: left"> <div style="color: #888" id="rule_repository_<%= rule.id -%>"><%= message('rules_configuration.repository')%> : <%= rule.repository_key %></div> <div style="color: #888" id="rule_key_<%= rule.id -%>"><%= message('key')%> : <%= rule.plugin_rule_key %></div> - <% if !rule.disabled? %> + <% if !rule.removed? %> <div style="color: #888" id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.available_since')%> : <%= human_short_date(rule.created_at) %></div> <% else %> <div style="color: #888" id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.removed_since')%> : <%= human_short_date(rule.updated_at) %></div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb index 56cad81e684..7ca61962129 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb @@ -45,7 +45,7 @@ </div> <div class="rule-search top"> <span class="note"><%= message('rules_configuration.repository') -%></span><br/> - <%= select_tag "plugins", options_for_select(@select_plugins, @plugins), :id => 'search_plugin', :multiple => true, :size => 6 %> + <%= select_tag "repositories", options_for_select(@select_repositories, @repositories), :id => 'search_repository', :multiple => true, :size => 6 %> </div> <div class="rule-search top"> <span class="note"><%= message('severity') -%></span><br/> @@ -77,8 +77,8 @@ <ul style="float: right" class="horizontal"> <li class="marginleft10"> <div class="csv"> - <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @plugins.join(','), - :activation => @activation, :inheritance => @inheritance, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" + <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @repositories.join(','), + :status => @activation, :inheritance => @inheritance, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" onClick="return downloadCsv()" id="download-link" class=""><%= message('download_verb') -%></a> </div> </li> @@ -154,7 +154,7 @@ $j("#rules-search-form").submit(); } - $j('#search_plugin').select2({ + $j('#search_repository').select2({ width: '120px', placeholder: "<%= message('any') -%>" }); diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb index 40875b69cf9..4f4cd18a059 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb @@ -22,11 +22,28 @@ # Sonar 3.6 # class AddStatusLanguageAndDatesToRules < ActiveRecord::Migration + + class Rule < ActiveRecord::Base + end + def self.up add_column 'rules', 'status', :string, :null => true, :limit => 40 add_column 'rules', 'language', :string, :null => true, :limit => 20 add_column 'rules', 'created_at', :datetime, :null => true add_column 'rules', 'updated_at', :datetime, :null => true + + set_rule_status + + remove_column('rules', 'enabled') end + + private + + def self.set_rule_status + Rule.reset_column_information + Rule.update_all({:status => 'READY', :created_at => Time.now}, ['enabled=?', true]) + Rule.update_all({:status => 'REMOVED', :updated_at => Time.now}, ['enabled=?', false]) + end + end diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java index 06d3e943357..9e043276d14 100644 --- a/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java @@ -30,6 +30,7 @@ import org.sonar.api.rules.RuleRepository; import org.sonar.api.utils.SonarException; import org.sonar.check.Status; import org.sonar.core.i18n.RuleI18nManager; +import org.sonar.core.rule.RuleStatus; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.ArrayList; @@ -209,7 +210,7 @@ public class RegisterRulesTest extends AbstractDbUnitTestCase { setupData("shared"); task.start(); - List<Rule> result = getSession().getResults(Rule.class, "enabled", true); + List<Rule> result = getSession().getResults(Rule.class, "status", RuleStatus.READY.name()); assertThat(result.size(), is(VolumeRepository.SIZE)); } diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren-result.xml index 44889c29d30..1aa3d7ab84d 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren-result.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren.xml index e4f1d9ef704..67bea788819 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldActivateInChildren.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent-result.xml index 210628c51b9..11b3e255853 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent-result.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent.xml index 5aee6ba05a5..aa2d530ea3d 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldChangeParent.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldCheckCycles.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldCheckCycles.xml index c85df96dab2..2a34f38f480 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldCheckCycles.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldCheckCycles.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="level1" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren-result.xml index 6cd28656f07..739fb82198f 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren-result.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="2" used_profile="false" name="parent" language="java" parent_name="[null]"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren.xml index 686ac1c5875..90ca7db8e7b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldDeactivateInChildren.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent-result.xml index 32d1470e4e4..d8674d21c03 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent-result.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent.xml index 686ac1c5875..90ca7db8e7b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRemoveParent.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent-result.xml index 5c1581f6646..8e7f91aea48 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent-result.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent.xml index aabcd7c8f1f..d01218e4d04 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldSetParent.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile.xml index 4ce5bc091b0..d1a4eea9b8b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test2" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/initialData.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/initialData.xml index 9ea528b934b..6b30e58185b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/initialData.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/initialData.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule1" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" name="bar" description="test2" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> <rules_profiles id="1" version="1" used_profile="true" name="parent" language="java" parent_name="[null]" /> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted.xml index f1829a1122e..d6e7fc81799 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted.xml @@ -1,7 +1,7 @@ <dataset> <rules id="2" name="bar" description="test2" plugin_config_key="checker/bar" - plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> + plugin_rule_key="checkstyle.rule2" plugin_name="plugin" status="READY" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/> <rules_parameters id="14" rule_id="2" name="param2" description="[null]" param_type="REGULAR_EXPRESSION"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRuleParameters.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRuleParameters.xml index cb9574ac90d..8b124e9c6c6 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRuleParameters.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRuleParameters.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description" - enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]" /> + status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" /> <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/> <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="STRING"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRules.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRules.xml index ee1b9b61e4f..1e4bfe7b714 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRules.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedActiveRules.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedRules.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedRules.xml index 8aec705f79f..3670e5df68b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedRules.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableDeprecatedRules.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableUserRulesIfParentIsDisabled.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableUserRulesIfParentIsDisabled.xml index a4cef9f0ff2..5260453c80d 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableUserRulesIfParentIsDisabled.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/disableUserRulesIfParentIsDisabled.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" plugin_rule_key="disabled_rule" plugin_name="fake" plugin_config_key="[null]" name="Disabled rule" description="[null]" - enabled="false" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> + status="REMOVED" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> <!-- user rule duplicated from rule 1. It is currently enabled. --> <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="1"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="1"/> </dataset>
\ No newline at end of file diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/doNotDisableUserRulesIfParentIsEnabled.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/doNotDisableUserRulesIfParentIsEnabled.xml index 6bd9cbd416a..e45fb2ebc5d 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/doNotDisableUserRulesIfParentIsEnabled.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/doNotDisableUserRulesIfParentIsEnabled.xml @@ -1,9 +1,9 @@ <dataset> <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Rule one" description="[null]" - enabled="true" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="1"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="1"/> </dataset>
\ No newline at end of file diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shared.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shared.xml index 5b95916c6d9..a825a3c4bbb 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shared.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shared.xml @@ -1,7 +1,7 @@ <dataset> <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shouldNotDisableManualRules.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shouldNotDisableManualRules.xml index 8eb56a1b61a..cc9e9f725d7 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shouldNotDisableManualRules.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/shouldNotDisableManualRules.xml @@ -1,9 +1,9 @@ <dataset> <rules id="1" plugin_rule_key="PerformanceIssue" plugin_name="manual" plugin_config_key="[null]" name="Performance Issue" description="[null]" - enabled="true" priority="[null]" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="[null]" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" plugin_rule_key="IllegalExceptionCheck" plugin_name="checkstyle" plugin_config_key="[null]" name="Illegal Exception" description="[null]" - enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/> </dataset>
\ No newline at end of file diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updadeRuleFields.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updadeRuleFields.xml index d12564071ba..34a705682bd 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updadeRuleFields.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updadeRuleFields.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description" - enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]" status="NORMAL"/> + status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" /> <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2" - enabled="true" priority="1" cardinality="SINGLE" parent_id="[null]" status="NORMAL"/> + status="READY" priority="1" cardinality="SINGLE" parent_id="[null]" /> <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updateRuleParameters.xml b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updateRuleParameters.xml index 0bc07f241d0..6e63e30e606 100644 --- a/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updateRuleParameters.xml +++ b/sonar-server/src/test/resources/org/sonar/server/startup/RegisterRulesTest/updateRuleParameters.xml @@ -1,10 +1,10 @@ <dataset> <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description" - enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="2" cardinality="SINGLE" parent_id="[null]"/> <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2" - enabled="true" priority="1" cardinality="SINGLE" parent_id="[null]"/> + status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/> <rules_parameters id="1" rule_id="1" name="param1" description="old description" param_type="STRING"/> <rules_parameters id="2" rule_id="1" name="deprecated_param" description="deprecated param to be removed" param_type="STRING"/> |