aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb6
3 files changed, 17 insertions, 7 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 82eb81b3524..9f9c773f0db 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -871,6 +871,15 @@ manual_measures.pending_message=Pending measures are marked with orange box. The
#------------------------------------------------------------------------------
#
+# MANUAL MEASURES
+#
+#------------------------------------------------------------------------------
+
+manual_rules.should_provide_real_description=Rule created on the fly. A description should be provided.
+
+
+#------------------------------------------------------------------------------
+#
# PROJECT HISTORY SERVICE
#
#------------------------------------------------------------------------------
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
index 6868c23bfed..8d1f9079885 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_rules_controller.rb
@@ -45,14 +45,13 @@ class ManualRulesController < ApplicationController
# Update rule
rule=Rule.manual_rule(params['id'].to_i)
bad_request('Unknown rule') unless rule
-
+ rule.name=(params[:name])
+ rule.description=params[:description]
+ rule.save!
else
# Create rule
- rule=Rule.find_or_create_manual_rule(params[:name], true)
+ rule=Rule.find_or_create_manual_rule(params[:name], true, {:description => params[:description]})
end
- rule.name=(params[:name])
- rule.description=params[:description]
- rule.save!
rescue Exception => e
flash[:error]= e.message
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 51d6df0a5fa..71fbd6a411f 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
@@ -136,14 +136,16 @@ class Rule < ActiveRecord::Base
Rule.find(:first, :conditions => ['enabled=? and plugin_name=? and id=?', true, MANUAL_REPOSITORY_KEY, id])
end
- def self.find_or_create_manual_rule(rule_id_or_name, create_if_not_found=false)
+ def self.find_or_create_manual_rule(rule_id_or_name, create_if_not_found=false, options={})
if Api::Utils.is_integer?(rule_id_or_name)
rule = Rule.find(:first, :conditions => {:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :id => rule_id_or_name.to_i})
else
key = rule_id_or_name.strip.downcase.sub(/\s+/, '_')
rule = Rule.find(:first, :conditions => {:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key})
if rule==nil && create_if_not_found
- rule = Rule.create!(:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key, :name => rule_id_or_name)
+ description = options[:description] || Api::Utils.message('manual_rules.should_provide_real_description')
+ rule = Rule.create!(:enabled => true, :plugin_name => MANUAL_REPOSITORY_KEY, :plugin_rule_key => key,
+ :name => rule_id_or_name, :description => description)
end
end
rule