<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Rules'} %>
<div class="tabs-panel marginbottom10 ">
- <p>
- <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %>
- <% active_rules ||= 0 %>
- <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}" -%>"><%= active_rules -%> <%= message('coding_rules._rules') -%></a>
- </p>
- <% if @stats %>
+ <% active_rules = @stats.get('countActiveRules').get(0).getValue() if @stats && @stats.get('countActiveRules') %>
+ <% active_rules ||= 0 %>
- <% if @deprecated_active_rules > 0 %>
- <br/>
- <table class="data" style="width:120px">
- <%
- key = 'DEPRECATED'
- status = key.downcase
- value = @deprecated_active_rules
- -%>
- <tr>
- <td>
- <%= message('rules.status.' + status).upcase -%>
- </td>
- <td class="thin left">
- <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|statuses=#{key}" -%>"><%= value -%></a>
- </td>
- </tr>
- </table>
- <% end -%>
+ <div class="widget-span widget-span-3">
+ <div class="widget-measure-container">
+ <div class="widget-measure widget-measure-main">
+ <span class="widget-label"><%= message('rules') -%></span>
+ <span nowrap>
+ <a class="widget-link" href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}" -%>">
+ <span><%= active_rules -%></span>
+ </a>
+ </span>
- <% inheritance = @stats.get('inheritance')
- if inheritance.size > 1
- inheritance_stats = Hash[ *@stats.get('inheritance').collect { |v| [ v.getKey(), v ] }.flatten ] -%>
- <br/>
- <table class="data" style="width:120px">
- <% if inheritance_stats['NONE'] %>
- <tr>
- <td>
- <%= message('coding_rules.filters.inheritance.not_inherited') -%>
- </td>
- <td class="thin left">
- <%= inheritance_stats['NONE'].getValue() -%>
- </td>
- </tr>
- <% end -%>
- <% if inheritance_stats['INHERITED'] %>
- <tr>
- <td>
- <%= message('coding_rules.filters.inheritance.inherited') -%>
- </td>
- <td class="thin left">
- <%= inheritance_stats['INHERITED'].getValue() -%>
- </td>
- </tr>
- <% end -%>
- <% if inheritance_stats['OVERRIDES'] %>
- <tr>
- <td>
- <%= message('coding_rules.filters.inheritance.overriden') -%>
- </td>
- <td class="thin left">
- <%= inheritance_stats['OVERRIDES'].getValue() -%>
- </td>
- </tr>
- <% end -%>
- </table>
- <% end -%>
+ </div>
+ <% if @deprecated_active_rules > 0 %>
+ <div class="widget-measure">
+ <%= message('quality_profiles.including') %> <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|statuses=DEPRECATED" -%>"><%= @deprecated_active_rules -%></a> <%= message('quality_profiles.deprecated') %>
+ </div>
+ <% end %>
+ </div>
+ </div>
- <br/>
+ <% if @stats
+ severity_stats = @stats.get('severity')
+ severity_map = Hash[ *severity_stats.collect { |v| [ v.getKey(), v ] }.flatten ]
- <table class="data" style="width:120px">
- <% @stats.get('severity').each do |stat|
- key = stat.getKey()
- severity = stat.getKey().downcase
- value = stat.getValue()
- -%>
- <tr>
- <td>
- <i class="icon-severity-<%= severity %>"></i><%= message(severity) -%>
- </td>
- <td class="thin left">
- <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|severities=#{key}" -%>"><%= value -%></a>
- </td>
- </tr>
- <% end -%>
- </table>
+ max = severity_stats.map { |val| val.getValue() }.max
+ %>
+ <div class="widget-span widget-span-3">
+ <div class="widget-measure-container">
+ <div class="widget-measure widget-measure-main">
+ <table class="data" style="width:120px">
+ <% Severity::KEYS.each do |key|
+ stat = severity_map[key]
+ severity = key.downcase
+ value = 0
+ value = stat.getValue() if stat
+ -%>
+ <tr>
+ <td>
+ <i class="icon-severity-<%= severity %>"></i><%= message(severity) -%>
+ </td>
+ <td class="thin left">
+ <a href="<%= "#{ApplicationController.root_context}/coding_rules#qprofile=#{@profile.key().toString()}|activation=true|languages=#{@profile.language()}|severities=#{key}" -%>"><%= value -%></a>
+ </td>
+ <td class="nowrap">
+ <% if max > 0 %>
+ <%= barchart(:width => 70, :percent => (100 * value / max).to_i) %>
+ <% end %>
+ </td>
+ </tr>
+ <% end -%>
+ </table>
+ </div>
+ </div>
+ </div>
<% end -%>
</div>
</div>