dev_shcool
huang 9 years ago
parent 62cb7d4568
commit cb148c3b9c

@ -213,7 +213,8 @@ class QualityAnalysisController < ApplicationController
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
else else
filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations" filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations"
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read # complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read
complexity_date = open("http://sonar.trustie.net" + "/api/resources/index?resource=947&depth=0&metrics=#{filter}").read
@complexity =JSON.parse(complexity_date).first @complexity =JSON.parse(complexity_date).first
# 按名称转换成hash键值对 # 按名称转换成hash键值对
@ -227,9 +228,6 @@ class QualityAnalysisController < ApplicationController
end end
@ha.store(key,value) @ha.store(key,value)
end end
issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read
@sonar_issues = JSON.parse(issue_date).first
end end
rescue => e rescue => e
puts e puts e

@ -3,16 +3,16 @@ module QualityAnalysisHelper
def sqale_rating_status val def sqale_rating_status val
arr = [] arr = []
if val < 5 if val <= 5
arr << "很好" arr << "很好"
arr << "b_green2" arr << "b_green2"
elsif val. > 5 && val < 10 elsif val. > 5 && val <= 10
arr << "较好" arr << "较好"
arr << "b_slow_yellow" arr << "b_slow_yellow"
elsif val > 10 && val < 20 elsif val > 10 && val <= 20
arr << "中等" arr << "中等"
arr << "b_yellow" arr << "b_yellow"
elsif val > 20 && val < 50 elsif val > 20 && val <= 50
arr << "较差" arr << "较差"
arr << "b_slow_red" arr << "b_slow_red"
elsif val > 20 elsif val > 20
@ -23,10 +23,10 @@ module QualityAnalysisHelper
def complexity_status val def complexity_status val
arr = [] arr = []
if val < 10 if val <= 10
arr << "良好" arr << "良好"
arr << "b_green2" arr << "b_green2"
elsif val > 10 && val < 15 elsif val > 10 && val <= 15
arr << "较高" arr << "较高"
arr << "b_yellow" arr << "b_yellow"
elsif val > 15 elsif val > 15
@ -37,10 +37,10 @@ module QualityAnalysisHelper
def duplicated_lines_density_status val def duplicated_lines_density_status val
arr = [] arr = []
if val < 30 if val <= 30
arr << "良好" arr << "良好"
arr << "b_green2" arr << "b_green2"
elsif val > 30 && val < 50 elsif val > 30 && val <= 50
arr << "较高" arr << "较高"
arr << "b_yellow" arr << "b_yellow"
elsif val > 50 elsif val > 50
@ -51,10 +51,10 @@ module QualityAnalysisHelper
def comment_lines_density_status val def comment_lines_density_status val
arr = [] arr = []
if val < 20 if val <= 20
arr << "较低" arr << "较低"
arr << "b_yellow" arr << "b_yellow"
elsif val > 20 && val < 50 elsif val > 20 && val <= 50
arr << "正常" arr << "正常"
arr << "b_green2" arr << "b_green2"
elsif val > 50 elsif val > 50
@ -64,15 +64,15 @@ module QualityAnalysisHelper
end end
def score_sqale_rating val def score_sqale_rating val
if val > 0 && val < 5 if val >= 0 && val <= 5
"5" "5"
elsif val > 5 && val < 10 elsif val > 5 && val <= 10
"4" "4"
elsif val > 10 && val < 20 elsif val > 10 && val <= 20
"3" "3"
elsif val > 20 && val < 50 elsif val > 20 && val <= 50
"2" "2"
elsif val > 20 elsif val > 50
"1" "1"
end end
end end

Loading…
Cancel
Save