|
|
|
@ -209,8 +209,22 @@ class QualityAnalysisController < ApplicationController
|
|
|
|
|
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
|
|
|
|
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
|
|
|
|
|
else
|
|
|
|
|
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read
|
|
|
|
|
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 =JSON.parse(complexity_date).first
|
|
|
|
|
|
|
|
|
|
# 按名称转换成hash键值对
|
|
|
|
|
@ha = {}
|
|
|
|
|
@complexity["msr"].each do |com|
|
|
|
|
|
key = com["key"]
|
|
|
|
|
if key == "sqale_index"
|
|
|
|
|
value = com["frmt_val"]
|
|
|
|
|
else
|
|
|
|
|
value = com["val"].to_i
|
|
|
|
|
end
|
|
|
|
|
@ha.store(key,value)
|
|
|
|
|
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
|
|
|
|
|