From 790976b12929abcae234907202afab1cfbfa3734 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 21 Jan 2014 20:12:21 +0100 Subject: [PATCH] Remove no more used code on active rules --- .../helpers/old_rules_configuration_helper.rb | 86 ------------------- .../webapp/WEB-INF/app/models/active_rule.rb | 8 -- .../app/models/active_rule_parameter.rb | 8 -- .../WEB-INF/app/models/rules_parameter.rb | 12 --- 4 files changed, 114 deletions(-) delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/helpers/old_rules_configuration_helper.rb diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/old_rules_configuration_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/old_rules_configuration_helper.rb deleted file mode 100644 index e66d9fe0d4d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/old_rules_configuration_helper.rb +++ /dev/null @@ -1,86 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -module OldRulesConfigurationHelper - include PropertiesHelper - - PARAM_TYPE_STRING_LIST = "s{}" - PARAM_TYPE_INTEGER_LIST = "i{}" - - # Kept for compatibility with old rule param type - def type_with_compatibility(type) - return PropertyType::TYPE_STRING if type == 's' - return PropertyType::TYPE_STRING if type == PARAM_TYPE_STRING_LIST - return PropertyType::TYPE_INTEGER if type == 'i' - return PropertyType::TYPE_INTEGER if type == PARAM_TYPE_INTEGER_LIST - return PropertyType::TYPE_BOOLEAN if type == 'b' - return PropertyType::TYPE_REGULAR_EXPRESSION if type == 'r' - return PropertyType::TYPE_STRING if is_set(type) - - type - end - - def readable_type(param_type) - type=type_with_compatibility(param_type) - - return "Set of comma delimited strings" if param_type == PARAM_TYPE_STRING_LIST - return "Number" if type == PropertyType::TYPE_INTEGER - return "Set of comma delimited numbers" if param_type == PARAM_TYPE_INTEGER_LIST - return "Regular expression" if type == PropertyType::TYPE_REGULAR_EXPRESSION - return "Set of comma delimited values" if is_set(param_type) - "" - end - - def param_value_input(parameter, value, options = {}) - type=type_with_compatibility(parameter.param_type) - name = options[:name] || 'value' - property_input_field name, type, value, 'WIDGET', {:id => parameter.id, :size => options[:size] }.update(options) - end - - def is_set(type) - type.at(1) == "[" && type.ends_with?("]") - end - - def validate_rule_param(attribute, param_type, errors, value) - return if attribute.nil? or attribute.length == 0 - - type=type_with_compatibility(param_type) - - if is_set_type - attribute.split(',').each do |v| - if !get_allowed_tokens.include?(v) - errors.add("#{value}", "'#{v}' must be one of : " + get_allowed_tokens.join(', ')) - end - end - elsif param_type == RulesConfigurationHelper::PARAM_TYPE_INTEGER_LIST - attribute.split(',').each do |n| - if !Api::Utils.is_integer?(n) - errors.add("#{value}", "'#{n}' must be an integer.") - end - end - elsif type == PropertyType::TYPE_REGULAR_EXPRESSION - errors.add("#{value}", "'#{attribute}' must be a regular expression") unless Api::Utils.is_regexp?(attribute) - elsif type == PropertyType::TYPE_INTEGER - errors.add("#{value}", "'#{attribute}' must be an integer.") unless Api::Utils.is_integer?(attribute) - elsif type == PropertyType::TYPE_BOOLEAN - errors.add("#{value}", "'#{attribute}' must be one of : true,false") unless Api::Utils.is_boolean?(attribute) - end - end -end - diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb index 0f43ae3beef..0267f2e6428 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb @@ -94,14 +94,6 @@ class ActiveRule < ActiveRecord::Base nil end - def copy - new_active_rule = ActiveRule.new(:rule => rule, :failure_level => failure_level) - self.active_rule_parameters.each do |active_rule_parameter| - new_active_rule.active_rule_parameters << active_rule_parameter.copy - end - new_active_rule - end - def inherited? inheritance=='INHERITED' end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_parameter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_parameter.rb index 0bba9a85665..a30fdbb457f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_parameter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_parameter.rb @@ -31,12 +31,4 @@ rules_parameter end - def validate - rules_parameter.validate_value(value, errors, "value") - end - - def copy - ActiveRuleParameter.new(:rules_parameter => rules_parameter, :value => value, :rules_parameter_key => rules_parameter.name) - end - end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb index f8c539a7002..69239fd51cf 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb @@ -25,18 +25,6 @@ class RulesParameter < ActiveRecord::Base validates_presence_of :name, :param_type belongs_to :rule - def is_set_type - param_type.at(1) == "[" && param_type.ends_with?("]") - end - - def get_allowed_tokens - param_type[2, param_type.length-3].split(",") - end - - def validate_value(attribute, errors, value) - validate_rule_param(attribute, param_type, errors, value) - end - def to_hash_json(active_rule) json = {'name' => name} json['description']=description if description -- 2.39.5