From e537ea6120df8eb20ba04da66811c21161f6ec6d Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 1 Dec 2010 11:30:48 +0000 Subject: [PATCH] SONAR-2007 Remove the useless ISO Categories + fix components page --- .../core/sensors/ViolationsDecorator.java | 20 +---- .../sensors/ViolationsDensityDecorator.java | 67 ++-------------- .../sensors/WeightedViolationsDecorator.java | 15 ---- .../core/timemachine/VariationDecorator.java | 9 +-- .../sonar/plugins/core/widgets/rules.html.erb | 61 +++------------ .../sonar/plugins/core/widgets/size.html.erb | 7 +- .../core/sensors/ViolationsDecoratorTest.java | 48 +++--------- .../ViolationsDensityDecoratorTest.java | 78 +++---------------- .../WeightedViolationsDecoratorTest.java | 25 +----- .../VariationDecoratorTest/shared.xml | 4 +- .../dbcleaner/purges/PurgeRuleMeasures.java | 2 +- .../PurgeUtilsTest/purgeSnapshots-result.xml | 10 +-- .../api/PurgeUtilsTest/purgeSnapshots.xml | 10 +-- .../dbContent-result.xml | 2 +- .../DefaultPeriodCleanerTest/dbContent.xml | 2 +- .../purgeDeletedResources-result.xml | 8 +- .../purgeDeletedResources.xml | 8 +- .../sharedFixture.xml | 2 +- .../purgeDeprecatedLast-result.xml | 8 +- .../purgeDeprecatedLast.xml | 8 +- .../PurgeDeprecatedLastTest/sharedFixture.xml | 2 +- .../nothingToPurge-result.xml | 10 +-- .../nothingToPurge.xml | 10 +-- .../purgeDisabledModule-result.xml | 8 +- .../purgeDisabledModule.xml | 8 +- .../purgeDisabledProject-result.xml | 12 +-- .../purgeDisabledProject.xml | 12 +-- .../sharedFixture.xml | 2 +- .../purgeEntities-result.xml | 16 ++-- .../PurgeEntitiesTest/purgeEntities.xml | 16 ++-- .../PurgeEntitiesTest/sharedFixture.xml | 2 +- .../purgeRuleMeasures-result.xml | 2 +- .../purgeRuleMeasures.xml | 2 +- .../PurgeRuleMeasuresTest/sharedFixture.xml | 2 +- .../purgeUnprocessed-result.xml | 16 ++-- .../PurgeUnprocessedTest/purgeUnprocessed.xml | 16 ++-- .../PurgeUnprocessedTest/sharedFixture.xml | 2 +- .../org/sonar/batch/DefaultTimeMachine.java | 2 +- .../sonar/batch/index/MeasurePersister.java | 1 - .../saveRuleMeasures-result.xml | 2 +- .../index/ViolationPersisterTest/shared.xml | 4 +- .../shouldInsertViolations-result.xml | 4 +- .../shouldUpdateViolation-result.xml | 4 +- ...pdatedWhenAnalyzingPastSnapshot-result.xml | 18 ++--- ...tIsNotUpdatedWhenAnalyzingPastSnapshot.xml | 18 ++--- .../UpdateStatusJobTest/sharedFixture.xml | 2 +- .../java/org/sonar/check/IsoCategory.java | 4 + .../src/main/java/org/sonar/check/Rule.java | 2 +- .../test/java/org/sonar/check/CheckTest.java | 1 - .../main/java/org/sonar/jpa/dao/RulesDao.java | 40 ++-------- .../org/sonar/jpa/entity/SchemaMigration.java | 2 +- sonar-core/src/main/resources/ehcache.xml | 2 +- .../java/org/sonar/jpa/dao/RulesDaoTest.java | 14 +--- .../components/CacheRuleFinderTest/shared.xml | 8 +- .../DefaultRuleFinderTest/shared.xml | 8 +- .../shouldAddActiveRulesToProfile-result.xml | 2 +- .../shouldAddActiveRulesToProfile.xml | 2 +- ...umberOfRulesOfACategoryForGivenPlugins.xml | 8 +- ...uleParametersFromARuleParameter-result.xml | 2 +- ...ActiveRuleParametersFromARuleParameter.xml | 2 +- .../shouldDeleteActiveRules-result.xml | 6 +- .../RulesDaoTest/shouldDeleteActiveRules.xml | 6 +- .../dao/RulesDaoTest/shouldGetActiveRules.xml | 6 +- .../dao/RulesDaoTest/shouldGetRuleParams.xml | 4 +- .../shouldGetRuleWithRuleKeyAndPluginKey.xml | 2 +- .../jpa/dao/RulesDaoTest/shouldGetRules.xml | 4 +- .../shouldSynchronizeRuleOfActiveRule.xml | 4 +- .../templates/CheckTemplateRepository.java | 41 ++-------- .../templates/XmlCheckTemplateFactory.java | 1 - .../org/sonar/api/database/daos/RulesDao.java | 9 ++- .../api/rules/StandardRulesXmlParser.java | 4 +- .../api/rules/StandardRulesXmlParserTest.java | 26 ++----- .../api/database/model/MeasureModel.java | 20 ++--- .../org/sonar/api/measures/CoreMetrics.java | 61 ++++++++++++++- .../sonar/api/measures/MeasuresFilters.java | 37 ++++----- .../org/sonar/api/measures/RuleMeasure.java | 22 ++++-- .../sonar/api/rules/AnnotationRuleParser.java | 2 - .../api/rules/Iso9126RulesCategories.java | 4 + .../main/java/org/sonar/api/rules/Rule.java | 24 +++--- .../org/sonar/api/rules/RulesCategory.java | 16 ++-- .../org/sonar/api/rules/XMLRuleParser.java | 5 -- .../web/gwt/client/webservices/Measure.java | 11 ++- .../client/webservices/ResourcesQuery.java | 16 ++-- .../api/web/gwt/client/webservices/Rule.java | 14 ++-- .../client/webservices/ViolationsQuery.java | 19 ++--- .../api/checks/CheckWithIntegerProperty.java | 2 +- .../org/sonar/api/checks/CheckWithKey.java | 3 +- .../CheckWithOverriddenPropertyKey.java | 3 +- .../checks/CheckWithPrimitiveProperties.java | 6 +- .../api/checks/CheckWithStringProperty.java | 6 +- .../CheckWithUnsupportedPropertyType.java | 6 +- .../api/checks/CheckWithoutProperties.java | 3 +- .../org/sonar/api/measures/MeasureTest.java | 10 +-- .../api/measures/MeasuresFiltersTest.java | 17 +--- .../sonar/api/measures/RuleMeasureTest.java | 13 +--- .../profiles/AnnotationProfileParserTest.java | 5 +- .../sonar/api/resources/CoreMetricsTest.java | 11 +++ .../org/sonar/api/rules/AnnotatedCheck.java | 4 +- .../rules/AnnotatedCheckWithParameters.java | 3 +- .../api/rules/AnnotationRuleParserTest.java | 22 +++--- .../org/sonar/api/test/IsRuleMeasure.java | 3 - .../sonar/server/filters/FilterExecutor.java | 2 +- .../rules/DeprecatedRuleRepositories.java | 1 - .../sonar/server/startup/RegisterRules.java | 11 --- .../controllers/api/resources_controller.rb | 26 +------ .../app/controllers/api/rules_controller.rb | 4 +- .../controllers/api/violations_controller.rb | 8 -- .../app/controllers/columns_controller.rb | 24 +++--- .../app/controllers/components_controller.rb | 9 +-- .../app/controllers/drilldown_controller.rb | 3 - .../rules_configuration_controller.rb | 19 +---- .../app/controllers/timemachine_controller.rb | 2 +- .../WEB-INF/app/helpers/application_helper.rb | 2 +- .../WEB-INF/app/helpers/components_helper.rb | 11 +-- .../WEB-INF/app/helpers/dashboard_helper.rb | 18 ----- .../WEB-INF/app/helpers/project_helper.rb | 18 ----- .../webapp/WEB-INF/app/models/drilldown.rb | 7 -- .../WEB-INF/app/models/filter_result.rb | 2 +- .../main/webapp/WEB-INF/app/models/project.rb | 2 +- .../WEB-INF/app/models/project_measure.rb | 30 +------ .../main/webapp/WEB-INF/app/models/rule.rb | 30 +------ .../webapp/WEB-INF/app/models/rule_failure.rb | 4 +- .../WEB-INF/app/models/rules_category.rb | 61 --------------- .../webapp/WEB-INF/app/models/snapshot.rb | 18 ++--- .../WEB-INF/app/models/sonar/columns_view.rb | 3 +- .../app/models/sonar/treemap_builder.rb | 2 +- .../webapp/WEB-INF/app/models/trends_chart.rb | 4 +- .../components/_list_edit_mode_controls.rhtml | 8 +- .../views/components/_list_table_header.rhtml | 6 +- .../app/views/components/index.html.erb | 2 +- .../app/views/drilldown/_rule_priority.erb | 2 +- .../app/views/drilldown/violations.html.erb | 64 ++------------- .../views/rules_configuration/_rule.html.erb | 1 - .../views/rules_configuration/index.html.erb | 9 +-- .../db/migrate/003_populate_database.rb | 40 ---------- .../db/migrate/006_use_iso_rule_categories.rb | 49 ------------ .../101_remove_null_snapshot_created_at.rb | 4 - .../migrate/162_delete_iso_rule_categories.rb | 41 ++++++++++ .../server/startup/RegisterRulesTest.java | 2 - .../disableDeprecatedActiveRuleParameters.xml | 2 +- .../disableDeprecatedActiveRules.xml | 4 +- .../disableDeprecatedRules.xml | 4 +- .../disableUserRulesIfParentIsDisabled.xml | 4 +- ...doNotDisableUserRulesIfParentIsEnabled.xml | 4 +- .../startup/RegisterRulesTest/shared.xml | 2 +- .../RegisterRulesTest/updadeRuleFields.xml | 4 +- .../updateRuleParameters.xml | 4 +- 147 files changed, 564 insertions(+), 1178 deletions(-) delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/models/rules_category.rb delete mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/003_populate_database.rb delete mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/006_use_iso_rule_categories.rb create mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java index d808990f575..9951bcc87da 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java @@ -37,7 +37,6 @@ public class ViolationsDecorator implements Decorator { // temporary data for current resource private Multiset rules = HashMultiset.create(); - private Multiset categories = HashMultiset.create(); private Multiset priorities = HashMultiset.create(); private Map ruleToLevel = new HashMap(); private int total = 0; @@ -49,8 +48,7 @@ public class ViolationsDecorator implements Decorator { @DependedUpon public List generatesViolationsMetrics() { return Arrays.asList(CoreMetrics.VIOLATIONS, - CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS, CoreMetrics.MAJOR_VIOLATIONS, CoreMetrics.MINOR_VIOLATIONS, CoreMetrics.INFO_VIOLATIONS, - CoreMetrics.USABILITY, CoreMetrics.MAINTAINABILITY, CoreMetrics.EFFICIENCY, CoreMetrics.PORTABILITY, CoreMetrics.RELIABILITY); + CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS, CoreMetrics.MAJOR_VIOLATIONS, CoreMetrics.MINOR_VIOLATIONS, CoreMetrics.INFO_VIOLATIONS); } public void decorate(Resource resource, DecoratorContext context) { @@ -65,7 +63,6 @@ public class ViolationsDecorator implements Decorator { private void resetCounters() { rules.clear(); - categories.clear(); priorities.clear(); ruleToLevel.clear(); total = 0; @@ -76,7 +73,6 @@ public class ViolationsDecorator implements Decorator { countCurrentResourceViolations(context); saveTotalViolations(context); saveViolationsByPriority(context); - saveViolationsByCategory(context); saveViolationsByRule(context); } @@ -105,18 +101,6 @@ public class ViolationsDecorator implements Decorator { return metric; } - private void saveViolationsByCategory(DecoratorContext context) { - Collection children = context.getChildrenMeasures(MeasuresFilters.ruleCategories(CoreMetrics.VIOLATIONS)); - for (Measure childMeasure : children) { - RuleMeasure childCategMeasure = (RuleMeasure) childMeasure; - categories.add(childCategMeasure.getRuleCategory(), childCategMeasure.getValue().intValue()); - } - - for (Multiset.Entry entry : categories.entrySet()) { - context.saveMeasure(RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, entry.getElement(), (double) entry.getCount())); - } - } - private void saveViolationsByRule(DecoratorContext context) { Collection children = context.getChildrenMeasures(MeasuresFilters.rules(CoreMetrics.VIOLATIONS)); for (Measure childMeasure : children) { @@ -130,7 +114,6 @@ public class ViolationsDecorator implements Decorator { for (Multiset.Entry entry : rules.entrySet()) { Rule rule = entry.getElement(); RuleMeasure measure = RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule, (double) entry.getCount()); - measure.setRuleCategory(rule.getCategoryId()); measure.setRulePriority(ruleToLevel.get(rule)); context.saveMeasure(measure); } @@ -146,7 +129,6 @@ public class ViolationsDecorator implements Decorator { List violations = context.getViolations(); for (Violation violation : violations) { rules.add(violation.getRule()); - categories.add(violation.getRule().getCategoryId()); priorities.add(violation.getPriority()); ruleToLevel.put(violation.getRule(), violation.getPriority()); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDensityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDensityDecorator.java index 0f4e9714fd9..d09a3be007f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDensityDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDensityDecorator.java @@ -23,45 +23,18 @@ import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependedUpon; import org.sonar.api.batch.DependsUpon; -import org.sonar.jpa.dao.RulesDao; -import org.sonar.api.measures.*; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.measures.Measure; +import org.sonar.api.measures.MeasureUtils; +import org.sonar.api.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import org.sonar.api.resources.ResourceUtils; -import org.sonar.api.rules.Iso9126RulesCategories; -import org.sonar.api.rules.RulesCategory; -import java.util.*; +import java.util.Arrays; +import java.util.List; public class ViolationsDensityDecorator implements Decorator { - private Map metricByCategoryId; - - public ViolationsDensityDecorator(RulesDao rulesDao) { - metricByCategoryId = new HashMap(); - for (RulesCategory category : rulesDao.getCategories()) { - if (category.equals(Iso9126RulesCategories.EFFICIENCY)) { - metricByCategoryId.put(category.getId(), CoreMetrics.EFFICIENCY); - - } else if (category.equals(Iso9126RulesCategories.MAINTAINABILITY)) { - metricByCategoryId.put(category.getId(), CoreMetrics.MAINTAINABILITY); - - } else if (category.equals(Iso9126RulesCategories.PORTABILITY)) { - metricByCategoryId.put(category.getId(), CoreMetrics.PORTABILITY); - - } else if (category.equals(Iso9126RulesCategories.RELIABILITY)) { - metricByCategoryId.put(category.getId(), CoreMetrics.RELIABILITY); - - } else if (category.equals(Iso9126RulesCategories.USABILITY)) { - metricByCategoryId.put(category.getId(), CoreMetrics.USABILITY); - } - } - } - - protected ViolationsDensityDecorator(Map metricByCategoryId) { - this.metricByCategoryId = metricByCategoryId; - } - public boolean shouldExecuteOnProject(Project project) { return true; } @@ -78,7 +51,7 @@ public class ViolationsDensityDecorator implements Decorator { public void decorate(Resource resource, DecoratorContext context) { if (shouldDecorateResource(context)) { - decorateDensity(resource, context); + decorateDensity(context); } } @@ -86,13 +59,10 @@ public class ViolationsDensityDecorator implements Decorator { return context.getMeasure(CoreMetrics.VIOLATIONS_DENSITY) == null; } - private void decorateDensity(Resource resource, DecoratorContext context) { + private void decorateDensity(DecoratorContext context) { Measure ncloc = context.getMeasure(CoreMetrics.NCLOC); if (MeasureUtils.hasValue(ncloc) && ncloc.getValue() > 0.0) { saveDensity(context, ncloc.getValue().intValue()); - if (ResourceUtils.isSpace(resource) || ResourceUtils.isSet(resource)) { - saveDensityByCategory(context, ncloc.getValue().intValue()); - } } } @@ -112,27 +82,6 @@ public class ViolationsDensityDecorator implements Decorator { return rci; } - private void saveDensityByCategory(DecoratorContext context, int ncloc) { - Collection categDebts = context.getMeasures(MeasuresFilters.ruleCategories(CoreMetrics.WEIGHTED_VIOLATIONS)); - Set categIdsDone = new HashSet(); - if (categDebts != null) { - for (RuleMeasure categDebt : categDebts) { - if (MeasureUtils.hasValue(categDebt)) { - double density = calculate(categDebt.getValue().intValue(), ncloc); - context.saveMeasure(RuleMeasure.createForCategory( - CoreMetrics.VIOLATIONS_DENSITY, categDebt.getRuleCategory(), density)); - context.saveMeasure(metricByCategoryId.get(categDebt.getRuleCategory()), density); - categIdsDone.add(categDebt.getRuleCategory()); - } - } - } - for (Map.Entry entry : metricByCategoryId.entrySet()) { - if (!categIdsDone.contains(entry.getKey())) { - context.saveMeasure(entry.getValue(), 100.0); - } - } - } - @Override public String toString() { return getClass().getSimpleName(); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/WeightedViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/WeightedViolationsDecorator.java index 36c993e4d7d..fdffd293ac0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/WeightedViolationsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/WeightedViolationsDecorator.java @@ -21,7 +21,6 @@ package org.sonar.plugins.core.sensors; import com.google.common.collect.Multiset; import com.google.common.collect.TreeMultiset; -import org.apache.commons.lang.ObjectUtils; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependedUpon; @@ -33,7 +32,6 @@ import org.sonar.api.rules.RulePriority; import org.sonar.api.rules.RuleUtils; import org.sonar.api.utils.KeyValueFormat; -import java.util.HashMap; import java.util.Map; public class WeightedViolationsDecorator implements Decorator { @@ -76,27 +74,17 @@ public class WeightedViolationsDecorator implements Decorator { double debt = 0.0; Multiset violationsByPriority = TreeMultiset.create(); - Map categoryDebt = new HashMap(); for (RuleMeasure violations : context.getMeasures(MeasuresFilters.rules(CoreMetrics.VIOLATIONS))) { if (MeasureUtils.hasValue(violations)) { violationsByPriority.add(violations.getRulePriority(), violations.getValue().intValue()); double add = (int) weights.get(violations.getRulePriority()) * violations.getValue(); debt += add; - - Double categoryVal = (Double) ObjectUtils.defaultIfNull(categoryDebt.get(violations.getRuleCategory()), 0.0); - categoryDebt.put(violations.getRuleCategory(), categoryVal + add); } } Measure debtMeasure = new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, debt, KeyValueFormat.format(violationsByPriority)); saveMeasure(context, debtMeasure); - - for (Map.Entry entry : categoryDebt.entrySet()) { - RuleMeasure categDebt = RuleMeasure.createForCategory(CoreMetrics.WEIGHTED_VIOLATIONS, entry.getKey(), entry.getValue()); - categDebt.setPersistenceMode(PersistenceMode.MEMORY); - saveMeasure(context, categDebt); - } } private void saveMeasure(DecoratorContext context, Measure debtMeasure) { @@ -105,7 +93,4 @@ public class WeightedViolationsDecorator implements Decorator { } } - protected Map getWeights() { - return weights; - } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java index d4bdf234a6c..aa656b01db0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java @@ -141,7 +141,7 @@ public class VariationDecorator implements Decorator { // improvements : keep query in cache ? select only some columns ? // TODO support measure on rules and characteristics String hql = "select m from " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s " + - "where m.snapshotId=s.id and m.metricId in (:metricIds) and m.ruleId=null and m.rulePriority=null and m.rulesCategoryId=null and m.characteristic=null " + "where m.snapshotId=s.id and m.metricId in (:metricIds) and m.ruleId=null and m.rulePriority=null and m.characteristic=null " + "and (s.rootId=:rootSnapshotId or s.id=:rootSnapshotId) and s.resourceId=:resourceId and s.status=:status"; return session.createQuery(hql) .setParameter("metricIds", metricByIds.keySet()) @@ -159,14 +159,12 @@ public class VariationDecorator implements Decorator { static class MeasureKey { Integer metricId; Integer ruleId; - Integer categoryId; RulePriority priority; Characteristic characteristic; MeasureKey(MeasureModel model) { metricId = model.getMetricId(); ruleId = model.getRuleId(); - categoryId = model.getRulesCategoryId(); priority = model.getRulePriority(); characteristic = model.getCharacteristic(); } @@ -177,8 +175,7 @@ public class VariationDecorator implements Decorator { // TODO merge RuleMeasure into Measure if (measure instanceof RuleMeasure) { RuleMeasure rm = (RuleMeasure) measure; - categoryId = rm.getRuleCategory(); - ruleId = (rm.getRule()==null ? null : rm.getRule().getId()); + ruleId = (rm.getRule() == null ? null : rm.getRule().getId()); priority = rm.getRulePriority(); } } @@ -190,7 +187,6 @@ public class VariationDecorator implements Decorator { MeasureKey that = (MeasureKey) o; - if (categoryId != null ? !categoryId.equals(that.categoryId) : that.categoryId != null) return false; if (characteristic != null ? !characteristic.equals(that.characteristic) : that.characteristic != null) return false; if (!metricId.equals(that.metricId)) return false; @@ -204,7 +200,6 @@ public class VariationDecorator implements Decorator { public int hashCode() { int result = metricId.hashCode(); result = 31 * result + (ruleId != null ? ruleId.hashCode() : 0); - result = 31 * result + (categoryId != null ? categoryId.hashCode() : 0); result = 31 * result + (priority != null ? priority.hashCode() : 0); result = 31 * result + (characteristic != null ? characteristic.hashCode() : 0); return result; diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb index d5f617a1649..83ff6fed336 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb @@ -1,55 +1,14 @@ <% if measure(Metric::LINES) %> - - - +
-
-

Rules compliance

-
- <%= format_measure(Metric::VIOLATIONS_DENSITY, :url => url_for_drilldown(Metric::WEIGHTED_VIOLATIONS, {:highlight => Metric::WEIGHTED_VIOLATIONS})) -%> <%= trend_icon(Metric::VIOLATIONS_DENSITY) -%> -
- <% - maintainability=@snapshot.measure(Metric::MAINTAINABILITY) - efficiency=@snapshot.measure(Metric::EFFICIENCY) - usability=@snapshot.measure(Metric::USABILITY) - reliability=@snapshot.measure(Metric::RELIABILITY) - portability=@snapshot.measure(Metric::PORTABILITY) - %> - -
-
+ +
+
+

Rules compliance

+
+ <%= format_measure(Metric::VIOLATIONS_DENSITY, :url => url_for_drilldown(Metric::WEIGHTED_VIOLATIONS, {:highlight => Metric::WEIGHTED_VIOLATIONS})) -%> <%= trend_icon(Metric::VIOLATIONS_DENSITY) -%> +
+
+

Violations

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb index 3dcce9a099e..bf89a8e1903 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb @@ -50,8 +50,11 @@ if measure('lines') || measure('ncloc')

<%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= trend_icon('directories') -%>

<% end %>

<%= format_measure('functions', :suffix => ' methods', :url => url_for_drilldown('functions')) -%> <%= trend_icon('functions') -%>

- <% if (measure('accessors')) %> -

<%= format_measure('accessors', :prefix => '+', :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= trend_icon('accessors') -%>

+ <% + if (measure('accessors')) + prefix=(dashboard_configuration.variation? ? '' : '+') + %> +

<%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= trend_icon('accessors') -%>

<% end %> <% if measure('paragraphs') %>

<%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= trend_icon('paragraphs') -%>

diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDecoratorTest.java index 2c1514946c1..eb370afdad9 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDecoratorTest.java @@ -19,19 +19,6 @@ */ package org.sonar.plugins.core.sensors; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.DecoratorContext; @@ -41,14 +28,19 @@ import org.sonar.api.measures.MeasuresFilter; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; -import org.sonar.api.rules.RulesCategory; import org.sonar.api.rules.Violation; import org.sonar.api.test.IsMeasure; import org.sonar.api.test.IsRuleMeasure; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.argThat; +import static org.mockito.Mockito.*; + public class ViolationsDecoratorTest { - private RulesCategory categA; - private RulesCategory categB; private Rule ruleA1; private Rule ruleA2; private Rule ruleB1; @@ -58,15 +50,9 @@ public class ViolationsDecoratorTest { @Before public void before() { - categA = new RulesCategory("Maintainability"); - categA.setId(1); - - categB = new RulesCategory("Usability"); - categB.setId(2); - - ruleA1 = Rule.create().setPluginName("ruleA1").setKey("ruleA1").setName("nameA1").setRulesCategory(categA); - ruleA2 = Rule.create().setPluginName("ruleA2").setKey("ruleA2").setName("nameA2").setRulesCategory(categA); - ruleB1 = Rule.create().setPluginName("ruleB1").setKey("ruleB1").setName("nameB1").setRulesCategory(categB); + ruleA1 = Rule.create().setPluginName("ruleA1").setKey("ruleA1").setName("nameA1"); + ruleA2 = Rule.create().setPluginName("ruleA2").setKey("ruleA2").setName("nameA2"); + ruleB1 = Rule.create().setPluginName("ruleB1").setKey("ruleB1").setName("nameB1"); decorator = new ViolationsDecorator(); resource = mock(Resource.class); @@ -142,18 +128,6 @@ public class ViolationsDecoratorTest { verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.INFO_VIOLATIONS, 0.0))); } - @Test - public void categoryViolations() throws Exception { - when(resource.getScope()).thenReturn(Resource.SCOPE_SET); - when(context.getViolations()).thenReturn(createViolations()); - when(context.getChildrenMeasures((MeasuresFilter) anyObject())).thenReturn(Collections. emptyList()); - - decorator.decorate(resource, context); - - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.VIOLATIONS, null, categA.getId(), null, 3.0))); - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.VIOLATIONS, null, categB.getId(), null, 1.0))); - } - private List createViolations() { List violations = new ArrayList(); violations.add(Violation.create(ruleA1, resource).setPriority(RulePriority.CRITICAL)); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDensityDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDensityDecoratorTest.java index cf4bca69fc3..7bf1650e570 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDensityDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDensityDecoratorTest.java @@ -19,19 +19,16 @@ */ package org.sonar.plugins.core.sensors; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; import org.junit.Test; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.measures.*; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.measures.Measure; import org.sonar.api.resources.Resource; -import org.sonar.api.rules.Rule; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; public class ViolationsDensityDecoratorTest { @@ -53,7 +50,7 @@ public class ViolationsDensityDecoratorTest { when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 50.0)); - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(new HashMap()); + ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(); decorator.decorate(resource, context); verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 75.0); @@ -68,7 +65,7 @@ public class ViolationsDensityDecoratorTest { when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 0.0)); when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 50.0)); - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(new HashMap()); + ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(); decorator.decorate(resource, context); verify(context, never()).saveMeasure(eq(CoreMetrics.VIOLATIONS_DENSITY), anyDouble()); @@ -83,7 +80,7 @@ public class ViolationsDensityDecoratorTest { when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 5000.0)); - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(new HashMap()); + ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(); decorator.decorate(resource, context); verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 0.0); @@ -97,7 +94,7 @@ public class ViolationsDensityDecoratorTest { DecoratorContext context = mock(DecoratorContext.class); when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(new HashMap()); + ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(); decorator.decorate(resource, context); verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 100.0); @@ -112,62 +109,9 @@ public class ViolationsDensityDecoratorTest { when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 0.0)); - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(new HashMap()); + ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(); decorator.decorate(resource, context); verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 100.0); } - - @Test - public void densityByCategory() { - Map metricByCategoryId = new HashMap(); - metricByCategoryId.put(3, CoreMetrics.USABILITY); - metricByCategoryId.put(5, CoreMetrics.EFFICIENCY); - metricByCategoryId.put(6, CoreMetrics.RELIABILITY); - - Resource resource = mock(Resource.class); - when(resource.getScope()).thenReturn(Resource.SCOPE_SET); - - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); - when(context.getMeasures((MeasuresFilter) anyObject())) - .thenReturn(Arrays.asList( - new RuleMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, new Rule(), null, 3).setValue(50.0), - new RuleMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, new Rule(), null, 5).setValue(0.0))); - - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(metricByCategoryId); - decorator.decorate(resource, context); - - verify(context).saveMeasure(CoreMetrics.USABILITY, 75.0); - verify(context).saveMeasure(CoreMetrics.EFFICIENCY, 100.0); - verify(context).saveMeasure(CoreMetrics.RELIABILITY, 100.0); - } - - @Test - public void doNotCalculateDensityByCategoryOnEntities() { - Map metricByCategoryId = new HashMap(); - metricByCategoryId.put(3, CoreMetrics.USABILITY); - metricByCategoryId.put(5, CoreMetrics.EFFICIENCY); - metricByCategoryId.put(6, CoreMetrics.RELIABILITY); - - Resource resource = mock(Resource.class); - when(resource.getScope()).thenReturn(Resource.SCOPE_ENTITY); - - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 200.0)); - when(context.getMeasure(CoreMetrics.WEIGHTED_VIOLATIONS)).thenReturn(new Measure(CoreMetrics.WEIGHTED_VIOLATIONS, 50.0)); - when(context.getMeasures((MeasuresFilter) anyObject())) - .thenReturn(Arrays.asList( - new RuleMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, new Rule(), null, 3).setValue(50.0), - new RuleMeasure(CoreMetrics.WEIGHTED_VIOLATIONS, new Rule(), null, 5).setValue(0.0))); - - ViolationsDensityDecorator decorator = new ViolationsDensityDecorator(metricByCategoryId); - decorator.decorate(resource, context); - - verify(context, never()).saveMeasure(eq(CoreMetrics.USABILITY), anyDouble()); - verify(context, never()).saveMeasure(eq(CoreMetrics.EFFICIENCY), anyDouble()); - verify(context, never()).saveMeasure(eq(CoreMetrics.RELIABILITY), anyDouble()); - verify(context, never()).saveMeasure(eq(CoreMetrics.MAINTAINABILITY), anyDouble()); - verify(context).saveMeasure(CoreMetrics.VIOLATIONS_DENSITY, 75.0); - } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/WeightedViolationsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/WeightedViolationsDecoratorTest.java index f02934a6dbf..c6bb156ecba 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/WeightedViolationsDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/WeightedViolationsDecoratorTest.java @@ -20,7 +20,6 @@ package org.sonar.plugins.core.sensors; import org.junit.Test; -import static org.mockito.Mockito.*; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; @@ -30,13 +29,14 @@ import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; import org.sonar.api.test.IsMeasure; -import org.sonar.api.test.IsRuleMeasure; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.mockito.Mockito.*; + public class WeightedViolationsDecoratorTest { @@ -92,25 +92,4 @@ public class WeightedViolationsDecoratorTest { verify(context, never()).saveMeasure((Measure) anyObject()); } - @Test - public void weightedViolationsOnCategories() { - Map weights = createWeights(); - - WeightedViolationsDecorator decorator = new WeightedViolationsDecorator(weights); - DecoratorContext context = mock(DecoratorContext.class); - - when(context.getMeasures((MeasuresFilter) anyObject())).thenReturn(createViolationsMeasures()); - - decorator.decorate(mock(Resource.class), context); - - // categ 3 - verify(context).saveMeasure(argThat(new IsRuleMeasure( - CoreMetrics.WEIGHTED_VIOLATIONS, null, 3, null, 40.0 * 0 + 80.0 * 5 + 90.0 * 10))); - - // categ 4 - verify(context).saveMeasure(argThat(new IsRuleMeasure( - CoreMetrics.WEIGHTED_VIOLATIONS, null, 4, null, 10.0 * 0 + 10.0 * 10))); - - } - } diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/VariationDecoratorTest/shared.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/VariationDecoratorTest/shared.xml index 21775e03e2b..69fc7dcba5b 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/VariationDecoratorTest/shared.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/VariationDecoratorTest/shared.xml @@ -9,11 +9,11 @@ - - diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java index c0eb8f36207..52943fcbef9 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java @@ -48,7 +48,7 @@ public final class PurgeRuleMeasures extends Purge { private void purge(Integer sid) { Query query = getSession().createQuery("SELECT m.id FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s WHERE s.id = m.snapshotId and " + - "(s.rootId=:rootSid OR s.id=:rootSid) and (m.ruleId is not null or m.rulesCategoryId is not null or m.rulePriority is not null)"); + "(s.rootId=:rootSid OR s.id=:rootSid) and (m.ruleId is not null or m.rulePriority is not null)"); query.setParameter("rootSid", sid); List measureIds = query.getResultList(); PurgeUtils.deleteMeasuresById(getSession(), measureIds); diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml index c321f46a952..3fd2105c578 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml @@ -1,6 +1,6 @@ - - + - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml index 4b40be0a4f4..e649516b41b 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml @@ -1,6 +1,6 @@ - diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent-result.xml index 3f3dd37e388..3e463135c2f 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent-result.xml @@ -24,7 +24,7 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent.xml index 278cd25cd11..53fc6ff607f 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleanerTest/dbContent.xml @@ -30,7 +30,7 @@ to ensure that unit tests pass on any locale. diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml index 93ccdc138b0..b4f7e36312c 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml @@ -33,28 +33,28 @@ - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml index 81c8a47cfa4..9db1e9b727b 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml @@ -33,28 +33,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml index 8d4d27778c7..d11bd33fdd1 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml @@ -1,6 +1,6 @@ - - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml index 7fea60a4cc1..ef4d986f055 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml @@ -36,28 +36,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml index 8d4d27778c7..d11bd33fdd1 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml @@ -1,6 +1,6 @@ - @@ -81,7 +81,7 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml index 79f80fb1f59..2f2ad96c06b 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml @@ -52,28 +52,28 @@ @@ -81,7 +81,7 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml index 7c789ff4831..cf5ea35113a 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml @@ -45,28 +45,28 @@ - + - + - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml index 809b7d64888..43770744db0 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml @@ -48,28 +48,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml index 97f609d82c7..8882a13385c 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml @@ -63,28 +63,28 @@ - + - + - + - + @@ -92,14 +92,14 @@ - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml index c9160b96dbd..957344e9286 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml @@ -68,28 +68,28 @@ @@ -97,14 +97,14 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml index eee1bfaad3c..d79d906a17d 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml @@ -1,6 +1,6 @@ - - + - + @@ -99,28 +99,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml index 09ca143bc24..caeaa7c7b8b 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml @@ -69,28 +69,28 @@ @@ -99,28 +99,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml index 8d4d27778c7..d11bd33fdd1 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml @@ -1,6 +1,6 @@ - diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml index 44d3946f097..663af150574 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml @@ -67,7 +67,7 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml index d4e59f25a41..d65258e2be5 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml @@ -1,6 +1,6 @@ - @@ -99,28 +99,28 @@ - + - + - + - + diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml index 29e7b983969..36a758cbce8 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml @@ -69,28 +69,28 @@ @@ -99,28 +99,28 @@ diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml index 8d4d27778c7..d11bd33fdd1 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml @@ -1,6 +1,6 @@ - diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shared.xml index 1f5082e2a98..a660a0f062b 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shared.xml @@ -3,11 +3,11 @@ - - diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldInsertViolations-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldInsertViolations-result.xml index 7cf69ed7856..ae33c698e21 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldInsertViolations-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldInsertViolations-result.xml @@ -2,11 +2,11 @@ - - diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml index c9d0e44f0d2..1830e9a2c56 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml @@ -2,11 +2,11 @@ - - diff --git a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot-result.xml index bf3183aac81..2835fcadc1b 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot-result.xml @@ -68,13 +68,13 @@ @@ -88,13 +88,13 @@ @@ -114,7 +114,7 @@ alert_status="[null]" description="[null]"/> @@ -134,13 +134,13 @@ @@ -153,13 +153,13 @@ diff --git a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot.xml b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot.xml index e16dbfd1667..2a01556a42e 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/lastSnapshotIsNotUpdatedWhenAnalyzingPastSnapshot.xml @@ -69,13 +69,13 @@ @@ -89,13 +89,13 @@ @@ -115,7 +115,7 @@ alert_status="[null]" description="[null]"/> @@ -135,13 +135,13 @@ @@ -154,13 +154,13 @@ diff --git a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/sharedFixture.xml b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/sharedFixture.xml index 00420a0362f..48565e5fbdf 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/sharedFixture.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/phases/UpdateStatusJobTest/sharedFixture.xml @@ -1,6 +1,6 @@ - rulesCategories; - public RulesDao(DatabaseSession session) { super(session); } @@ -45,39 +45,18 @@ public class RulesDao extends BaseDao { return getSession().getResults(Rule.class, "pluginName", pluginKey, "enabled", true); } - public List getRulesByCategory(RulesCategory categ) { - List result = new ArrayList(); - for (Rule rule : getRules()) { - if (rule.getRulesCategory().equals(categ)) { - result.add(rule); - } - } - return result; - } public Rule getRuleByKey(String pluginKey, String ruleKey) { return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", pluginKey, "enabled", true); } - public Long countRules(List plugins, String categoryName) { + public Long countRules(List plugins) { return (Long) getSession().createQuery( - "SELECT COUNT(r) FROM Rule r WHERE r.pluginName IN (:pluginNames) AND r.rulesCategory=:rulesCategory AND r.enabled=true"). + "SELECT COUNT(r) FROM Rule r WHERE r.pluginName IN (:pluginNames) AND r.enabled=true"). setParameter("pluginNames", plugins). - setParameter("rulesCategory", getCategory(categoryName)). getSingleResult(); } - public List getCategories() { - if (rulesCategories == null) { - rulesCategories = getSession().getResults(RulesCategory.class); - } - return rulesCategories; - } - - public RulesCategory getCategory(String key) { - return getSession().getSingleResult(RulesCategory.class, "name", key); - } - public List getRuleParams() { return getSession().getResults(RuleParam.class); @@ -96,13 +75,6 @@ public class RulesDao extends BaseDao { } } - public void deleteActiveRuleParameters(RuleParam ruleParam) { - getSession().createQuery( - "DELETE FROM ActiveRuleParam arp WHERE ruleParam=:param") - .setParameter("param", ruleParam) - .executeUpdate(); - } - public List getViolations(Snapshot snapshot) { return getSession().getResults(RuleFailureModel.class, "snapshotId", snapshot.getId()); } diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java index 5d9eb70c3bc..0be085d8be8 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java @@ -30,7 +30,7 @@ import java.sql.Statement; public class SchemaMigration { public final static int VERSION_UNKNOWN = -1; - public static final int LAST_VERSION = 161; + public static final int LAST_VERSION = 162; public final static String TABLE_NAME = "schema_migrations"; diff --git a/sonar-core/src/main/resources/ehcache.xml b/sonar-core/src/main/resources/ehcache.xml index 99e2597c98e..9385f272c34 100644 --- a/sonar-core/src/main/resources/ehcache.xml +++ b/sonar-core/src/main/resources/ehcache.xml @@ -70,7 +70,7 @@ overflowToDisk="false"/> \ No newline at end of file diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java index 30dc9fc0602..4656c20bb1b 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java @@ -51,7 +51,6 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { assertEquals("rule_one", rules.get(0).getKey()); assertEquals(1, rules.get(0).getParams().size()); - assertEquals("category one", rules.get(0).getRulesCategory().getName()); } @Test @@ -66,17 +65,6 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { assertThat(rule2, nullValue()); } - @Test - public void shouldCountNumberOfRulesOfACategoryForGivenPlugins() { - setupData("shouldCountNumberOfRulesOfACategoryForGivenPlugins"); - - Long result = rulesDao.countRules(Arrays.asList("plugin1", "plugin2"), "category one"); - assertThat(result, is(3L)); - - result = rulesDao.countRules(Arrays.asList("plugin1", "plugin2"), "category two"); - assertThat(result, is(1L)); - } - @Test public void shouldGetRuleParams() { setupData("shouldGetRuleParams"); @@ -116,7 +104,7 @@ public class RulesDaoTest extends AbstractDbUnitTestCase { public void shouldAddActiveRulesToProfile() { setupData("shouldAddActiveRulesToProfile"); - Rule rule = new Rule("rule1", "key1", "config1", new RulesCategory("test"), null); + Rule rule = new Rule("rule1", "key1", "config1", null, null); RuleParam ruleParam = new RuleParam(null, "param1", null, null); rule.setParams(Arrays.asList(ruleParam)); diff --git a/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml index f6adafee0da..de08ce13d22 100644 --- a/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/components/CacheRuleFinderTest/shared.xml @@ -3,18 +3,18 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml index f6adafee0da..de08ce13d22 100644 --- a/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/components/DefaultRuleFinderTest/shared.xml @@ -3,18 +3,18 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml index c7059375406..6818bf4c09e 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml @@ -4,7 +4,7 @@ - diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml index f30fb8d64d9..19b124c737d 100644 --- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml +++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile.xml @@ -4,7 +4,7 @@ - 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 edb6c8d9271..86c8d928eee 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 @@ -3,15 +3,15 @@ - - - - \ 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 71c8345bb80..5f86b049240 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 @@ -2,7 +2,7 @@ - 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 90456d43522..f2d17bc78be 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 @@ -2,7 +2,7 @@ - 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 58dc223fc1f..736de8e2412 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 @@ -5,11 +5,11 @@ - - - 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 ffd0336d51f..89f2fecf7cf 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 @@ -5,11 +5,11 @@ - - - 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 58dc223fc1f..736de8e2412 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 @@ -5,11 +5,11 @@ - - - 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 2eded82f21f..7df82f67476 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 @@ -3,9 +3,9 @@ - - 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 00de02226cf..42176327e03 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 @@ -2,7 +2,7 @@ - \ 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 9190f5bcdab..303865ba8fb 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 @@ -2,9 +2,9 @@ - - - - diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java index fa96311c8db..3ebc5a99c0f 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java @@ -22,8 +22,10 @@ package org.sonar.api.checks.templates; import org.apache.commons.io.IOUtils; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Language; -import org.sonar.api.rules.*; -import org.sonar.check.IsoCategory; +import org.sonar.api.rules.Rule; +import org.sonar.api.rules.RuleParam; +import org.sonar.api.rules.RulePriority; +import org.sonar.api.rules.RulesRepository; import java.io.InputStream; import java.util.*; @@ -134,20 +136,12 @@ public class CheckTemplateRepository implements RulesRepository { } - - - - - - - - /* - CODE FOR BACKWARD COMPATIBLITY - This class should not extend RulesRepository in next versions + CODE FOR BACKWARD COMPATIBLITY + This class should not extend RulesRepository in next versions - */ + */ public List getInitialReferential() { @@ -163,7 +157,6 @@ public class CheckTemplateRepository implements RulesRepository { rule.setDescription(checkTemplate.getDescription(Locale.ENGLISH)); rule.setName(checkTemplate.getTitle(Locale.ENGLISH)); rule.setPriority(RulePriority.fromCheckPriority(checkTemplate.getPriority())); - rule.setRulesCategory(toRuleCategory(checkTemplate.getIsoCategory())); for (CheckTemplateProperty checkTemplateProperty : checkTemplate.getProperties()) { RuleParam param = rule.createParameter(checkTemplateProperty.getKey()); param.setDescription(checkTemplateProperty.getDescription(Locale.ENGLISH)); @@ -173,26 +166,6 @@ public class CheckTemplateRepository implements RulesRepository { return rule; } - private RulesCategory toRuleCategory(IsoCategory isoCategory) { - if (isoCategory == IsoCategory.Reliability) { - return Iso9126RulesCategories.RELIABILITY; - } - if (isoCategory == IsoCategory.Efficiency) { - return Iso9126RulesCategories.EFFICIENCY; - } - if (isoCategory == IsoCategory.Maintainability) { - return Iso9126RulesCategories.MAINTAINABILITY; - } - if (isoCategory == IsoCategory.Portability) { - return Iso9126RulesCategories.PORTABILITY; - } - if (isoCategory == IsoCategory.Usability) { - return Iso9126RulesCategories.USABILITY; - } - return null; - } - - public List parseReferential(String fileContent) { return Collections.emptyList(); } diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java index 0b51222c53d..1de8a616a0c 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java @@ -75,7 +75,6 @@ public class XmlCheckTemplateFactory { template.setConfigKey(rule.getConfigKey()); template.setDescription(rule.getDescription()); - template.setIsoCategory(rule.getRulesCategory().toIsoCategory()); template.setPriority(rule.getPriority().toCheckPriority()); template.setTitle(rule.getName()); diff --git a/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java b/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java index 1d5d5fb90bc..cb7842f049d 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java @@ -27,6 +27,7 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleParam; import org.sonar.api.rules.RulesCategory; +import java.util.Collections; import java.util.List; @Deprecated @@ -47,7 +48,7 @@ public class RulesDao { } public List getRulesByCategory(RulesCategory categ) { - return target.getRulesByCategory(categ); + return Collections.emptyList(); } public Rule getRuleByKey(String pluginKey, String ruleKey) { @@ -55,15 +56,15 @@ public class RulesDao { } public Long countRules(List plugins, String categoryName) { - return target.countRules(plugins, categoryName); + return target.countRules(plugins); } public List getCategories() { - return target.getCategories(); + return Collections.emptyList(); } public RulesCategory getCategory(String key) { - return target.getCategory(key); + return null; } diff --git a/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java b/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java index e532df1d040..58b8c69abbc 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java @@ -105,9 +105,7 @@ public class StandardRulesXmlParser { xstream.registerConverter(new TrimStringConverter()); xstream.alias("rules", ArrayList.class); - xstream.alias("categ", RulesCategory.class); - xstream.useAttributeFor(RulesCategory.class, "name"); - xstream.aliasField("category", Rule.class, "rulesCategory"); + xstream.omitField(Rule.class, "category"); xstream.alias("rule", Rule.class); xstream.useAttributeFor(Rule.class, "key"); diff --git a/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java b/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java index 30bc75f9f89..cdccbf1875b 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java @@ -20,15 +20,15 @@ package org.sonar.api.rules; import org.apache.commons.io.IOUtils; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.*; - import org.junit.Assert; import org.junit.Test; import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.*; + public class StandardRulesXmlParserTest { @Test public void checkAllFields() { @@ -48,26 +48,12 @@ public class StandardRulesXmlParserTest { Assert.assertEquals("param description", rule.getParams().get(0).getDescription()); } - @Test - public void ruleShouldHaveACategory() { - StandardRulesXmlParser parser = new StandardRulesXmlParser(); - String xml = ""; - List rules = parser.parse(xml); - assertNotNull(rules.get(0).getRulesCategory()); - Assert.assertEquals("cat1", rules.get(0).getRulesCategory().getName()); - assertNull(rules.get(0).getRulesCategory().getId()); - assertNull(rules.get(0).getRulesCategory().getDescription()); - } - @Test public void ruleCanHaveALevel() { StandardRulesXmlParser parser = new StandardRulesXmlParser(); String xml = ""; List rules = parser.parse(xml); - assertNotNull(rules.get(0).getRulesCategory()); Assert.assertEquals(RulePriority.CRITICAL, rules.get(0).getPriority()); - assertNull(rules.get(0).getRulesCategory().getId()); - assertNull(rules.get(0).getRulesCategory().getDescription()); } @Test @@ -101,10 +87,10 @@ public class StandardRulesXmlParserTest { @Test public void shouldContainCDataDescription() { StandardRulesXmlParser parser = new StandardRulesXmlParser(); - String xml = " and accents Žˆ˜ ]]> "; + String xml = " and accents ��� ]]> "; List rules = parser.parse(xml); assertEquals(1, rules.size()); - Assert.assertEquals(" and accents Žˆ˜", rules.get(0).getDescription()); + Assert.assertEquals(" and accents ���", rules.get(0).getDescription()); } @Test diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java index e829e6e786e..e9833d626e9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java @@ -72,7 +72,11 @@ public class MeasureModel implements Cloneable { @Column(name = "rule_id", updatable = true, nullable = true) private Integer ruleId; - @Column(name = "rules_category_id") + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated + @Column(name = "rules_category_id", nullable = true) private Integer rulesCategoryId; @Column(name = "rule_priority", updatable = false, nullable = true) @@ -216,7 +220,7 @@ public class MeasureModel implements Cloneable { * @return whether the measure is about rule */ public boolean isRuleMeasure() { - return ruleId != null || rulePriority != null || rulesCategoryId != null; + return ruleId != null || rulePriority != null; } /** @@ -269,19 +273,18 @@ public class MeasureModel implements Cloneable { } /** - * @return the rule category id + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 */ + @Deprecated public Integer getRulesCategoryId() { - return rulesCategoryId; + return null; } /** - * Sets the rule category id - * - * @return the current object + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 */ + @Deprecated public MeasureModel setRulesCategoryId(Integer id) { - this.rulesCategoryId = id; return this; } @@ -526,7 +529,6 @@ public class MeasureModel implements Cloneable { clone.setDiffValue2(getDiffValue2()); clone.setDiffValue3(getDiffValue3()); clone.setValue(getValue()); - clone.setRulesCategoryId(getRulesCategoryId()); clone.setRulePriority(getRulePriority()); clone.setRuleId(getRuleId()); clone.setSnapshotId(getSnapshotId()); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index cf6cacfb657..0954951f490 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -19,6 +19,7 @@ */ package org.sonar.api.measures; +import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.SonarException; import java.lang.reflect.Field; @@ -41,7 +42,13 @@ public final class CoreMetrics { public static final String DOMAIN_COMPLEXITY = "Complexity"; public static final String DOMAIN_DOCUMENTATION = "Documentation"; public static final String DOMAIN_RULES = "Rules"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String DOMAIN_RULE_CATEGORIES = "Rule categories"; + public static final String DOMAIN_GENERAL = "General"; public static final String DOMAIN_DUPLICATION = "Duplication"; public static final String DOMAIN_DESIGN = "Design"; @@ -269,19 +276,68 @@ public final class CoreMetrics { Metric.ValueType.DATA, Metric.DIRECTION_NONE, false, DOMAIN_DUPLICATION); /* coding rules */ + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String USABILITY_KEY = "usability"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final Metric USABILITY = new Metric(USABILITY_KEY, "Usability", "Usability", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String RELIABILITY_KEY = "reliability"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final Metric RELIABILITY = new Metric(RELIABILITY_KEY, "Reliability", "Reliability", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String EFFICIENCY_KEY = "efficiency"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final Metric EFFICIENCY = new Metric(EFFICIENCY_KEY, "Efficiency", "Efficiency", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String PORTABILITY_KEY = "portability"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final Metric PORTABILITY = new Metric(PORTABILITY_KEY, "Portability", "Portability", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final String MAINTAINABILITY_KEY = "maintainability"; + + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static final Metric MAINTAINABILITY = new Metric(MAINTAINABILITY_KEY, "Maintainability", "Maintainability", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); @@ -437,7 +493,10 @@ public final class CoreMetrics { for (Field field : CoreMetrics.class.getFields()) { if (Metric.class.isAssignableFrom(field.getType())) { try { - metrics.add((Metric) field.get(null)); + Metric metric = (Metric) field.get(null); + if (!StringUtils.equals(metric.getDomain(), DOMAIN_RULE_CATEGORIES)) { + metrics.add(metric); + } } catch (IllegalAccessException e) { throw new SonarException("can not load metrics from " + CoreMetrics.class.getSimpleName(), e); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index b9fb26b057d..434fe55e23c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -25,6 +25,7 @@ import org.sonar.api.rules.RulePriority; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -105,6 +106,10 @@ public final class MeasuresFilters { return new RulePriorityFilter(metric, priority); } + /** + * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static MeasuresFilter ruleCategory(final Metric metric, final Integer category) { return new RuleCategoryFilter(metric, category); } @@ -113,26 +118,15 @@ public final class MeasuresFilters { return new RuleFilter(metric, rule); } + /** + * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static MeasuresFilter> ruleCategories(final Metric metric) { return new MetricFilter>(metric) { - private boolean apply(Measure measure) { - return measure instanceof RuleMeasure - && metric.equals(measure.getMetric()) - && ((RuleMeasure) measure).getRule() == null - && ((RuleMeasure) measure).getRuleCategory() != null; - } - public Collection filter(Collection measures) { - List result = new ArrayList(); - if (measures != null) { - for (Measure measure : measures) { - if (apply(measure)) { - result.add((RuleMeasure) measure); - } - } - } - return result; + return Collections.emptyList(); } }; } @@ -213,24 +207,23 @@ public final class MeasuresFilters { @Override boolean doApply(RuleMeasure measure) { return measure.getRule() == null - && measure.getRuleCategory() == null && priority.equals(measure.getRulePriority()); } } + /** + * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated private static class RuleCategoryFilter extends AbstractRuleMeasureFilter { - private Integer categ; protected RuleCategoryFilter(Metric metric, Integer categ) { super(metric); - this.categ = categ; } @Override boolean doApply(RuleMeasure measure) { - return measure.getRule() == null - && categ.equals(measure.getRuleCategory()) - && measure.getRulePriority() == null; + return false; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java index 6ed4ab82a83..76e63950713 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java @@ -32,7 +32,6 @@ public class RuleMeasure extends Measure { private Rule rule; private RulePriority rulePriority; - private Integer ruleCategory; /** * This constructor is for internal use only. Please use static methods createForXXX(). @@ -41,7 +40,6 @@ public class RuleMeasure extends Measure { super(metric); this.rule = rule; this.rulePriority = rulePriority; - this.ruleCategory = ruleCategory; } public Rule getRule() { @@ -60,12 +58,20 @@ public class RuleMeasure extends Measure { this.rulePriority = rulePriority; } +/** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public Integer getRuleCategory() { - return ruleCategory; + return null; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public void setRuleCategory(Integer ruleCategory) { - this.ruleCategory = ruleCategory; + } @Override @@ -81,7 +87,6 @@ public class RuleMeasure extends Measure { .append(getMetric(), other.getMetric()) .append(rule, other.rule) .append(rulePriority, other.rulePriority) - .append(ruleCategory, other.ruleCategory) .isEquals(); } @@ -96,9 +101,7 @@ public class RuleMeasure extends Measure { append(getMetric()). append(rule). append(rulePriority). - append(ruleCategory). toHashCode(); - } @Override @@ -113,7 +116,6 @@ public class RuleMeasure extends Measure { append("alertText", alertText). append("tendency", tendency). append("rule", rule). - append("category", ruleCategory). append("priority", rulePriority). toString(); } @@ -126,6 +128,10 @@ public class RuleMeasure extends Measure { return (RuleMeasure) new RuleMeasure(metric, null, priority, null).setValue(value); } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public static RuleMeasure createForCategory(Metric metric, Integer category, Double value) { return (RuleMeasure) new RuleMeasure(metric, null, null, category).setValue(value); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java index ab89fdb1b0c..d40dc943553 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java @@ -64,7 +64,6 @@ public final class AnnotationRuleParser implements ServerComponent { String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), ruleKey); Rule rule = Rule.create(repositoryKey, ruleKey, ruleName); rule.setDescription(ruleAnnotation.description()); - rule.setRulesCategory(RulesCategory.fromIsoCategory(ruleAnnotation.isoCategory())); rule.setPriority(RulePriority.fromCheckPriority(ruleAnnotation.priority())); rule.setCardinality(ruleAnnotation.cardinality()); @@ -83,7 +82,6 @@ public final class AnnotationRuleParser implements ServerComponent { String ruleName = StringUtils.defaultIfEmpty(checkAnnotation.title(), ruleKey); Rule rule = Rule.create(repositoryKey, ruleKey, ruleName); rule.setDescription(checkAnnotation.description()); - rule.setRulesCategory(RulesCategory.fromIsoCategory(checkAnnotation.isoCategory())); rule.setPriority(RulePriority.fromCheckPriority(checkAnnotation.priority())); Field[] fields = clazz.getDeclaredFields(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java index 88724e603c3..b3628588575 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java @@ -23,6 +23,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +/** + * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007 + */ +@Deprecated public final class Iso9126RulesCategories { private Iso9126RulesCategories() { } 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 a2999a8452b..dcba3549df4 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 @@ -56,10 +56,6 @@ public final class Rule { @Column(name = "plugin_config_key", updatable = true, nullable = true) private String configKey; - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "rules_category_id", updatable = true, nullable = true) - private RulesCategory rulesCategory; - @Column(name = "priority", updatable = true, nullable = true) @Enumerated(EnumType.ORDINAL) private RulePriority priority = DEFAULT_PRIORITY; @@ -123,7 +119,6 @@ public final class Rule { setName(name); this.key = key; this.configKey = key; - this.rulesCategory = rulesCategory; this.priority = priority; this.pluginName = pluginKey; } @@ -137,7 +132,6 @@ public final class Rule { setName(name); this.key = key; this.configKey = key; - this.rulesCategory = rulesCategory; this.pluginName = pluginName; this.description = description; } @@ -151,7 +145,6 @@ public final class Rule { setName(name); this.key = key; this.configKey = configKey; - this.rulesCategory = rulesCategory; this.pluginName = pluginName; this.description = description; } @@ -193,17 +186,18 @@ public final class Rule { } /** - * @return the rule category + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 */ + @Deprecated public RulesCategory getRulesCategory() { - return rulesCategory; + return null; } /** - * Sets the rule category + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 */ + @Deprecated public Rule setRulesCategory(RulesCategory rulesCategory) { - this.rulesCategory = rulesCategory; return this; } @@ -295,10 +289,11 @@ public final class Rule { return parameter; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public Integer getCategoryId() { - if (rulesCategory != null) { - return rulesCategory.getId(); - } return null; } @@ -380,7 +375,6 @@ public final class Rule { .append("name", name) .append("key", key) .append("configKey", configKey) - .append("categ", rulesCategory) .append("plugin", pluginName) .toString(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesCategory.java index 190c739fd03..207a6b01d5f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesCategory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesCategory.java @@ -33,8 +33,9 @@ import javax.persistence.Entity; import javax.persistence.Table; /** - * A class to hold rules category + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 */ +@Deprecated @Immutable @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) @Entity @@ -59,7 +60,7 @@ public class RulesCategory extends BaseIdentifiable { /** * Creates a category based on the category name and description * - * @param name the category name + * @param name the category name * @param description the category description */ public RulesCategory(String name, String description) { @@ -98,6 +99,7 @@ public class RulesCategory extends BaseIdentifiable { /** * Sets the cay description + * * @param description the description */ public void setDescription(String description) { @@ -153,19 +155,19 @@ public class RulesCategory extends BaseIdentifiable { } public static RulesCategory fromIsoCategory(IsoCategory iso) { - if (iso==IsoCategory.Efficiency) { + if (iso == IsoCategory.Efficiency) { return Iso9126RulesCategories.EFFICIENCY; } - if (iso==IsoCategory.Maintainability) { + if (iso == IsoCategory.Maintainability) { return Iso9126RulesCategories.MAINTAINABILITY; } - if (iso==IsoCategory.Portability) { + if (iso == IsoCategory.Portability) { return Iso9126RulesCategories.PORTABILITY; } - if (iso==IsoCategory.Reliability) { + if (iso == IsoCategory.Reliability) { return Iso9126RulesCategories.RELIABILITY; } - if (iso==IsoCategory.Usability) { + if (iso == IsoCategory.Usability) { return Iso9126RulesCategories.USABILITY; } return null; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java index cb0fd725f17..adc70ff30e5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java @@ -134,11 +134,6 @@ public final class XMLRuleParser implements ServerComponent { } else if (StringUtils.equalsIgnoreCase("priority", nodeName)) { rule.setPriority(RulePriority.valueOf(StringUtils.trim(cursor.collectDescendantText(false)))); - } else if (StringUtils.equalsIgnoreCase("category", nodeName)) { - /* BACKWARD COMPATIBILITY WITH DEPRECATED FORMAT : attribute "name" */ - String category = StringUtils.trim(StringUtils.defaultString(cursor.getAttrValue("name"), cursor.collectDescendantText(false))); - rule.setRulesCategory(new RulesCategory(category)); - } else if (StringUtils.equalsIgnoreCase("cardinality", nodeName)) { rule.setCardinality(Cardinality.valueOf(StringUtils.trim(cursor.collectDescendantText(false)))); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java index a9cc3c5aee5..40f32459096 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java @@ -32,7 +32,6 @@ public class Measure { private String ruleKey; private String ruleName; - private String ruleCategory; private String rulePriority; private Date date; @@ -115,12 +114,12 @@ public class Measure { this.ruleName = ruleName; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public String getRuleCategory() { - return ruleCategory; - } - - public void setRuleCategory(String s) { - this.ruleCategory = s; + return null; } public String getRulePriority() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java index fe6125e486a..c2cc2052ec4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java @@ -39,7 +39,6 @@ public final class ResourcesQuery extends AbstractResourceQuery { private String qualifiers; private String metrics; private String rules; - private String ruleCategories; private String rulePriorities; private boolean verbose = false; @@ -80,8 +79,12 @@ public final class ResourcesQuery extends AbstractResourceQuery { return setRulePriorities(b ? "true" : "false"); } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public ResourcesQuery filterOnRuleCategories(boolean b) { - return setRuleCategories(b ? "true" : "false"); + return this; } public ResourcesQuery setRulePriorities(String s) { @@ -89,8 +92,11 @@ public final class ResourcesQuery extends AbstractResourceQuery { return this; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public ResourcesQuery setRuleCategories(String s) { - this.ruleCategories = s; return this; } @@ -161,9 +167,6 @@ public final class ResourcesQuery extends AbstractResourceQuery { if (rules != null) { url += "rules=" + rules + "&"; } - if (ruleCategories != null) { - url += "rule_categories=" + ruleCategories + "&"; - } if (rulePriorities != null) { url += "rule_priorities=" + rulePriorities + "&"; } @@ -247,7 +250,6 @@ public final class ResourcesQuery extends AbstractResourceQuery { m.setRuleKey(JsonUtils.getString(measure, "rule_key")); m.setRuleName(JsonUtils.getString(measure, "rule_name")); - m.setRuleCategory(JsonUtils.getString(measure, "rule_category")); m.setRulePriority(JsonUtils.getString(measure, "rule_priority")); m.setDate(date); return m; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java index c150e48c63b..4838c5ee67d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java @@ -22,12 +22,10 @@ package org.sonar.api.web.gwt.client.webservices; public class Rule extends ResponsePOJO { private String key; private String name; - private String category; - public Rule(String key, String name, String category) { + public Rule(String key, String name) { this.key = key; this.name = name; - this.category = category; } @@ -47,11 +45,11 @@ public class Rule extends ResponsePOJO { this.name = name; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; + return null; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java index 46442b6c995..2faac389e0f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java @@ -31,7 +31,6 @@ public final class ViolationsQuery extends AbstractResourceQuery { private String scopes; private String qualifiers; private String rules; - private String categories; private String priorities; private Integer depth; @@ -70,12 +69,19 @@ public final class ViolationsQuery extends AbstractResourceQuery { return this; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public String getCategories() { - return categories; + return null; } + /** + * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 + */ + @Deprecated public ViolationsQuery setCategories(String s) { - this.categories = s; return this; } @@ -112,9 +118,6 @@ public final class ViolationsQuery extends AbstractResourceQuery { if (rules != null) { url += "rules=" + rules + "&"; } - if (categories != null) { - url += "categories=" + categories + "&"; - } if (priorities != null) { url += "priorities=" + priorities + "&"; } @@ -150,9 +153,7 @@ public final class ViolationsQuery extends AbstractResourceQuery { JSONObject ruleObj = jsViolation.get("rule").isObject(); Rule rule = new Rule( JsonUtils.getString(ruleObj, "key"), - JsonUtils.getString(ruleObj, "name"), - JsonUtils.getString(ruleObj, "category") - ); + JsonUtils.getString(ruleObj, "name")); result.add(new Violation(message.stringValue(), priority.stringValue(), lineIndex, rule, null)); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java index 3232abdf7b3..3df303974ec 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java @@ -21,7 +21,7 @@ package org.sonar.api.checks; import org.sonar.check.*; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithIntegerProperty { @RuleProperty diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java index 9cd020d1404..d06e9b253a1 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java @@ -1,10 +1,9 @@ package org.sonar.api.checks; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; -@Rule(key = "CheckWithKey", isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(key = "CheckWithKey", priority = Priority.CRITICAL) public class CheckWithKey { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java index 4361a069a85..f1ecc47e0d3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java @@ -19,12 +19,11 @@ */ package org.sonar.api.checks; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithOverriddenPropertyKey{ @RuleProperty(key = "maximum") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java index 77772819be0..35f3c7702ea 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java @@ -19,9 +19,11 @@ */ package org.sonar.api.checks; -import org.sonar.check.*; +import org.sonar.check.Priority; +import org.sonar.check.Rule; +import org.sonar.check.RuleProperty; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithPrimitiveProperties { @RuleProperty(description = "Maximum threshold") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java index a0ecb648003..0167652ca10 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java @@ -19,9 +19,11 @@ */ package org.sonar.api.checks; -import org.sonar.check.*; +import org.sonar.check.Priority; +import org.sonar.check.Rule; +import org.sonar.check.RuleProperty; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithStringProperty { @RuleProperty diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java index 9e55a1733ff..16f7fd36083 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java @@ -19,9 +19,11 @@ */ package org.sonar.api.checks; -import org.sonar.check.*; +import org.sonar.check.Priority; +import org.sonar.check.Rule; +import org.sonar.check.RuleProperty; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithUnsupportedPropertyType { @RuleProperty diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java index ad83842a1b2..67878499567 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java @@ -19,11 +19,10 @@ */ package org.sonar.api.checks; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; -@Rule(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@Rule(priority = Priority.CRITICAL) class CheckWithoutProperties { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java index a522152ead4..4fe07d41236 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java @@ -20,16 +20,14 @@ package org.sonar.api.measures; import org.apache.commons.lang.StringUtils; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import org.junit.Test; -import org.sonar.api.rules.Iso9126RulesCategories; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.*; + public class MeasureTest { @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java index 14d659d4130..7d0e417f734 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java @@ -19,8 +19,6 @@ */ package org.sonar.api.measures; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; import org.junit.Test; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; @@ -29,6 +27,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + public class MeasuresFiltersTest { @Test @@ -97,18 +98,6 @@ public class MeasuresFiltersTest { assertThat(filter.filter(measures).size(), is(2)); } - @Test - public void ruleCategory() { - MeasuresFilter filter = MeasuresFilters.ruleCategory(CoreMetrics.VIOLATIONS, 2); - List measures = Arrays.asList( - RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 50.0), - RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, 2, 10.0), - RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, 3, 15.0), - new Measure(CoreMetrics.VIOLATIONS, 500.0)); - - assertThat(filter.filter(measures).getValue(), is(10.0)); - } - @Test public void measure() { MeasuresFilter filter = MeasuresFilters.measure(new Measure(CoreMetrics.VIOLATIONS)); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/RuleMeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/RuleMeasureTest.java index a65223d74d4..92c601e1d7f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/RuleMeasureTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/RuleMeasureTest.java @@ -19,12 +19,13 @@ */ package org.sonar.api.measures; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import org.junit.Test; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + public class RuleMeasureTest { @Test @@ -33,10 +34,6 @@ public class RuleMeasureTest { RuleMeasure.createForPriority(CoreMetrics.CLASSES, RulePriority.CRITICAL, 4.5), RuleMeasure.createForPriority(CoreMetrics.CLASSES, RulePriority.CRITICAL, 3.4)); - assertEquals( - RuleMeasure.createForCategory(CoreMetrics.CLASSES, 3, 4.5), - RuleMeasure.createForCategory(CoreMetrics.CLASSES, 3, 3.4)); - assertEquals( RuleMeasure.createForRule(CoreMetrics.CLASSES, new Rule("pmd", "abc1"), 4.5), RuleMeasure.createForRule(CoreMetrics.CLASSES, new Rule("pmd", "abc1"), 3.4)); @@ -49,10 +46,6 @@ public class RuleMeasureTest { RuleMeasure.createForPriority(CoreMetrics.CLASSES, RulePriority.CRITICAL, 4.5), RuleMeasure.createForPriority(CoreMetrics.CLASSES, RulePriority.BLOCKER, 3.4)); - assertNotEquals( - RuleMeasure.createForCategory(CoreMetrics.CLASSES, 3, 4.5), - RuleMeasure.createForCategory(CoreMetrics.CLASSES, 331, 3.4)); - assertNotEquals( RuleMeasure.createForRule(CoreMetrics.CLASSES, new Rule("pmd", "abc1"), 4.5), RuleMeasure.createForRule(CoreMetrics.CLASSES, new Rule("pmd", "def2"), 3.4)); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java index a6d0c6a0a90..c30131645f2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/AnnotationProfileParserTest.java @@ -28,7 +28,6 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RulePriority; import org.sonar.api.utils.ValidationMessages; import org.sonar.check.BelongsToProfile; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import static org.hamcrest.Matchers.is; @@ -75,11 +74,11 @@ public class AnnotationProfileParserTest { } @BelongsToProfile(title = "Other profile", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "other", isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@org.sonar.check.Rule(key = "other", priority = Priority.CRITICAL) class RuleOnOtherProfile { } @BelongsToProfile(title = "Foo way", priority = Priority.BLOCKER) -@org.sonar.check.Rule(key = "fake", isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) +@org.sonar.check.Rule(key = "fake", priority = Priority.CRITICAL) class FakeRule { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java index 408b428e5be..7861c2cd2c5 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java @@ -25,6 +25,7 @@ import org.sonar.api.measures.Metric; import java.util.List; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class CoreMetricsTest { @@ -35,4 +36,14 @@ public class CoreMetricsTest { assertTrue(metrics.contains(CoreMetrics.NCLOC)); assertTrue(metrics.contains(CoreMetrics.DIRECTORIES)); } + + @Test + public void shouldExcludeDeprecatedIsoMetrics() { + List metrics = CoreMetrics.getMetrics(); + assertFalse(metrics.contains(CoreMetrics.USABILITY)); + assertFalse(metrics.contains(CoreMetrics.EFFICIENCY)); + assertFalse(metrics.contains(CoreMetrics.RELIABILITY)); + assertFalse(metrics.contains(CoreMetrics.PORTABILITY)); + assertFalse(metrics.contains(CoreMetrics.MAINTAINABILITY)); + } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheck.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheck.java index 24e77b484e5..38bd46e2149 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheck.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheck.java @@ -19,8 +19,6 @@ */ package org.sonar.api.rules; -import org.sonar.check.IsoCategory; - -@org.sonar.check.Rule(name ="Annotated Check", description = "Description", isoCategory = IsoCategory.Reliability) +@org.sonar.check.Rule(name ="Annotated Check", description = "Description") public class AnnotatedCheck { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java index 97e16c4de71..9780f4b18a1 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java @@ -19,10 +19,9 @@ */ package org.sonar.api.rules; -import org.sonar.check.IsoCategory; import org.sonar.check.RuleProperty; -@org.sonar.check.Rule(key = "overridden_key", name = "Check with parameters", description = "Has parameters", isoCategory = IsoCategory.Efficiency) +@org.sonar.check.Rule(key = "overridden_key", name = "Check with parameters", description = "Has parameters") public class AnnotatedCheckWithParameters { @RuleProperty(description = "Maximum value") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java index da3ca48d4c1..6493581677b 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java @@ -1,14 +1,14 @@ package org.sonar.api.rules; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import org.junit.Test; +import org.sonar.check.IsoCategory; +import org.sonar.check.Priority; import java.util.Collections; import java.util.List; -import org.junit.Test; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; public class AnnotationRuleParserTest { @@ -20,7 +20,6 @@ public class AnnotationRuleParserTest { assertThat(rule.getKey(), is("foo")); assertThat(rule.getName(), is("bar")); assertThat(rule.getPriority(), is(RulePriority.BLOCKER)); - assertThat(rule.getRulesCategory(), is(Iso9126RulesCategories.MAINTAINABILITY)); assertThat(rule.getParams().size(), is(1)); RuleParam prop = rule.getParam("property"); assertThat(prop.getKey(), is("property")); @@ -36,7 +35,6 @@ public class AnnotationRuleParserTest { assertThat(rule.getKey(), is("foo")); assertThat(rule.getName(), is("foo")); assertThat(rule.getPriority(), is(RulePriority.MAJOR)); - assertThat(rule.getRulesCategory(), is(Iso9126RulesCategories.MAINTAINABILITY)); } @Test @@ -47,7 +45,6 @@ public class AnnotationRuleParserTest { assertThat(rule.getKey(), is(RuleWithoutKey.class.getCanonicalName())); assertThat(rule.getName(), is("foo")); assertThat(rule.getPriority(), is(RulePriority.MAJOR)); - assertThat(rule.getRulesCategory(), is(Iso9126RulesCategories.MAINTAINABILITY)); } @Test @@ -59,28 +56,27 @@ public class AnnotationRuleParserTest { assertThat(rule.getName(), is(Check.class.getCanonicalName())); assertThat(rule.getDescription(), is("Deprecated check")); assertThat(rule.getPriority(), is(RulePriority.BLOCKER)); - assertThat(rule.getRulesCategory(), is(Iso9126RulesCategories.MAINTAINABILITY)); } private List parseAnnotatedClass(Class annotatedClass) { return new AnnotationRuleParser().parse("repo", Collections.singleton(annotatedClass)); } - @org.sonar.check.Rule(name = "foo", isoCategory = IsoCategory.Maintainability) + @org.sonar.check.Rule(name = "foo") private class RuleWithoutKey { } - @org.sonar.check.Rule(key = "foo", isoCategory = IsoCategory.Maintainability) + @org.sonar.check.Rule(key = "foo") private class RuleWithoutName { } - @org.sonar.check.Rule(key = "foo", name = "bar", isoCategory = IsoCategory.Maintainability, priority = Priority.BLOCKER) + @org.sonar.check.Rule(key = "foo", name = "bar", priority = Priority.BLOCKER) private class RuleWithProperty { @org.sonar.check.RuleProperty(description = "Ignore ?", defaultValue = "false") String property; } - @org.sonar.check.Check(description = "Deprecated check", isoCategory = IsoCategory.Maintainability, priority = Priority.BLOCKER) + @org.sonar.check.Check(description = "Deprecated check", priority = Priority.BLOCKER, isoCategory = IsoCategory.Maintainability) private class Check { } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java index 05bedea0dcf..14dadb15f87 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java @@ -33,14 +33,12 @@ public class IsRuleMeasure extends BaseMatcher { private Metric metric = null; private Rule rule = null; - private Integer category = null; private RulePriority priority = null; private Double value = null; public IsRuleMeasure(Metric metric, Rule rule, Integer category, RulePriority priority, Double value) { this.metric = metric; this.rule = rule; - this.category = category; this.priority = priority; this.value = value; } @@ -52,7 +50,6 @@ public class IsRuleMeasure extends BaseMatcher { RuleMeasure m = (RuleMeasure) o; return ObjectUtils.equals(metric, m.getMetric()) && ObjectUtils.equals(rule, m.getRule()) && - ObjectUtils.equals(category, m.getRuleCategory()) && ObjectUtils.equals(priority, m.getRulePriority()) && NumberUtils.compare(value, m.getValue()) == 0; } diff --git a/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java b/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java index 02fbcc98fcf..dd6b88e1e24 100644 --- a/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java +++ b/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java @@ -137,7 +137,7 @@ public class FilterExecutor implements ServerComponent { sql.append(" ) AND "); } - sql.append(" pm.rule_id is null AND pm.rules_category_id is null AND pm.rule_priority is null AND pm.characteristic_id IS NULL AND "); + sql.append(" pm.rule_id is null AND pm.rule_priority is null AND pm.characteristic_id IS NULL AND "); } sql.append(" s.status=:status AND s.islast=:islast "); if (filter.getScopes() != null) { diff --git a/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedRuleRepositories.java b/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedRuleRepositories.java index 1794d2dfd27..b3bc7f1a9c7 100644 --- a/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedRuleRepositories.java +++ b/sonar-server/src/main/java/org/sonar/server/rules/DeprecatedRuleRepositories.java @@ -115,7 +115,6 @@ class DeprecatedRuleRepository extends RuleRepository { private Rule cloneRule(Rule deprecatedRule) { Rule rule = Rule.create(getKey(), deprecatedRule.getKey(), deprecatedRule.getName()); - rule.setRulesCategory(deprecatedRule.getRulesCategory()); rule.setConfigKey(deprecatedRule.getConfigKey()); rule.setPriority(deprecatedRule.getPriority()); rule.setDescription(deprecatedRule.getDescription()); 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 ae9fbd01aca..6526d1d04fd 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 @@ -127,7 +127,6 @@ public final class RegisterRules { persistedRule.setName(rule.getName()); persistedRule.setConfigKey(rule.getConfigKey()); persistedRule.setDescription(rule.getDescription()); - persistedRule.setRulesCategory(reattachCategory(rule.getRulesCategory(), session)); persistedRule.setPriority(rule.getPriority()); persistedRule.setEnabled(true); persistedRule.setCardinality(rule.getCardinality()); @@ -169,19 +168,9 @@ public final class RegisterRules { } } - private RulesCategory reattachCategory(RulesCategory category, DatabaseSession session) { - if (category != null) { - return session.getSingleResult(RulesCategory.class, "name", category.getName()); - } - return null; - } - private void saveNewRules(Collection rules, DatabaseSession session) { for (Rule rule : rules) { rule.setEnabled(true); - if (rule.getRulesCategory() != null) { - rule.setRulesCategory(reattachCategory(rule.getRulesCategory(), session)); - } session.saveWithoutFlush(rule); } session.commit(); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index a8f01446763..80da25d2f0c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -187,10 +187,6 @@ class Api::ResourcesController < Api::ApiController (params['filter_rules']=='true') ? params['rules']='false' : params['rules']='true' end - if params['filter_rules_cats'] - (params['filter_rules_cats']=='true') ? params['rule_categories']='false' : params['rule_categories']='true' - end - if params['metrics'] if params['metrics'].include? 'mandatory_violations' params['metrics']=params['metrics'].gsub(/mandatory_violations/, 'violations') @@ -203,7 +199,7 @@ class Api::ResourcesController < Api::ApiController end def select_columns_for_measures - select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.rules_category_id,project_measures.rule_priority,project_measures.text_value,project_measures.characteristic_id' + select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.rule_priority,project_measures.text_value,project_measures.characteristic_id' if params[:includetrends]=='true' select_columns+=',project_measures.tendency,project_measures.diff_value_1,project_measures.diff_value_2,project_measures.diff_value_3' end @@ -231,20 +227,6 @@ class Api::ResourcesController < Api::ApiController measures_values[:rule_ids]=rule_ids.compact end - param_categs=params['rule_categories'] || 'false' - if param_categs=='true' - measures_conditions << "project_measures.rules_category_id IS NOT NULL" - - elsif param_categs=='false' - measures_conditions << "project_measures.rules_category_id IS NULL" if param_rules=='false' - else - measures_conditions << "project_measures.rules_category_id IN (:categ_ids)" - measures_values[:categ_ids]=param_categs.split(',').map do |c| - categ=RulesCategory.by_key(c) - categ ? categ.id : -1 - end.compact - end - param_priorities = params['rule_priorities'] || 'false' if param_priorities=='true' measures_conditions << "project_measures.rule_priority IS NOT NULL" @@ -356,9 +338,6 @@ class Api::ResourcesController < Api::ApiController json_measure[:rule_key] = rule.key if rule json_measure[:rule_name] = rule.name if rule end - if measure.rules_category_id - json_measure[:rule_category] = measure.category.name - end if measure.rule_priority json_measure[:rule_priority] = Sonar::RulePriority.to_s(measure.rule_priority) end @@ -414,9 +393,6 @@ class Api::ResourcesController < Api::ApiController xml.rule_key(rule.key) if rule xml.rule_name(rule.name) if rule end - if measure.rules_category_id - xml.rule_category(measure.category.name) - end if measure.rule_priority xml.rule_priority(Sonar::RulePriority.to_s(measure.rule_priority)) end 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 e17fd55fb73..1fc65c297a5 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 @@ -29,7 +29,6 @@ class Api::RulesController < Api::RestController options[:plugins]=params[:plugins].split(',') if params[:plugins] options[:language]=language - options[:categories]=params[:categories].split(',') if params[:categories] options[:priorities]=params[:priorities].split(',') if params[:priorities] options[:status]=params[:status] options[:searchtext]=params[:searchtext] @@ -52,7 +51,6 @@ class Api::RulesController < Api::RestController end def set_backward_compatibility_params - params[:categories]=params[:category] if params[:category] params[:plugins]=params[:plugin] if params[:plugin] params[:priorities]=params[:levels] if params[:levels] end @@ -88,7 +86,7 @@ class Api::RulesController < Api::RestController def rest_to_csv(rules, profile) FasterCSV.generate do |csv| - header = ["title", "key", "category", "plugin"] + header = ["title", "key", "plugin"] header.concat(["priority","status"]) if profile csv << header rules.each do |rule| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb index efddf6f07bf..e8b62eafa90 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb @@ -67,14 +67,6 @@ class Api::ViolationsController < Api::ResourceRestController conditions << 'rule_id IN (:rule_ids)' values[:rule_ids] = rule_ids end - param_categories=params[:categories] || params[:category] - if param_categories - conditions << 'rules.rules_category_id IN (:category_ids)' - values[:category_ids]=param_categories.split(',').map do |c| - categ=RulesCategory.by_key(c) - categ ? categ.id : -1 - end.compact - end if params[:priorities] conditions << 'rule_failures.failure_level IN (:priorities)' values[:priorities]=params[:priorities].split(',').map do |p| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb index a574008d741..96849e2bf03 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb @@ -23,39 +23,39 @@ class ColumnsController < ApplicationController before_filter :init def add - column = @dashboard_configuration.find_available_column(@column_id) - @dashboard_configuration.add_column(column) + column = @components_configuration.find_available_column(@column_id) + @components_configuration.add_column(column) redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end def delete - column = @dashboard_configuration.find_selected_column(@column_id) - @dashboard_configuration.remove_column(column) + column = @components_configuration.find_selected_column(@column_id) + @components_configuration.remove_column(column) if column.sort_default? - @dashboard_configuration.set_column_sort_default(Sonar::ColumnsView::TYPE_PROJECT) + @components_configuration.set_column_sort_default(Sonar::ColumnsView::TYPE_PROJECT) end redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end def toggle_treemap - @dashboard_configuration.toggle_treemap_enabled + @components_configuration.toggle_treemap_enabled redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end def left - column = @dashboard_configuration.find_selected_column(@column_id) - @dashboard_configuration.move_column(column, "left") + column = @components_configuration.find_selected_column(@column_id) + @components_configuration.move_column(column, "left") redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end def right - column = @dashboard_configuration.find_selected_column(@column_id) - @dashboard_configuration.move_column(column, "right") + column = @components_configuration.find_selected_column(@column_id) + @components_configuration.move_column(column, "right") redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end def default_sorting - @dashboard_configuration.set_column_sort_default(@column_id) + @components_configuration.set_column_sort_default(@column_id) redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] end @@ -63,7 +63,7 @@ class ColumnsController < ApplicationController private def init - @dashboard_configuration = Sonar::ComponentsConfiguration.new + @components_configuration = Sonar::ComponentsConfiguration.new @column_id = params[:id] end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb index 55be91961e2..737936ab11c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb @@ -29,19 +29,19 @@ class ComponentsController < ApplicationController SECTION = Navigation::SECTION_RESOURCE def index - @dashboard_configuration = Sonar::ComponentsConfiguration.new + @components_configuration = Sonar::ComponentsConfiguration.new @project = Project.by_key(params[:id]) return access_denied unless has_role?(:user, @project) @snapshot = @project.last_snapshot @snapshots = Snapshot.find(:all, :include => 'project', :conditions => ['snapshots.parent_snapshot_id=? and snapshots.qualifier<>? and projects.qualifier<>?', @snapshot.id, Snapshot::QUALIFIER_UNIT_TEST_CLASS, Snapshot::QUALIFIER_UNIT_TEST_CLASS]) - @columns = @dashboard_configuration.selected_columns - metrics = @dashboard_configuration.homepage_metrics + @columns = @components_configuration.selected_columns + metrics = @components_configuration.homepage_metrics measures = component_measures(@snapshots, metrics) @measures_by_snapshot = measures_by_snapshot(@snapshots, measures) - if @dashboard_configuration.treemap_enabled? && @snapshots.size>1 + if @components_configuration.treemap_enabled? && @snapshots.size>1 @treemap = Sonar::TreemapBuilder.build(@snapshots, TREEMAP_SIZE, TREEMAP_SIZE) end end @@ -103,7 +103,6 @@ class ComponentsController < ApplicationController 'snapshot_id' => page_sids, 'metric_id' => mids, 'rule_id' => nil, - 'rules_category_id' => nil, 'rule_priority' => nil, 'characteristic_id' => nil})) measures.concat(AsyncMeasureSnapshot.search(page_sids, mids)) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index e838034a1bc..22666455121 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -62,7 +62,6 @@ class DrilldownController < ApplicationController end def violations - @filter = params[:filter] || 'priority' @metric = select_metric(params[:metric], 'violations') # selected resources @@ -80,10 +79,8 @@ class DrilldownController < ApplicationController # options @rule=Rule.by_key_or_id(params[:rule]) @priority_id = (params[:priority] ? Sonar::RulePriority.id(params[:priority]) : nil) - @categ_id = (params[:categ_id] ? params[:categ_id].to_i : nil) options={} - options[:rule_category_id]=@categ_id options[:rule_priority_id]=@priority_id if @rule params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id 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 36fedc05dd6..ba6043e411a 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 @@ -52,23 +52,22 @@ class RulesConfigurationController < ApplicationController init_params() @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort - @select_categories = ANY_SELECTION + RulesCategory.all.collect {|rc| [ rc.name, rc.name ] }.sort @select_priority = ANY_SELECTION + RULE_PRIORITIES @select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]] @rules = Rule.search(java_facade, { - :profile => @profile, :categories => @categories, :status => @status, :priorities => @priorities, + :profile => @profile, :status => @status, :priorities => @priorities, :plugins => @plugins, :searchtext => @searchtext, :include_parameters => true, :language => @profile.language}) unless @searchtext.blank? if @status==STATUS_ACTIVE @hidden_inactives=Rule.search(java_facade, { - :profile => @profile, :categories => @categories, :status => STATUS_INACTIVE, :priorities => @priorities, + :profile => @profile, :status => STATUS_INACTIVE, :priorities => @priorities, :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size elsif @status==STATUS_INACTIVE @hidden_actives=Rule.search(java_facade, { - :profile => @profile, :categories => @categories, :status => STATUS_ACTIVE, :priorities => @priorities, + :profile => @profile, :status => STATUS_ACTIVE, :priorities => @priorities, :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size end end @@ -137,7 +136,6 @@ class RulesConfigurationController < ApplicationController { :priority => Sonar::RulePriority.id(params[:rule][:priority]), :parent_id => template.id, - :rules_category_id => template.rules_category_id, :plugin_name => template.plugin_name, :cardinality => 'SINGLE', :plugin_rule_key => "#{template.plugin_rule_key}_#{Time.now.to_i}", @@ -309,21 +307,10 @@ class RulesConfigurationController < ApplicationController count end - def select_category(categories, categ_id_string) - return categories.first if categ_id_string.nil? or categ_id_string.blank? - categories.each do |categ| - if categ_id_string==categ.id.to_s - return categ - end - end - nil - end - def init_params @id = params[:id] @priorities = filter_any(params[:priorities]) || [''] @plugins=filter_any(params[:plugins]) || [''] - @categories=filter_any(params[:categories]) || [''] @status=params[:rule_status] || STATUS_ACTIVE @searchtext=params[:searchtext] end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb index 032e19f4464..627fc5a88df 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb @@ -52,7 +52,7 @@ class TimemachineController < ApplicationController snapshot_by_id[s.id]=s end - measures=ProjectMeasure.find(:all, :conditions => {:rule_id => nil, :rules_category_id => nil, :rule_priority => nil, :snapshot_id => @sids}) + measures=ProjectMeasure.find(:all, :conditions => {:rule_id => nil, :rule_priority => nil, :snapshot_id => @sids, :characteristic_id => nil}) measures.concat(AsyncMeasureSnapshot.search(@sids)) rows_by_metric_id={} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 6aebf2254f3..12ae02f6c87 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -408,7 +408,7 @@ module ApplicationHelper m = @snapshot.measure(metric_or_measure) end - if @dashboard_configuration && @dashboard_configuration.variation? + if defined?(@dashboard_configuration) && @dashboard_configuration.variation? return nil unless options[:force] end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/components_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/components_helper.rb index eb6bff07492..5c8aca6f1ba 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/components_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/components_helper.rb @@ -67,16 +67,7 @@ module ComponentsHelper return nil if items.nil? items.each do |item| metric = Metric.by_name(metric_name) - return item if (item && metric && item.metric_id==metric.id && item.rules_category_id.nil? && item.rule_priority.nil?) - end - nil - end - - def item_by_metric_name_and_categ_id(items, metric_name, rules_category_name) - return nil if items.nil? - items.each do |item| - rules_category = RulesCategory.by_name(rules_category_name) - return item if (item.metric.name==metric_name && item.rules_category_id==rules_category.id && item.rule_id.nil? && item.rule_priority.nil?) + return item if (item && metric && item.metric_id==metric.id && item.rule_priority.nil? && item.characteristic_id.nil?) end nil end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index be8ccad5ad4..6cd75f7d723 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -20,14 +20,6 @@ module DashboardHelper include WidgetPropertiesHelper - def item_by_metric_id(items, metric_id) - return nil if items.nil? - items.each do |item| - return item if (item.metric.id==metric_id and item.rules_category_id.nil?) - end - nil - end - def active_widgets_ids_formatted(column) active_widget_ids=[] @dashboard.widgets.find(:all, :conditions => {:column_index => column}, :order => 'row_index ASC').each do |widget| @@ -45,16 +37,6 @@ module DashboardHelper return "\'"+active_widget_ids.join("\',\'")+"\'" end - def item_by_metric_name_and_categ_id(items, metric_name, rules_category_id) - return nil if items.nil? - items.each do |item| - return item if (item.metric.name==metric_name and - item.rules_category_id == rules_category_id and - item.rule_id.nil?) - end - nil - end - def formatted_value(measure, default='') measure ? measure.formatted_value : default end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/project_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/project_helper.rb index 8a186da8b5c..3cce0220a0b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/project_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/project_helper.rb @@ -20,24 +20,6 @@ module ProjectHelper include ActionView::Helpers::UrlHelper - def item_by_metric_id(items, metric_id) - return nil if items.nil? - items.each do |item| - return item if(item.metric.id==metric_id and item.rules_category_id.nil?) - end - nil - end - - def item_by_metric_name_and_categ_id(items, metric_name, rules_category_id) - return nil if items.nil? - items.each do |item| - return item if (item.metric.name==metric_name and - item.rules_category_id == rules_category_id and - item.rule_id.nil?) - end - nil - end - def formatted_value(measure, default='') measure ? measure.formatted_value : default end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb index 2f9eb94d88d..3fd9db9b5c0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb @@ -69,13 +69,6 @@ class DrilldownColumn conditions += ' AND project_measures.rule_id IS NULL' end - if options[:rule_category_id] - conditions += ' AND project_measures.rules_category_id=:categ' - values[:categ]=options[:rule_category_id] - elsif options[:rule_id].nil? - conditions += ' AND project_measures.rules_category_id IS NULL' - end - if options[:rule_priority_id] conditions += ' AND project_measures.rule_priority=:priority' values[:priority]=options[:rule_priority_id] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_result.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_result.rb index 0f8f9be9787..c3332f4ba3b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_result.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_result.rb @@ -50,7 +50,7 @@ # load measures # if @metric_ids.size>0 - measures=ProjectMeasure.find(:all, :conditions => ['rule_priority is null and rules_category_id is null and rule_id is null and characteristic_id is null and snapshot_id in (?)', @page_sids]) + measures=ProjectMeasure.find(:all, :conditions => ['rule_priority is null and rule_id is null and characteristic_id is null and snapshot_id in (?)', @page_sids]) if filter.display_user_managed_metrics? measures.concat(AsyncMeasureSnapshot.search(@page_sids, @metric_ids)) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index caabed09f3a..de2a7aa9bec 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -81,7 +81,7 @@ class Project < ActiveRecord::Base ' where s.id=m.snapshot_id and ' + " s.status='%s' and " + ' s.project_id=%s and m.metric_id=%s ', Snapshot::STATUS_PROCESSED, self.id, metric_id] ) + - ' and m.rules_category_id IS NULL and m.rule_id IS NULL and m.rule_priority IS NULL' + + ' and m.rule_id IS NULL and m.rule_priority IS NULL' + ' order by s.created_at' create_chart_measures( Project.connection.select_all( sql ), 'created_at', 'value' ) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index 3cb777ef9ff..42f4cccc19f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -27,7 +27,6 @@ class ProjectMeasure < ActiveRecord::Base belongs_to :snapshot belongs_to :rule - belongs_to :rules_category belongs_to :project belongs_to :characteristic has_one :measure_data, :class_name => 'MeasureData', :foreign_key => 'measure_id' @@ -50,20 +49,8 @@ class ProjectMeasure < ActiveRecord::Base write_attribute(:metric_id, m.id) if m.id end - def category - @category ||= - begin - RulesCategory.by_id(rules_category_id) - end - end - - def category=(c) - @category = RulesCategory.by_name(c.name) - write_attribute(:rules_category_id, @category.id) if @category.id - end - def rule_measure? - rule_id || rules_category_id || rule_priority + rule_id || rule_priority end def data @@ -250,17 +237,6 @@ class ProjectMeasure < ActiveRecord::Base ProjectMeasure.find(:all, :conditions => {:snapshot_id => snapshot_ids, :metric_id => metric_ids}) end - def self.find_by_metric_and_snapshot_ids(metric, snapshot_ids, rules_category_id=nil, rule_id=nil) - parameters = {:snapshot_id => snapshot_ids, :metric_id => metric.id} - parameters[:rule_id] = rule_id - if (rule_id.nil?) - parameters[:rules_category_id] = rules_category_id - end - - (metric.direction<0) ? order_direction = 'desc' : order_direction = 'asc' - ProjectMeasure.find(:all, :conditions => parameters, :order => "value #{order_direction}") - end - def review? measure_date != nil end @@ -277,8 +253,8 @@ class ProjectMeasure < ActiveRecord::Base if rule_measure? if rule_id "#{metric_key}_rule_#{rule_id}" - elsif rules_category_id - "#{metric_key}_#{rules_category_id}" + elsif characteristic_id + "#{metric_key}_c_#{characteristic_id}" else "#{metric_key}_#{rule_priority_text}" end 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 b2013b6f28d..8dbd0c37af5 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 @@ -19,10 +19,9 @@ # class Rule < ActiveRecord::Base - validates_presence_of :name, :rules_category_id, :plugin_rule_key, :plugin_config_key, :plugin_name + validates_presence_of :name, :plugin_rule_key, :plugin_config_key, :plugin_name has_many :rules_parameters - belongs_to :rules_category has_many :rule_failures has_many :active_rules belongs_to :parent, :class_name => 'Rule', :foreign_key => 'parent_id' @@ -43,21 +42,6 @@ class Rule < ActiveRecord::Base Sonar::RulePriority.to_s(priority) end - def rules_category - category - end - - def category - @rules_category ||= - begin - RulesCategory.by_id(rules_category_id) - end - end - - def category=(c) - @rules_category = c - end - def key "#{plugin_name}:#{plugin_rule_key}" end @@ -103,7 +87,7 @@ class Rule < ActiveRecord::Base end def to_hash_json(profile) - json = {'title' => name, 'key' => key, 'category' => rules_category.name, 'plugin' => plugin_name} + json = {'title' => name, 'key' => key, 'plugin' => plugin_name} json['description'] = description active_rule = nil if profile @@ -127,7 +111,6 @@ class Rule < ActiveRecord::Base xml.rule do xml.title(name) xml.key(key) - xml.category(rules_category.name) xml.plugin(plugin_name) xml.description {xml.cdata!(description)} active_rule = nil @@ -150,7 +133,7 @@ class Rule < ActiveRecord::Base end def to_csv(profile) - csv = [name.strip, plugin_rule_key, rules_category.name, plugin_name] + csv = [name.strip, plugin_rule_key, plugin_name] if profile active_rule = profile.active_by_rule_id(id) if active_rule @@ -165,7 +148,7 @@ class Rule < ActiveRecord::Base end - # options :language => nil, :categories => [], :plugins => [], :searchtext => '', :profile => nil, :priorities => [], :status => + # options :language => nil, :plugins => [], :searchtext => '', :profile => nil, :priorities => [], :status => def self.search(java_facade, options={}) conditions = ['enabled=:enabled'] values = {:enabled => true} @@ -189,11 +172,6 @@ class Rule < ActiveRecord::Base end end - if remove_blank(options[:categories]) - conditions << "rules_category_id IN (:category_ids)" - values[:category_ids] = RulesCategory.find(:all, :select => 'id', :conditions => { :name => options[:categories] }).map(&:id) - end - unless options[:searchtext].blank? conditions << "(UPPER(rules.name) LIKE :searchtext OR plugin_rule_key = :key)" searchtext = options[:searchtext].to_s.strip diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index f2654f78a44..d5fec9ebf90 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -30,8 +30,7 @@ class RuleFailure < ActiveRecord::Base json['priority'] = Sonar::RulePriority.to_s(failure_level).upcase json['rule'] = { :key => rule.key, - :name => rule.name, - :category => rule.category.name} + :name => rule.name} json['resource'] = { :key => snapshot.project.key, :name => snapshot.project.name, @@ -49,7 +48,6 @@ class RuleFailure < ActiveRecord::Base xml.rule do xml.key(rule.key) xml.name(rule.name) - xml.category(rule.category.name) end xml.resource do xml.key(snapshot.project.key) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_category.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_category.rb deleted file mode 100644 index 021b91986ce..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_category.rb +++ /dev/null @@ -1,61 +0,0 @@ - # - # Sonar, entreprise quality control tool. - # Copyright (C) 2009 SonarSource SA - # 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 {library}; if not, write to the Free Software - # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - # -class RulesCategory < ActiveRecord::Base - has_many :rule, :order => 'name' - - @@categories = nil - def self.all - if @@categories.nil? - @@categories = find(:all, :order => 'name') - end - @@categories - end - - def self.by_id(key) - all.each do |categ| - return categ if categ.id==key - end - nil - end - - def self.by_name(name) - all.each do |categ| - return categ if categ.name==name - end - nil - end - - def self.by_key(key) - if key.to_i>0 - by_id(key.to_i) - else - by_name(key) - end - end - - def self.clear_cache - @@categories=nil - end - - def self.select_choices - all.collect {|rc| [ rc.name, rc.id ] }.sort - end - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index 657bc53b8b5..61beff4ccf2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -27,9 +27,9 @@ class Snapshot < ActiveRecord::Base belongs_to :root_snapshot, :class_name => 'Snapshot', :foreign_key => 'root_snapshot_id' belongs_to :characteristic - has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND rules_category_id IS NULL AND rule_priority IS NULL AND characteristic_id IS NULL' - has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => '(rule_id IS NOT NULL OR rules_category_id IS NOT NULL OR rule_priority IS NOT NULL) AND characteristic_id IS NULL' - has_many :characteristic_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND rules_category_id IS NULL AND rule_priority IS NULL AND characteristic_id IS NOT NULL' + has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND rule_priority IS NULL AND characteristic_id IS NULL' + has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => '(rule_id IS NOT NULL OR rule_priority IS NOT NULL) AND characteristic_id IS NULL' + has_many :characteristic_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND rule_priority IS NULL AND characteristic_id IS NOT NULL' has_many :events, :dependent => :destroy, :order => 'event_date DESC' has_one :source, :class_name => 'SnapshotSource', :dependent => :destroy @@ -149,21 +149,15 @@ class Snapshot < ActiveRecord::Base m ? m.formatted_value : nil end - def rule_measures(metric=nil, rule_categ_id=nil, rule_priority=nil) + def rule_measures(metric=nil, rule_priority=nil) rulemeasures.select do |m| - m.rule_id && (metric ? m.metric_id==metric.id : true) && (rule_priority ? m.rule_priority==rule_priority : true) && (rule_categ_id ? m.rules_category_id==rule_categ_id : true) - end - end - - def rule_category_measures(metric_key) - rulemeasures.select do |measure| - measure.rule_id.nil? && measure.rule_priority.nil? && measure.rules_category_id && measure.metric && measure.metric.key==metric_key + m.rule_id && (metric ? m.metric_id==metric.id : true) && (rule_priority ? m.rule_priority==rule_priority : true) end end def rule_priority_measures(metric_key) rulemeasures.select do |measure| - measure.rule_id.nil? && measure.rule_priority && measure.rules_category_id.nil? && measure.metric && measure.metric.key==metric_key + measure.rule_id.nil? && measure.rule_priority && measure.metric && measure.metric.key==metric_key end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb index 1c3aeacea6d..bbef4793cfb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb @@ -23,7 +23,6 @@ class Sonar::ColumnsView TYPE_BUILD_TIME = 'BUILD_TIME' TYPE_LINKS = 'LINKS' TYPE_METRIC = 'METRIC' - TYPE_RULES_CATEGORY = 'RULES_CATEG' TYPE_TREE_MAP = 'TREEMAP' TYPE_LANGUAGE = 'LANGUAGE' TYPE_VERSION = 'VERSION' @@ -44,7 +43,7 @@ class Sonar::ColumnsView end def metric_column? - @col_type == TYPE_METRIC || @col_type == TYPE_RULES_CATEGORY + @col_type == TYPE_METRIC end def language_column? diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb index d7d5adbe90d..7b80d4858c8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb @@ -47,7 +47,7 @@ class Sonar::TreemapBuilder # temporary fix for SONAR-1098 snapshots=snapshots[0...999] measures = ProjectMeasure.find(:all, - :conditions => ['rules_category_id IS NULL and rule_id IS NULL and rule_priority IS NULL and metric_id IN (?) and snapshot_id IN (?)', + :conditions => ['characteristic_id IS NULL and rule_id IS NULL and rule_priority IS NULL and metric_id IN (?) and snapshot_id IN (?)', [size_metric.id, color_metric.id], snapshots.map{|s| s.id}]) end Sonar::Treemap.new(measures_hash_by_snapshot(snapshots, measures), width, height, size_metric, color_metric) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb index dada10b3f34..10dee295e63 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb @@ -49,7 +49,7 @@ class TrendsChart " and s.status='%s' " + " and s.project_id=%s " + " and m.metric_id in (%s) " + - " and m.rules_category_id is null and m.rule_priority is null and m.characteristic_id is null", Snapshot::STATUS_PROCESSED, resource.id, metric_ids * ','] ) + " and m.rule_priority is null and m.characteristic_id is null", Snapshot::STATUS_PROCESSED, resource.id, metric_ids * ','] ) ProjectMeasure.connection.select_all( sql ) end end @@ -63,7 +63,7 @@ class TrendsChart "AND m.rule_id is null " + "AND m.project_id=%s " + "AND m.metric_id in (%s) " + - "AND m.rules_category_id is null and m.rule_priority is null and m.characteristic_id IS NULL", resource.id, metric_ids * ','] ) + "and m.rule_priority is null and m.characteristic_id IS NULL", resource.id, metric_ids * ','] ) ProjectMeasure.connection.select_all( sql ) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml index a6f5c5f6402..a87eec11769 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml @@ -1,7 +1,7 @@ <% if has_role?(:admin) && configuring? %>
- <% addeable_columns = dashboard_configuration.addeable_columns %> + <% addeable_columns = components_configuration.addeable_columns %> <% if addeable_columns.size > 0 %> @@ -32,7 +32,7 @@ "default_sorting" -%>"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml index 7873bcd3eba..7e1300fdd75 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml @@ -3,7 +3,7 @@ - + <% configured_columns.each do |column| %> <% end %> @@ -14,7 +14,7 @@ %> - @@ -27,7 +27,7 @@ - + <% configured_columns.each do |column| %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb index 2746695d881..b1483f04e00 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb @@ -15,7 +15,7 @@ <% end %> <% if has_role?(:admin) && configuring? %> - <%= render :partial => 'list_edit_mode_controls', :locals => {:configured_columns => @columns, :dashboard_configuration => @dashboard_configuration}%> + <%= render :partial => 'list_edit_mode_controls', :locals => {:configured_columns => @columns, :components_configuration => @components_configuration}%> <% end %> <% if @snapshots.empty? && @project.nil? %>

No projects have been analysed.

diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb index 00d42b6b2e8..3931990aa4a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb @@ -2,7 +2,7 @@
<%= image_tag 'warning.png' %> Note that these changes will impact all users and all projects.
<%= link_to( "Enable treemap", - {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if (!dashboard_configuration.treemap_enabled?) %> + {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if (!components_configuration.treemap_enabled?) %> <%= link_to( "Disable treemap", - {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if dashboard_configuration.treemap_enabled? %> + {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if components_configuration.treemap_enabled? %>   <%= image_tag("treemap_icon.png") %>
NameName<%= column.name %><%= html_measure(alert_status_measure, nil, true, nil, nil, nil) %> <% if logged_in? %><%= link_to_favourite(@snapshot.project) -%><% end %> + <%= qualifier_icon(@snapshot) -%> "><%= @snapshot.project.name -%>
NameName<%= column.name %><%= image_tag "priority/#{priority_id}.png" %> <%= link_to label, - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :categ_id => nil, :priority => Sonar::RulePriority.to_s(priority_id)} %> + {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id)} %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb index b7e501c889a..8779eaa2f71 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb @@ -5,42 +5,7 @@
- <% if @filter=='category' %> -
    -
  • - <%= link_to 'Priority', - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :filter => nil, :categ_id => nil, :priority => nil} %> -
  • -
  • - <%= link_to 'Category', - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :filter => - 'category', :categ_id => nil, :priority => nil}, :class => 'selected' %> -
  • -
- - <% - rule_category_measures = @snapshot.rule_category_measures(Metric::VIOLATIONS) - max = 0 - rule_category_measures.each do |m| - max = m.value if m.value and m.value>max - end - RulesCategory.all.each do |category| - - %> - - - - - - <% end %> -
<%= link_to h(category.name), - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :filter => 'category', :categ_id => category.id, :priority => nil} %> - <% measure = rule_category_measures.select{|m| m.rules_category_id==category.id}.first %> - <%= format_measure(measure) -%> - - <%= barchart(:width => 60, :percent => (measure ? (100 * measure.value / max).to_i : 0), :color => '#777') if max>0 %> -
- <% else %> + <% rule_priority_measures = @snapshot.rule_priority_measures(Metric::VIOLATIONS) max = 0 @@ -48,32 +13,21 @@ max = m.value if m.value and m.value>max end %> -
    -
  • - <%= link_to 'Priority', - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :filter => nil, :categ_id => nil, :priority => nil}, :class => 'selected' %> -
  • -
  • - <%= link_to 'Category', - {:controller => 'drilldown', :action => 'violations', :id => @project.id, :filter => - 'category', :categ_id => nil, :priority => nil} %> -
  • -
+

Priority

<%= render :partial => 'rule_priority', :locals => {:label => 'Blocker', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_BLOCKER, :max => max, :measures => rule_priority_measures }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Critical', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measures => rule_priority_measures }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Major', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measures => rule_priority_measures }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Minor', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measures => rule_priority_measures }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Info', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measures => rule_priority_measures }%> + <%= render :partial => 'rule_priority', :locals => {:label => 'Critical', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measures => rule_priority_measures }%> + <%= render :partial => 'rule_priority', :locals => {:label => 'Major', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measures => rule_priority_measures }%> + <%= render :partial => 'rule_priority', :locals => {:label => 'Minor', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measures => rule_priority_measures }%> + <%= render :partial => 'rule_priority', :locals => {:label => 'Info', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measures => rule_priority_measures }%>
- <% end %>

