resole some nil problems

This commit is contained in:
Your Name 2016-06-29 09:10:47 +08:00
parent 300ad68405
commit 22b40c082c
4 changed files with 62 additions and 44 deletions

View File

@ -27,7 +27,7 @@ class QualityAnalysisController < ApplicationController
@g = Gitlab.client
branch = params[:branch]
language = params[:language]
path = params[:path].nil? ? "./" :params[:path]
path = params[:path].blank? ? "./" : params[:path]
qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
version = qa.nil? ? 1 : qa.sonar_version + 1
properties = "sonar.projectKey=#{sonar_name}

View File

@ -209,7 +209,7 @@
},
series: [{
name: '复杂度',
data: [<%= @complexity["msr"][6]["val"] %>]
data: [<%= @complexity["msr"][6].nil? ? 0 : @complexity["msr"][6]["val"] %>]
// tooltip: {
// valueSuffix: ' km/h'
// }
@ -329,7 +329,7 @@
},
series: [{
name: '重复率',
data: [<%= @complexity["msr"][7]["val"] %>]
data: [<%= @complexity["msr"][7].nil? ? 0 : @complexity["msr"][7]["val"] %>]
// tooltip: {
// valueSuffix: ' km/h'
// }
@ -454,7 +454,7 @@
},
series: [{
name: '质量等级',
data: [<%= @complexity["msr"][5]["val"] %>]
data: [<%= @complexity["msr"][5].nil? ? 0 : @complexity["msr"][5]["val"] %>]
// tooltip: {
// valueSuffix: ' km/h'
// }

View File

@ -1,5 +1,4 @@
<%= javascript_include_tag 'highcharts','highcharts-more' %>
<%= render :partial => "hightchars" %>
<div class="project_r_h">
<h2 class="project_h2" style="width:180px;">质量分析</h2>
</div>
@ -7,66 +6,85 @@
<div class="cl"></div>
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">概要信息</span></div>
<div class="analysis-block mt10 mb40 f14">
<div class="flex">
<div class="analysis-genral">
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">质量等级</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][9]["frmt_val"] %><span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@complexity["msr"][9]["val"].to_i)[1] %> borderRadius"><%= sqale_rating_status(@complexity["msr"][9]["val"].to_i)[0] %></span></p>
<% if @complexity["msr"].count > 3 %>
<%= render :partial => "hightchars" %>
<div class="analysis-block mt10 mb40 f14">
<div class="flex">
<div class="analysis-genral">
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">质量等级</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][9].nil? ? 0 : @complexity["msr"][9]["frmt_val"] %>
<span class="f10 c_white analysis-genral-icon <%=@complexity["msr"][9].nil? ? "" : sqale_rating_status(@complexity["msr"][9]["val"].to_i)[1] %> borderRadius"><%= @complexity["msr"][9].nil? ? 0 : sqale_rating_status(@complexity["msr"][9]["val"].to_i)[0] %></span></p>
</div>
<div class="analysis-genral" >
<p id="container_function_complexity" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">复杂度</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][6].nil? ? 0 : @complexity["msr"][6]["val"] %>
<span class="f10 c_white analysis-genral-icon <%= @complexity["msr"][6].nil? ? "" : complexity_status(@complexity["msr"][6]["val"].to_i)[1] %> borderRadius"><%= @complexity["msr"][6].nil? ? 0 : complexity_status(@complexity["msr"][6]["val"].to_i)[0] %></span></p>
</div>
</div>
<div class="analysis-genral" >
<p id="container_function_complexity" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">复杂度</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][6]["val"] %><span class="f10 c_white analysis-genral-icon <%= complexity_status(@complexity["msr"][6]["val"].to_i)[1] %> borderRadius"><%= complexity_status(@complexity["msr"][6]["val"].to_i)[0] %></span></p>
<div class="flex">
<div class="analysis-genral">
<p id="container_duplicated_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">代码重复度</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][7].nil? ? 0 : @complexity["msr"][7]["frmt_val"] %>
<span class="f10 c_white analysis-genral-icon <%= @complexity["msr"][7].nil? ? "" : duplicated_lines_density_status(@complexity["msr"][7]["val"].to_i)[1] %> borderRadius"><%= @complexity["msr"][7].nil? ? 0 : duplicated_lines_density_status(@complexity["msr"][7]["val"].to_i)[0] %></span></p>
</div>
<div class="analysis-genral">
<p id="container_comment_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">注释率</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][5].nil? ? 0 : @complexity["msr"][5]["frmt_val"] %>
<span class="f10 c_white analysis-genral-icon <%= @complexity["msr"][5].nil? ? "" : comment_lines_density_status(@complexity["msr"][5]["val"].to_i)[1] %> borderRadius"><%= @complexity["msr"][5].nil? ? 0 : comment_lines_density_status(@complexity["msr"][5]["val"].to_i)[0] %></span></p>
</div>
</div>
</div>
<div class="flex">
<div class="analysis-genral">
<p id="container_duplicated_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">代码重复度</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][7]["frmt_val"] %><span class="f10 c_white analysis-genral-icon <%= duplicated_lines_density_status(@complexity["msr"][7]["val"].to_i)[1] %> borderRadius"><%= duplicated_lines_density_status(@complexity["msr"][7]["val"].to_i)[0] %></span></p>
</div>
<div class="analysis-genral">
<p id="container_comment_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">注释率</p>
<p class="fontBlue2 pr"><%= @complexity["msr"][5]["frmt_val"] %><span class="f10 c_white analysis-genral-icon <%= comment_lines_density_status(@complexity["msr"][5]["val"].to_i)[1] %> borderRadius"><%=comment_lines_density_status(@complexity["msr"][5]["val"].to_i)[0] %></span></p>
</div>
</div>
</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl mr10">质量等级</span><span class="mr10 fontGrey2"><span class="c_red f18" style="margin-top:-5px; display:inline-block;"><%= score_sqale_rating(@complexity["msr"][9]["val"].to_i) %></span>/5分</span><span class="fontGrey2">可定性评价为:<span class="c_red">质量<%= sqale_rating_status(@complexity["msr"][9]["val"])[0] %></span></span></div>
<% end %>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl mr10">质量等级</span><span class="mr10 fontGrey2"><span class="c_red f18" style="margin-top:-5px; display:inline-block;"><%=@complexity["msr"][9].nil? ? 0 : score_sqale_rating(@complexity["msr"][9]["val"].to_i) %></span>/5分</span>
<span class="fontGrey2">可定性评价为:<span class="c_red">质量<%=@complexity["msr"][9].nil? ? 0 : sqale_rating_status(@complexity["msr"][9]["val"])[0] %></span></span></div>
<div class="analysis-block mt10 mb40 f14">
<div><span class="fontGrey3 mr30">技术债务</span><span class="fontBlue2 w70 pInline"><%= @complexity["msr"][8]["frmt_val"] %></span><span class="fontGrey2"><a target="_blank" href="<%= @sonar_address %>/drilldown/measures/<%= @resource_id %>?metric=sqale_index">查看详情</a></span></div>
<div><span class="fontGrey3 mr30">技术债务</span><span class="fontBlue2 w70 pInline"><%=@complexity["msr"][8].nil? ? 0 : @complexity["msr"][8]["frmt_val"] %></span>
<span class="fontGrey2"><a target="_blank" href="<%= @sonar_address %>/drilldown/measures/<%= @resource_id %>?metric=sqale_index">查看详情</a></span></div>
<div><span class="fontGrey3 mr30 fl">质量问题</span>
<span class="fontBlue2 w70 pInline"><a class="fontBlue2 w70 pInline" target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false"><%= @sonar_issues["msr"][0]["frmt_val"] %></a></span><span class="fontGrey2">问题分类如下:</span></div>
<span class="fontBlue2 w70 pInline"><a class="fontBlue2 w70 pInline" target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false"><%=@sonar_issues["msr"][0].nil? ? 0 : @sonar_issues["msr"][0]["frmt_val"] %></a></span><span class="fontGrey2">问题分类如下:</span></div>
<div class="ml90 mt15">
<div class="mb10"><span class="analysis-block-icon mr5"></span><span class="fontGrey3 mr45">阻断</span><span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][1]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= statistics_result_percentage(@sonar_issues["msr"][1]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-serious-icon mr5"></span><span class="fontGrey3 mr45">严重</span><span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][2]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= statistics_result_percentage(@sonar_issues["msr"][2]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-main-icon mr5"></span><span class="fontGrey3 mr45">主要</span><span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][3]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= statistics_result_percentage(@sonar_issues["msr"][3]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-secondary-icon mr5"></span><span class="fontGrey3 mr45">次要</span><span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][4]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= statistics_result_percentage(@sonar_issues["msr"][4]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div><span class="analysis-info-icon mr5"></span><span class="fontGrey3 mr45">信息</span><span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][5]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= statistics_result_percentage(@sonar_issues["msr"][5]["frmt_val"].to_i, 200) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-block-icon mr5"></span><span class="fontGrey3 mr45">阻断</span>
<span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][1].nil? ? 0 : @sonar_issues["msr"][1]["frmt_val"] %></span>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@sonar_issues["msr"][1].nil? ? 0 : statistics_result_percentage(@sonar_issues["msr"][1]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-serious-icon mr5"></span><span class="fontGrey3 mr45">严重</span>
<span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][2].nil? ? 0 : @sonar_issues["msr"][2]["frmt_val"] %></span>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@sonar_issues["msr"][2].nil? ? 0 : statistics_result_percentage(@sonar_issues["msr"][2]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-main-icon mr5"></span><span class="fontGrey3 mr45">主要</span>
<span class="fontBlue2 w70 pInline"><%= @sonar_issues["msr"][3].nil? ? 0 : @sonar_issues["msr"][3]["frmt_val"] %></span>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@sonar_issues["msr"][3].nil? ? 0 : statistics_result_percentage(@sonar_issues["msr"][3]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-secondary-icon mr5"></span><span class="fontGrey3 mr45">次要</span>
<span class="fontBlue2 w70 pInline"><%=@sonar_issues["msr"][4].nil? ? 0 : @sonar_issues["msr"][4]["frmt_val"] %></span>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@sonar_issues["msr"][4].nil? ? 0 : statistics_result_percentage(@sonar_issues["msr"][4]["frmt_val"].to_i, 1000) %>%;"></span></span></div>
<div><span class="analysis-info-icon mr5"></span><span class="fontGrey3 mr45">信息</span>
<span class="fontBlue2 w70 pInline"><%=@sonar_issues["msr"][5].nil? ? 0 : @sonar_issues["msr"][5]["frmt_val"] %></span><span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@sonar_issues["msr"][5].nil? ? 0 : statistics_result_percentage(@sonar_issues["msr"][5]["frmt_val"].to_i, 200) %>%;"></span></span></div>
</div>
</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl mr10">代码规模</span><span class="fontGrey2">可定性评价为:<span class="c_red"><%= lines_scale(@complexity["msr"][0]["frmt_val"].to_i) %></span></span></div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl mr10">代码规模</span><span class="fontGrey2">可定性评价为:<span class="c_red"><%=@complexity["msr"][0].nil? ? 0 : lines_scale(@complexity["msr"][0]["frmt_val"].to_i) %></span></span></div>
<div class="analysis-block mt10 mb40 flex f14">
<div class="analysis-genral">
<p class="fontGrey3">代码行数</p>
<p class="fontBlue2"><%= @complexity["msr"][0]["frmt_val"] %></p>
<p class="fontBlue2"><%= @complexity["msr"][0].nil? ? 0 : @complexity["msr"][0]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">文件</p>
<p class="fontBlue2"><%= @complexity["msr"][2]["frmt_val"] %></p>
<p class="fontBlue2"><%= @complexity["msr"][2].nil? ? 0 : @complexity["msr"][2]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">目录</p>
<p class="fontBlue2"><%= @complexity["msr"][3]["frmt_val"] %></p>
<p class="fontBlue2"><%= @complexity["msr"][3].nil? ? 0 : @complexity["msr"][3]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">类</p>
<p class="fontBlue2"><%= @complexity["msr"][1]["frmt_val"] %></p>
<p class="fontBlue2"><%= @complexity["msr"][1].nil? ? 0 : @complexity["msr"][1]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">方法</p>
<p class="fontBlue2"><%= @complexity["msr"][4]["frmt_val"] %></p>
<p class="fontBlue2"><%=@complexity["msr"][4].nil? ? 0 : @complexity["msr"][4]["frmt_val"] %></p>
</div>
</div>
<!--<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>-->

View File

@ -5,9 +5,9 @@
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
<%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
<%# if User.current.member_of?(@project) %>
<% if quality_analysis(User.current.try(:login), @repository.id).nil? %>
<%# if quality_analysis(User.current.try(:login), @repository.id).nil? %>
<%= link_to "质量分析", quality_analysis_path(:id => @project.id), :remote => true, :class => "btn_zipdown fr" %>
<% end %>
<%# end %>
<%# end %>
<%# else %>
<%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %>