aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-12 14:20:54 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-12 14:29:20 +0200
commite17cf1c2dc52256336c388c5dc4bde3087c13c1c (patch)
tree37d71b5d2c711c99adfd0181618705b0558eccf0 /server/sonar-web
parent0ace9fe008ae66ca0899827556f1d45fdfeb18c5 (diff)
downloadsonarqube-e17cf1c2dc52256336c388c5dc4bde3087c13c1c.tar.gz
sonarqube-e17cf1c2dc52256336c388c5dc4bde3087c13c1c.zip
SONAR-6637 Stop filling db column PROJECT_MEASURES.RULE_PRIORITY
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb29
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb10
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/231_refactor_rule_measures.rb62
4 files changed, 6 insertions, 97 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
index 928fbb5dcef..35918a606ab 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
@@ -274,20 +274,10 @@ class Api::ResourcesController < Api::ApiController
if params['filter_rules']
(params['filter_rules']=='true') ? params['rules']='false' : params['rules']='true'
end
-
- if params['metrics']
- if params['metrics'].include? 'mandatory_violations'
- params['metrics']=params['metrics'].gsub(/mandatory_violations/, 'violations')
- params['rule_priorities']='MAJOR'
- elsif params['metrics'].include? 'optional_violations'
- params['metrics']=params['metrics'].gsub(/optional_violations/, 'violations')
- params['rule_priorities']='INFO'
- end
- end
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.rule_priority,project_measures.text_value,project_measures.characteristic_id,project_measures.measure_data'
+ select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.characteristic_id,project_measures.measure_data'
if params[:includetrends]=='true'
select_columns+=',project_measures.variation_value_1,project_measures.variation_value_2,project_measures.variation_value_3,project_measures.variation_value_4,project_measures.variation_value_5'
end
@@ -315,17 +305,6 @@ class Api::ResourcesController < Api::ApiController
measures_values[:rule_ids]=rule_ids.compact
end
- param_priorities = params['rule_priorities'] || 'false'
- if param_priorities=='true'
- measures_conditions << "project_measures.rule_priority IS NOT NULL"
- elsif param_priorities=='false'
- measures_conditions << "project_measures.rule_priority IS NULL" if param_rules=='false'
- else
- measures_conditions << "project_measures.rule_priority IN (:priorities)"
- measures_values[:priorities]=param_priorities.split(',').map do |p|
- Sonar::RulePriority.id(p)
- end.compact
- end
end
def add_characteristic_filters(measures_conditions, measures_values)
@@ -454,9 +433,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.rule_priority
- json_measure[:rule_priority] = Sonar::RulePriority.to_s(measure.rule_priority)
- end
if measure.characteristic_id
characteristic=@characteristic_by_id[measure.characteristic_id]
json_measure[:ctic_key]=(characteristic ? characteristic.kee : '')
@@ -541,9 +517,6 @@ class Api::ResourcesController < Api::ApiController
xml.rule_key(rule.key) if rule
xml.rule_name(rule.name) if rule
end
- if measure.rule_priority
- xml.rule_priority(Sonar::RulePriority.to_s(measure.rule_priority))
- end
if measure.characteristic_id
characteristic=@characteristic_by_id[measure.characteristic_id]
xml.ctic_key(characteristic ? characteristic.kee : '')
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb
index 83b50b73d7f..64f83d1f554 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb
@@ -68,7 +68,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.rule_priority.nil? && item.characteristic_id.nil? && item.person_id.nil?)
+ return item if (item && metric && item.metric_id==metric.id && item.characteristic_id.nil? && item.person_id.nil?)
end
nil
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
index c85fcbb789a..e3195f67456 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb
@@ -44,7 +44,7 @@ class ProjectMeasure < ActiveRecord::Base
end
def rule_measure?
- rule_id || rule_priority
+ rule_id != nil
end
def data
@@ -233,14 +233,12 @@ class ProjectMeasure < ActiveRecord::Base
# Deprecated in v.2.13. Replaced by severity()
def rule_priority_text
- severity
+ nil
end
+ # not used for a while. Deprecated in 5.2.
def severity
- @severity ||=
- begin
- rule_priority ? Sonar::RulePriority.to_s(rule_priority) : nil
- end
+ nil
end
def key
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/231_refactor_rule_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/231_refactor_rule_measures.rb
deleted file mode 100644
index aaa2113df77..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/231_refactor_rule_measures.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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.
-#
-
-#
-# Sonar 2.13
-# http://jira.sonarsource.com/browse/SONAR-1974
-#
-class RefactorRuleMeasures < ActiveRecord::Migration
-
- class ProjectMeasure < ActiveRecord::Base
- end
-
- class Metric < ActiveRecord::Base
- end
-
- def self.up
- Metric.reset_column_information
- ProjectMeasure.reset_column_information
-
- replace('violations', 0, 'info_violations')
- replace('violations', 1, 'minor_violations')
- replace('violations', 2, 'major_violations')
- replace('violations', 3, 'critical_violations')
- replace('violations', 4, 'blocker_violations')
-
- replace('new_violations', 0, 'new_info_violations')
- replace('new_violations', 1, 'new_minor_violations')
- replace('new_violations', 2, 'new_major_violations')
- replace('new_violations', 3, 'new_critical_violations')
- replace('new_violations', 4, 'new_blocker_violations')
- end
-
-
- private
- def self.replace(from_metric_key, from_severity, to_metric_key)
- from_metric = Metric.find_by_name(from_metric_key)
- to_metric = Metric.find_by_name(to_metric_key)
-
- if from_metric && to_metric
- say_with_time("Update metric #{to_metric_key}") do
- ProjectMeasure.update_all("metric_id=#{to_metric.id}", "metric_id=#{from_metric.id} AND rule_id IS NOT NULL AND rule_priority=#{from_severity}")
- end
- end
- end
-end