Rule

<% - rule_measures=@snapshot.rule_measures(Metric.by_key(Metric::VIOLATIONS), @categ_id, @priority_id) + rule_measures=@snapshot.rule_measures(Metric.by_key(Metric::VIOLATIONS), @priority_id) max=0 rule_index=0 rule_measures.each { |m| max=m.value if m.value>max } @@ -96,7 +50,7 @@ " title="Click for more on <%= rule.plugin_name -%>: <%= rule.plugin_rule_key -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"> - 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 64534a0049c..0cc3d938051 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 @@ -51,10 +51,6 @@ Plugin
<%= select_tag "plugins", options_for_select(@select_plugins, @plugins), :id => 'search_plugin', :multiple => true, :size => 6 %> - - <% if @rules.empty? %> - + <% end %> <% # avoid executing several times the method is_admin?() diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/003_populate_database.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/003_populate_database.rb deleted file mode 100644 index eb8c30b49a7..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/003_populate_database.rb +++ /dev/null @@ -1,40 +0,0 @@ - # - # Sonar, entreprise quality control tool. - # Copyright (C) 2009 SonarSource SA - # 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 - # -class PopulateDatabase < ActiveRecord::Migration - def self.up - insert_rule_categories - end - - protected - - def self.insert_rule_categories - RulesCategory.create(:name => 'Code Convention', :description => 'These rules do not suppose Quality of the development but make it possible to define a standard within the companies.') - RulesCategory.create(:name => 'Naming Convention', :description => 'These rules do not suppose Quality of the development but make it possible to define a common language.') - RulesCategory.create(:name => 'Documentation', :description => 'Documentation level.') - RulesCategory.create(:name => 'Completeness', :description => 'These rules make it possible to measure the completness of the source code.') - RulesCategory.create(:name => 'Conciseness', :description => 'These rules make it possible to measure the level of concision of the code and the Quality of object-oriented design.') - RulesCategory.create(:name => 'Understandability', :description => 'These rules make it possible to measure the understanbility of the code.') - RulesCategory.create(:name => 'Reliability', :description => 'These rules make it possible to measure the reliability of the code.') - RulesCategory.create(:name => 'Efficiency', :description => 'These rules make it possible to measure the level of efficiency, with the direction performance of the developed code.') - RulesCategory.create(:name => 'Portability', :description => 'Portability of the code.') - end - - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/006_use_iso_rule_categories.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/006_use_iso_rule_categories.rb deleted file mode 100644 index 3a05c5874b7..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/006_use_iso_rule_categories.rb +++ /dev/null @@ -1,49 +0,0 @@ - # - # Sonar, entreprise quality control tool. - # Copyright (C) 2009 SonarSource SA - # 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 - # -class UseIsoRuleCategories < ActiveRecord::Migration - def self.up - usability = RulesCategory.create(:name => 'Usability', :description => 'The extent to which the project can be understood, learned, operated, attractive and compliant with usability regulations and guidelines. It commonly relies on naming conventions and formatting rules.') - understandability = RulesCategory.find_by_name 'Understandability' - code_convention = RulesCategory.find_by_name 'Code Convention' - documentation = RulesCategory.find_by_name 'Documentation' - naming_convention = RulesCategory.find_by_name 'Naming Convention' - RulesCategory.delete_all "id in (#{understandability.id},#{code_convention.id},#{documentation.id},#{naming_convention.id})" - - maintainability = RulesCategory.create(:name => 'Maintainability', :description => 'The extent to which the project facilitates updating to satisfy new requirements. Thus the the project which is maintainable should be not complex.') - completeness = RulesCategory.find_by_name 'Completeness' - conciseness = RulesCategory.find_by_name 'Conciseness' - RulesCategory.delete_all "id in (#{completeness.id},#{conciseness.id})" - - update_description('Efficiency', 'The extent to which the project fulfills its purpose without waste of resources. This means resources in the sense of memory utilisation and processor speed.') - update_description('Portability', 'The extent to which the project can be operated easily and well on multiple computer configurations. Portability can mean both between different hardware setups and between different operating systems -- such as running on both Mac OS X and GNU/Linux.') - update_description('Reliability', 'The extent to which the project can be expected to perform its intended function with rescission. Some examples : are loop indexes range tested? Is input data checked for range errors ? Is divide-by-zero avoided ? Is exception handling provided ?') - - RulesCategory.clear_cache - end - - protected - def self.update_description(categ_name, desc) - rule = RulesCategory.find_by_name(categ_name) - if (rule) - rule.description = desc - rule.save - end - end -end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/101_remove_null_snapshot_created_at.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/101_remove_null_snapshot_created_at.rb index 2f09122a289..adc14ea6084 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/101_remove_null_snapshot_created_at.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/101_remove_null_snapshot_created_at.rb @@ -25,8 +25,4 @@ class RemoveNullSnapshotCreatedAt < ActiveRecord::Migration s.save end end - - def self.down - - end end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb new file mode 100644 index 00000000000..8f1cf9c62a2 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb @@ -0,0 +1,41 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2009 SonarSource SA +# 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 +# +class DeleteIsoRuleCategories < ActiveRecord::Migration + + def self.up + remove_rule_categories + delete_measures_on_iso_category + end + + private + + def self.remove_rule_categories + begin + remove_column('rules', 'rules_category_id') + rescue + # already removed + end + end + + def self.delete_measures_on_iso_category + puts "If the following step fails, please execute the SQL request 'DELETE FROM PROJECT_MEASURES WHERE RULE_ID IS NULL AND RULES_CATEGORY_ID IS NOT NULL' and restart Sonar." + ProjectMeasure.delete_all('rule_id is null and rules_category_id is not null') + 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 a6b2552c759..2f76ab1d3bd 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 @@ -115,7 +115,6 @@ public class RegisterRulesTest extends AbstractDbUnitTestCase { assertThat(rule.getDescription(), is("Description of One")); assertThat(rule.getPriority(), is(RulePriority.BLOCKER)); assertThat(rule.getConfigKey(), is("config1")); - assertThat(rule.getRulesCategory(), is(Iso9126RulesCategories.EFFICIENCY)); } @Test @@ -178,7 +177,6 @@ class FakeRepository extends RuleRepository { Rule rule1 = Rule.create("fake", "rule1", "One"); rule1.setDescription("Description of One"); rule1.setPriority(RulePriority.BLOCKER); - rule1.setRulesCategory(Iso9126RulesCategories.EFFICIENCY); rule1.setConfigKey("config1"); rule1.createParameter("param1").setDescription("parameter one"); rule1.createParameter("param2").setDescription("parameter two"); 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 1de750580ab..09b7c3dd728 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 @@ -3,7 +3,7 @@ + enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]" /> 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 628de2bff46..de7eea07189 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 @@ + enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> 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 b2e95b913f9..88e3ae88436 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 @@ + enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> + enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> 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 f3b1d4197ab..a4cef9f0ff2 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 @@ + enabled="false" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> + enabled="true" priority="4" cardinality="SINGLE" parent_id="1"/> \ 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 c53aea894ee..6bd9cbd416a 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 @@ + enabled="true" priority="4" cardinality="MULTIPLE" parent_id="[null]"/> + enabled="true" priority="4" cardinality="SINGLE" parent_id="1"/> \ 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 78595a57e1c..36ee1b8bc69 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 @@ + enabled="true" priority="4" cardinality="SINGLE" parent_id="[null]"/> 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 5afdf8901b9..cd931c60c73 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 @@ -3,10 +3,10 @@ + enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]"/> + enabled="true" priority="1" cardinality="SINGLE" parent_id="[null]"/> 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 b077b4f9663..fca8cf64b12 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 @@ -3,10 +3,10 @@ + enabled="true" priority="2" cardinality="SINGLE" parent_id="[null]"/> + enabled="true" priority="1" cardinality="SINGLE" parent_id="[null]"/> -- 2.39.5
- <%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :categ_id => @categ_id, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %> + <%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %> <%= rule_measure.formatted_value %> @@ -172,8 +126,6 @@ Path: <% if @priority_id %> <%= Sonar::RulePriority.to_s(@priority_id) %> <%= link_to 'clear', {:overwrite_params => {:priority => nil}} %> -<% elsif @categ_id %> -<%= h(RulesCategory.by_id(@categ_id).name) %> <%= link_to 'clear', {:overwrite_params => {:categ_id => nil}} %> <% else %> Any <%= @filter %> <% end %> »  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 8ac42606ba8..fa6f11b1887 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 @@ -55,7 +55,6 @@ <%= rule.plugin_name.capitalize %> <%= rule.category.name %> - Category
- <%= select_tag "categories", options_for_select(@select_categories, @categories), :id => 'search_category', :multiple => true, :size => 6 %> -
Priority
<%= select_tag "priorities", options_for_select(@select_priority, @priorities), :id => 'search_priority', :multiple => true, :size => 6 %> @@ -75,7 +71,7 @@
Active/Priority Name [<%= link_to_function("expand/collapse", "toggle_rules()") %>] PluginCategory
No results.
No results.