diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-03 00:09:06 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-03 00:09:06 +0000 |
commit | 3ed6a62ad9e0fa21c108ab1e13724c90269ad2ca (patch) | |
tree | 930376e159c42017e51bb6f9376360424050c28b /plugins | |
parent | fcd0d57b85fcc029d8fa2e05d6e03fd9225c8134 (diff) | |
download | sonarqube-3ed6a62ad9e0fa21c108ab1e13724c90269ad2ca.tar.gz sonarqube-3ed6a62ad9e0fa21c108ab1e13724c90269ad2ca.zip |
SONAR-249 do not hide widgets which are changed in variation view + improve ruby api to display trend icons and measure variations + support variations in the widgets rules/size
Diffstat (limited to 'plugins')
2 files changed, 117 insertions, 58 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb index c62d9c4c78e..8875bed9ffd 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb @@ -1,88 +1,134 @@ -<% if measure(Metric::LINES) %> +<% + violations=@snapshot.measure('violations') + density=@snapshot.measure('violations_density') + blocker_violations = @snapshot.measure('blocker_violations') + critical_violations = @snapshot.measure('critical_violations') + major_violations = @snapshot.measure('major_violations') + minor_violations = @snapshot.measure('minor_violations') + info_violations = @snapshot.measure('info_violations') +%> <table width="100%"> <tr> - <td valign="top" width="50%"> + <td valign="top"> <div class="dashbox"> <h3>Violations</h3> - <div class="big marginbottom10"> - <%= format_measure(Metric::VIOLATIONS, :url => url_for(:controller => 'drilldown', :action => 'violations', :id => @project.key)) -%> <%= trend_icon(Metric::VIOLATIONS) -%> + <div class="marginbottom10"> + <span class="big"> + <%= format_measure(violations, :url => url_for(:controller => 'drilldown', :action => 'violations', :id => @project.key)) -%> + </span> + <%= dashboard_configuration.variation? ? format_variation(violations) : trend_icon(violations) -%> </div> <h3>Rules compliance</h3> - <div class="big"> - <%= format_measure(Metric::VIOLATIONS_DENSITY, :url => url_for_drilldown(Metric::WEIGHTED_VIOLATIONS, {:highlight => Metric::WEIGHTED_VIOLATIONS})) -%> <%= trend_icon(Metric::VIOLATIONS_DENSITY) -%> + <div> + <span class="big"> + <%= format_measure(density, :url => url_for_drilldown(Metric::WEIGHTED_VIOLATIONS, {:highlight => Metric::WEIGHTED_VIOLATIONS})) -%> + </span> + <%= dashboard_configuration.variation? ? format_variation(density) : trend_icon(density) -%> </div> </div> </td> - <td valign="top" width="50%" nowrap> + <td valign="top" nowrap> <% - blocker_violations = @snapshot.measure(Metric::BLOCKER_VIOLATIONS) - critical_violations = @snapshot.measure(Metric::CRITICAL_VIOLATIONS) - major_violations = @snapshot.measure(Metric::MAJOR_VIOLATIONS) - minor_violations = @snapshot.measure(Metric::MINOR_VIOLATIONS) - info_violations = @snapshot.measure(Metric::INFO_VIOLATIONS) - max = 0 - [blocker_violations,critical_violations,major_violations,minor_violations,info_violations].each do |m| - max = m.value if m and m.value and m.value>max - end + values=[blocker_violations,critical_violations,major_violations,minor_violations,info_violations] + if dashboard_configuration.variation? + values=values.map{|m| m ? (m.variation(dashboard_configuration.variation_index)||0) : 0} + else + values=values.map{|m| m ? (m.value||0) : 0} + end + max=values.map{|val| val.abs}.max %> <table class="clear width100"> <tr> <td><%= image_tag 'priority/BLOCKER.png'%></td> <td> <%= link_to 'Blocker', {:controller => 'drilldown', :action => 'violations', :id => @project.key, :priority => 'BLOCKER'} %></td> - <td style="padding-left: 10px;" align="right"> + <td style="padding: 0 10px;" align="right"> <%= format_measure(blocker_violations) -%> </td> - <td width="1%"><%= trend_icon(blocker_violations) -%></td> + <td> + <%= dashboard_configuration.variation? ? format_variation(blocker_violations) : trend_icon(blocker_violations, :empty => true) -%> + </td> <td align="left" style="padding-bottom:2px; padding-top:2px;"> - <%= barchart(:width => 60, :percent => (blocker_violations ? (100 * blocker_violations.value / max).to_i : 0), :color => '#777777') if max>0 %> + <% if dashboard_configuration.variation? %> + <%= barchart(:width => 35, :percent => (values[0]<0 ? (100 * values[0] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[0]>0 ? (100 * values[0] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[0] / max).to_i) %> + <% end %> </td> </tr> <tr> <td><%= image_tag 'priority/CRITICAL.png' %></td> <td> <%= link_to 'Critical', {:controller => 'drilldown', :action => 'violations', :id => @project.key, :priority => 'CRITICAL'} %></td> - <td style="padding-left: 10px;" align="right"> - <%= format_measure(critical_violations) -%> + <td style="padding: 0 10px;" align="right"> + <%= format_measure(critical_violations) -%> + </td> + <td> + <%= dashboard_configuration.variation? ? format_variation(critical_violations) : trend_icon(critical_violations, :empty => true) -%> </td> - <td width="1%"><%= trend_icon(critical_violations) -%></td> <td align="left" style="padding-bottom:2px; padding-top:2px;"> - <%= barchart(:width => 60, :percent => (critical_violations ? (100 * critical_violations.value / max).to_i : 0), :color => '#777777') if max>0 %> + <% if dashboard_configuration.variation? %> + <%= barchart(:width => 35, :percent => (values[1]<0 ? (100 * values[1] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[1]>0 ? (100 * values[1] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[1] / max).to_i) %> + <% end %> </td> </tr> <tr> <td><%= image_tag 'priority/MAJOR.png' %></td> <td> <%= link_to 'Major', {:controller => 'drilldown', :action => 'violations', :id => @project.key, :priority => 'MAJOR'} %></td> - <td style="padding-left: 10px;" align="right"> + <td style="padding: 0 10px;" align="right"> <%= format_measure(major_violations) -%> - </td> - <td width="1%"><%= trend_icon(major_violations) -%></td> + </td> + <td> + <%= dashboard_configuration.variation? ? format_variation(major_violations) : trend_icon(major_violations, :empty => true) -%> + </td> <td align="left" style="padding-bottom:2px; padding-top:2px;"> - <%= barchart(:width => 60, :percent => (major_violations ? (100 * major_violations.value / max).to_i : 0), :color => '#777777') if max>0 %> + <% if dashboard_configuration.variation? %> + <%= barchart(:width => 35, :percent => (values[2]<0 ? (100 * values[2] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[2]>0 ? (100 * values[2] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[2] / max).to_i) %> + <% end %> </td> </tr> <tr> <td><%= image_tag 'priority/MINOR.png' %></td> <td> <%= link_to 'Minor', {:controller => 'drilldown', :action => 'violations', :id => @project.key, :priority => 'MINOR'} %></td> - <td style="padding-left: 10px;" align="right"> - <%= format_measure(minor_violations) -%> - </td> - <td width="1%"><%= trend_icon(minor_violations) -%></td> + <td style="padding: 0 10px;" align="right"> + <%= format_measure(minor_violations) -%> + </td> + <td> + <%= dashboard_configuration.variation? ? format_variation(minor_violations) : trend_icon(minor_violations, :empty => true) -%> + </td> <td align="left" style="padding-bottom:2px; padding-top:2px;"> - <%= barchart(:width => 60, :percent => (minor_violations ? (100 * minor_violations.value / max).to_i : 0), :color => '#777777') if max>0 %> + <% if dashboard_configuration.variation? %> + <%= barchart(:width => 35, :percent => (values[3]<0 ? (100 * values[3] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[3]>0 ? (100 * values[3] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[3] / max).to_i) %> + <% end %> </td> </tr> <tr> <td><%= image_tag 'priority/INFO.png' %></td> <td> <%= link_to 'Info', {:controller => 'drilldown', :action => 'violations', :id => @project.key, :priority => 'INFO'} %></td> - <td style="padding-left: 10px;" align="right"> - <%= format_measure(info_violations) -%> - </td> - <td width="1%"><%= trend_icon(info_violations) -%></td> + <td style="padding: 0 10px;" align="right"> + <%= format_measure(info_violations) -%> + </td> + <td> + <%= dashboard_configuration.variation? ? format_variation(info_violations) : trend_icon(info_violations, :empty => true) -%> + </td> <td align="left" style="padding-bottom:2px; padding-top:2px;"> - <%= barchart(:width => 60, :percent => (info_violations ? (100 * info_violations.value / max).to_i : 0), :color => '#777777') if max>0 %> + <% if dashboard_configuration.variation? %> + <%= barchart(:width => 35, :percent => (values[4]<0 ? (100 * values[4] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[4]>0 ? (100 * values[4] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[4] / max).to_i) %> + <% end %> </td> </tr> </table> </td> </tr> - </table> -<% end %>
\ No newline at end of file + </table> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb index bf89a8e1903..1e8e44cf792 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb @@ -1,63 +1,76 @@ <% -if measure('lines') || measure('ncloc') + lines=measure('lines') + ncloc=measure('ncloc') + classes=measure('classes') files=measure('files') - statements=measure('statements') + packages=measure('packages') + functions=measure('functions') + if measure('lines') || ncloc + files=measure('files') + statements=measure('statements') %> <table width="100%"> <tr> <td valign="top" width="48%" nowrap> <div class="dashbox"> <h3>Lines of code</h3> - <% if measure('ncloc') %> - <p><span class="big"> - <%= format_measure('ncloc', :suffix => '', :url => url_for_drilldown('ncloc')) -%> <%= trend_icon('ncloc', :big => true) -%></span></p> + <% if ncloc %> + <p> + <span class="big"><%= format_measure(ncloc, :suffix => '', :url => url_for_drilldown(ncloc)) -%></span> + <%= dashboard_configuration.variation? ? format_variation(ncloc) : trend_icon(ncloc, :big => true) -%> + </p> <% generated_ncloc=measure('generated_ncloc') if generated_ncloc && generated_ncloc.value>0 %> - <p>+<%= format_measure(generated_ncloc, :suffix => ' generated', :url => url_for_drilldown(generated_ncloc)) -%> <%= trend_icon(generated_ncloc) -%></p> + <p>+<%= format_measure(generated_ncloc, :suffix => ' generated', :url => url_for_drilldown(generated_ncloc)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%></p> <% end %> - <p><%= format_measure('lines', :suffix => ' lines', :url => url_for_drilldown('lines')) -%> <%= trend_icon('lines') -%></p> + <p><%= format_measure(lines, :suffix => ' lines', :url => url_for_drilldown(lines)) -%> <%= dashboard_configuration.variation? ? format_variation(lines) : trend_icon(lines) -%></p> <% else%> - <p><span class="big"><%= format_measure('lines', :suffix => '', :url => url_for_drilldown('lines')) -%> <%= trend_icon('lines', :big => true) -%></span></p> + <p><span class="big"><%= format_measure(lines, :suffix => '', :url => url_for_drilldown(lines)) -%> <%= trend_icon(lines, :big => true) -%></span></p> <% end %> <% generated_lines=measure('generated_lines') if generated_lines && generated_lines.value>0 %> - <p>incl. <%= format_measure(generated_lines, :suffix => ' generated', :url => url_for_drilldown(generated_lines)) -%> <%= trend_icon(generated_lines) -%></p> + <p>incl. <%= format_measure(generated_lines, :suffix => ' generated', :url => url_for_drilldown(generated_lines)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_lines) : trend_icon(generated_lines) -%></p> <% end %> <% if statements %> <p> - <%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= trend_icon(statements) -%> + <%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= dashboard_configuration.variation? ? format_variation(statements) : trend_icon(statements) -%> </p> <% end %> <% if files && measure('classes') %> - <p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= trend_icon(files) -%></p> + <p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files) -%></p> <% end %> </div> </td> <td width="10"> </td> <td valign="top"> <div class="dashbox"> - <% if measure('classes') %> + <% if classes %> <h3>Classes</h3> - <p><span class="big"><%= format_measure('classes', :url => url_for_drilldown('classes')) -%> <%= trend_icon('classes') -%></span></p> - <p><%= format_measure('packages', :suffix => ' packages', :url => url_for_drilldown('packages')) -%> <%= trend_icon('packages') -%></p> + <p> + <span class="big"><%= format_measure(classes, :url => url_for_drilldown(classes)) -%></span> + <%= dashboard_configuration.variation? ? format_variation(classes) : trend_icon(classes, :big => true) -%> + </p> + <p><%= format_measure(packages, :suffix => ' packages', :url => url_for_drilldown(packages)) -%> <%= dashboard_configuration.variation? ? format_variation(packages) : trend_icon(packages) -%></p> <% else %> <h3>Files</h3> - <p><span class="big"><%= format_measure('files', :url => url_for_drilldown('files')) -%> <%= trend_icon('files') -%></span></p> - <p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= trend_icon('directories') -%></p> + <p><span class="big"><%= format_measure(files, :url => url_for_drilldown(files)) -%></span> + <%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files, :big => true) -%> + </p> + <p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= dashboard_configuration.variation? ? format_variation('directories') : trend_icon('directories') -%></p> <% end %> - <p><%= format_measure('functions', :suffix => ' methods', :url => url_for_drilldown('functions')) -%> <%= trend_icon('functions') -%></p> + <p><%= format_measure(functions, :suffix => ' methods', :url => url_for_drilldown(functions)) -%> <%= dashboard_configuration.variation? ? format_variation(functions) : trend_icon(functions) -%></p> <% if (measure('accessors')) prefix=(dashboard_configuration.variation? ? '' : '+') %> - <p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= trend_icon('accessors') -%></p> + <p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= dashboard_configuration.variation? ? format_variation('accessors') : trend_icon('accessors') -%></p> <% end %> <% if measure('paragraphs') %> - <p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= trend_icon('paragraphs') -%></p> + <p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= dashboard_configuration.variation? ? format_variation('paragraphs') : trend_icon('paragraphs') -%></p> <% end %> </div> </td> |