98 lines
2.0 KiB
Ruby
98 lines
2.0 KiB
Ruby
# encoding: utf-8
|
|
module QualityAnalysisHelper
|
|
|
|
def sqale_rating_status val
|
|
arr = []
|
|
if val.to_i > 0 && val.to_i < 5
|
|
arr << "很好"
|
|
arr << "b_green2"
|
|
elsif val.to_i > 5 && val.to_i < 10
|
|
arr << "较好"
|
|
arr << "b_slow_yellow"
|
|
elsif val.to_i > 10 && val.to_i < 20
|
|
arr << "中等"
|
|
arr << "b_yellow"
|
|
elsif val.to_i > 20 && val.to_i < 50
|
|
arr << "较差"
|
|
arr << "b_slow_red"
|
|
elsif val.to_i > 20
|
|
arr << "很差"
|
|
arr << "b_red"
|
|
end
|
|
end
|
|
|
|
def complexity_status val
|
|
arr = []
|
|
if val.to_i < 10
|
|
arr << "良好"
|
|
arr << "b_green2"
|
|
elsif val.to_i > 10 && val.to_i < 15
|
|
arr << "较高"
|
|
arr << "b_yellow"
|
|
elsif val.to_i > 15
|
|
arr << "很高"
|
|
arr << "b_red"
|
|
end
|
|
end
|
|
|
|
def duplicated_lines_density_status val
|
|
arr = []
|
|
if val.to_i < 30
|
|
arr << "良好"
|
|
arr << "b_green2"
|
|
elsif val.to_i > 30 && val.to_i < 50
|
|
arr << "较高"
|
|
arr << "b_yellow"
|
|
elsif val.to_i > 50
|
|
arr << "很高"
|
|
arr << "b_red"
|
|
end
|
|
end
|
|
|
|
def comment_lines_density_status val
|
|
arr = []
|
|
if val.to_i < 20
|
|
arr << "较低"
|
|
arr << "b_yellow"
|
|
elsif val.to_i > 20 && val.to_i < 50
|
|
arr << "正常"
|
|
arr << "b_green2"
|
|
elsif val.to_i > 50
|
|
arr << "较高"
|
|
arr << "b_red"
|
|
end
|
|
end
|
|
|
|
def score_sqale_rating val
|
|
if val.to_i > 0 && val.to_i < 5
|
|
"5"
|
|
elsif val.to_i > 5 && val.to_i < 10
|
|
"4"
|
|
elsif val.to_i > 10 && val.to_i < 20
|
|
"3"
|
|
elsif val.to_i > 20 && val.to_i < 50
|
|
"2"
|
|
elsif val.to_i > 20
|
|
"1"
|
|
end
|
|
end
|
|
|
|
def lines_scale val
|
|
if val.to_i < 5000
|
|
"小型"
|
|
elsif val.to_i >5000 && val.to_i < 50000
|
|
"中型"
|
|
else
|
|
"大型"
|
|
end
|
|
end
|
|
|
|
#统计答题百分比,统计结果保留两位小数
|
|
def statistics_result_percentage(e, t)
|
|
e = e.to_f
|
|
t = t.to_f
|
|
t == 0 ? 0 : format("%.2f", e*100/t)
|
|
end
|
|
|
|
end
|