diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-05-07 15:05:05 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-05-07 15:05:05 +0200 |
commit | 8f936044deed48e659bffaa9e6587fe22143a192 (patch) | |
tree | 1b055d6807c8323cbcd0dee50f29dc69fa0a60e7 /plugins | |
parent | 12077a645e769be0d4387f30a1e5f5c1966dc08e (diff) | |
download | sonarqube-8f936044deed48e659bffaa9e6587fe22143a192.tar.gz sonarqube-8f936044deed48e659bffaa9e6587fe22143a192.zip |
SONAR-5130 Show distribution of LOC and TechDebt by language
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java | 2 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb | 35 |
2 files changed, 35 insertions, 2 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java index b3330c7833f..0df49408671 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/SizeWidget.java @@ -22,6 +22,6 @@ package org.sonar.plugins.core.widgets; public class SizeWidget extends CoreWidget { public SizeWidget() { - super("size", "Size metrics", "/org/sonar/plugins/core/widgets/size.html.erb"); + super("size", "Size metrics", "/Users/julienlancelot/Dev/Sources/sonar/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb"); } } 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 e3f741587f4..f30117a5bde 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,6 +1,7 @@ <% lines=measure('lines') ncloc=measure('ncloc') + ncloc_language_distribution=measure('ncloc_language_distribution') classes=measure('classes') files=measure('files') functions=measure('functions') @@ -8,6 +9,7 @@ if measure('lines') || ncloc files=measure('files') statements=measure('statements') + languages = Api::Utils.java_facade.getLanguages() %> <table width="100%"> <tr> @@ -15,7 +17,16 @@ <div class="dashbox"> <% if ncloc %> - <h3><%= message('widget.size.lines_of_code') -%></h3> + <% + ncloc_language_dist_hash = Hash[*(ncloc_language_distribution.data.split(';').map { |elt| elt.split('=') }.flatten)] if ncloc_language_distribution + if ncloc_language_dist_hash && ncloc_language_dist_hash.size == 1 + language_key = ncloc_language_dist_hash.first()[0].to_s + language = languages.find { |l| l.getKey()==language_key } + %> + <h3><%= message('widget.size.lines_of_code_with_language', :params => (language ? language.getName() : language_key)) -%></h3> + <% else %> + <h3><%= message('widget.size.lines_of_code') -%></h3> + <% end %> <p> <span class="big"><%= format_measure(ncloc, :suffix => '', :url => url_for_drilldown(ncloc)) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(ncloc) : trend_icon(ncloc) -%> @@ -45,6 +56,28 @@ <% if projects %> <p><%= format_measure(projects, :suffix => message('widget.size.projects.suffix')) -%> <%= dashboard_configuration.selected_period? ? format_variation(projects) : trend_icon(projects) -%></p> <% end %> + + <% if ncloc_language_dist_hash && ncloc_language_dist_hash.size > 1 %> + <table class="clear width100"> + <% + max = ncloc_language_dist_hash.max_by{|_k,v| v.to_i}[1].to_i + # Sort lines language distribution by reverse number of lines + ncloc_language_dist_hash.sort {|v1,v2| v2[1].to_i <=> v1[1].to_i }.each do |language_key, language_ncloc| + tooltip = ncloc.format_numeric_value(language_ncloc) + message('widget.size.lines_of_code.suffix') + %> + <tr> + <td> + <% language = languages.find { |l| l.getKey()==language_key.to_s } -%> + <%= language ? language.getName() : language_key -%> + </td> + <td> </td> + <td align="left" style="padding-bottom:2px; padding-top:2px;"> + <%= barchart(:width => 70, :percent => (100 * language_ncloc.to_i / max).to_i, :tooltip => tooltip)%> + </td> + </tr> + <% end %> + </table> + <% end %> </div> </td> <td width="10"> </td> |