]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-249 add variations to widgets comments, tests and complexity
authorsimonbrandhof <simon.brandhof@gmail.com>
Fri, 3 Dec 2010 11:05:14 +0000 (11:05 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Fri, 3 Dec 2010 11:05:14 +0000 (11:05 +0000)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb

index 3ca7e36b1b52caa24e7e3fb228471a52397faf0f..85eaf154043beb4d2149b9ff483e014a63a73fe4 100644 (file)
@@ -1,43 +1,69 @@
 <%
-code_coverage_measure=measure(Metric::COVERAGE)
-tests_measure=measure(Metric::TESTS)
-if code_coverage_measure || tests_measure %>
+  code_coverage_measure=measure(Metric::COVERAGE)
+  tests_measure=measure(Metric::TESTS)
+  execution_time=measure(Metric::TEST_EXECUTION_TIME)
+  success_percentage=measure(Metric::TEST_SUCCESS_DENSITY)
+
+  if code_coverage_measure || tests_measure
+%>
 <table width="100%">
        <tr>
                <td valign="top" width="50%" nowrap>
       <div class="dashbox">
         <p class="title">Code coverage</p>
-        <p><span class="big"><%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown(Metric::COVERAGE), :default => '-') %> <%= trend_icon(code_coverage_measure, :big => true) %></span></p>
+        <p>
+          <span class="big"><%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown(Metric::COVERAGE), :default => '-') %></span>
+          <%= dashboard_configuration.variation? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure, :big => true) -%>
+        </p>
         <% line_coverage=measure(Metric::LINE_COVERAGE)
           if line_coverage %>
-          <p><%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight =>  Metric::LINE_COVERAGE)) %> <%= trend_icon(line_coverage) %></p>
+          <p>
+            <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight =>  Metric::LINE_COVERAGE)) -%>
+            <%= dashboard_configuration.variation? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>
+          </p>
         <% end %>
         <% branch_coverage=measure(Metric::BRANCH_COVERAGE)
           if branch_coverage %>
-          <p><%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown(Metric::UNCOVERED_CONDITIONS, :highlight =>  Metric::BRANCH_COVERAGE)) %> <%= trend_icon(branch_coverage) %></p>
+          <p>
+            <%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown(Metric::UNCOVERED_CONDITIONS, :highlight =>  Metric::BRANCH_COVERAGE)) %>
+            <%= dashboard_configuration.variation? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
+          </p>
         <% end %>
-        <p><%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown(Metric::TESTS)) %> <%= trend_icon(tests_measure) %></p>
+        <p>
+          <%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown(Metric::TESTS)) -%>
+          <%= dashboard_configuration.variation? ? format_variation(tests_measure) : trend_icon(tests_measure) -%>
+        </p>
         <% skipped_measure=measure(Metric::SKIPPED_TESTS)
-           if skipped_measure && skipped_measure.value>0
+           if skipped_measure
         %>
-        <p>+<%= format_measure(skipped_measure, :suffix => ' skipped', :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %> <%= trend_icon(skipped_measure) %></p>
+        <p>
+          +<%= format_measure(skipped_measure, :suffix => ' skipped', :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %>
+          <%= dashboard_configuration.variation? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%>
+        </p>
         <% end %>
-        <p><%= format_measure(Metric::TEST_EXECUTION_TIME, :suffix => '', :url => url_for_drilldown(Metric::TEST_EXECUTION_TIME)) %> <%= trend_icon(measure(Metric::TEST_EXECUTION_TIME)) %></p>
+        <p>
+          <%= format_measure(execution_time, :suffix => '', :url => url_for_drilldown(Metric::TEST_EXECUTION_TIME)) -%>
+          <%= dashboard_configuration.variation? ? format_variation(execution_time) : trend_icon(execution_time) -%>
+        </p>
       </div>
     </td>
     <td valign="top" width="50%" nowrap>
   <%
-  success_percentage=measure(Metric::TEST_SUCCESS_DENSITY)
   if success_percentage
   %>
   <div class="dashbox">
       <h3>Test success</h3>
-      <p><span class="big"><%= format_measure(success_percentage, :suffix => '', :url => url_for_drilldown(success_percentage)) %> <%= trend_icon(measure(Metric::TEST_SUCCESS_DENSITY), :big => true) %></span></p>
+      <p><span class="big">
+        <%= format_measure(success_percentage, :suffix => '', :url => url_for_drilldown(success_percentage)) %></span>
+        <%= dashboard_configuration.variation? ? format_variation(success_percentage) : trend_icon(success_percentage, :big => true) -%>
+      </p>
       <p>
-        <%= format_measure(Metric::TEST_FAILURES, :suffix => ' failures', :url => url_for_drilldown(Metric::TEST_FAILURES)) %> <%= trend_icon(measure(Metric::TEST_FAILURES)) %>
+        <%= format_measure(Metric::TEST_FAILURES, :suffix => ' failures', :url => url_for_drilldown(Metric::TEST_FAILURES)) %>
+        <%= dashboard_configuration.variation? ? format_variation(Metric::TEST_FAILURES) : trend_icon(Metric::TEST_FAILURES) -%>
       </p>
       <p>
-        <%= format_measure(Metric::TEST_ERRORS, :suffix => ' errors', :url => url_for_drilldown(Metric::TEST_ERRORS)) %> <%= trend_icon(measure(Metric::TEST_ERRORS)) %>
+        <%= format_measure(Metric::TEST_ERRORS, :suffix => ' errors', :url => url_for_drilldown(Metric::TEST_ERRORS)) %>
+        <%= dashboard_configuration.variation? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>
       </p>
   </div>
   <% end %>
index 53582cd0f27814a6a1825bd6ce73ffb0a6f47451..1edc9a936b54c9bb3c1c9b9b6862d05ff907b013 100644 (file)
@@ -1,35 +1,74 @@
-<% if measure(Metric::LINES) || measure(Metric::NCLOC) %>
+<%
+  if measure(Metric::LINES) || measure(Metric::NCLOC)
+    comment_lines=measure('comment_lines')
+    comment_lines_density=measure('comment_lines_density')
+    comment_blank_lines=measure('comment_blank_lines')
+    public_documented_api_density=measure('public_documented_api_density')
+    public_undocumented_api=measure('public_undocumented_api')
+    commented_out_lines=measure('commented_out_code_lines')
+    duplicated_lines_density=measure('duplicated_lines_density')
+    duplicated_lines=measure('duplicated_lines')
+    duplicated_blocks=measure('duplicated_blocks')
+    duplicated_files=measure('duplicated_files')
+%>
 <table width="100%">
        <tr>
                <td valign="top" width="50%" nowrap>
-                       <% if (measure(Metric::COMMENT_LINES)) %>
+                       <% if (comment_lines) %>
                    <div class="dashbox">
                      <h3>Comments</h3>
-                     <p><span class="big"><%= format_measure(Metric::COMMENT_LINES_DENSITY, :suffix => '', :url => url_for_drilldown(Metric::COMMENT_LINES_DENSITY)) -%> <%= trend_icon(Metric::COMMENT_LINES_DENSITY, :big => true) -%></span></p>
-                     <p><%= format_measure(Metric::COMMENT_LINES, :suffix => ' lines', :url => url_for_drilldown(Metric::COMMENT_LINES)) -%> <%= trend_icon(Metric::COMMENT_LINES) -%></p>
+                     <p>
+                       <span class="big"><%= format_measure(comment_lines_density, :suffix => '', :url => url_for_drilldown(comment_lines_density)) -%></span>
+                       <%= dashboard_configuration.variation? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density, :big => true) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(comment_lines, :suffix => ' lines', :url => url_for_drilldown(comment_lines)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(comment_lines) : trend_icon(comment_lines) -%>
+                     </p>
                      <%
-                     comment_blank_lines=measure('comment_blank_lines')
                      if comment_blank_lines && comment_blank_lines.value>0
                      %>
-                     <p>+<%= format_measure(comment_blank_lines, :suffix => ' blank', :url => url_for_drilldown(comment_blank_lines)) -%> <%= trend_icon(comment_blank_lines) -%></p>
+                     <p>+<%= format_measure(comment_blank_lines, :suffix => ' blank', :url => url_for_drilldown(comment_blank_lines)) -%>
+                     <%= dashboard_configuration.variation? ? format_variation(comment_blank_lines) : trend_icon(comment_blank_lines) -%>
+                     </p>
                      <% end %>
-                     <p><%= format_measure(Metric::PUBLIC_DOCUMENTED_API_DENSITY, :suffix => ' docu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) -%> <%= trend_icon(Metric::PUBLIC_DOCUMENTED_API_DENSITY) -%></p>
-                     <p><%= format_measure(Metric::PUBLIC_UNDOCUMENTED_API, :suffix => ' undocu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_UNDOCUMENTED_API)) -%> <%= trend_icon(Metric::PUBLIC_UNDOCUMENTED_API) -%></p>
-                     <p><%= format_measure(Metric::COMMENTED_OUT_CODE_LINES, :suffix => ' commented LOCs', :url => url_for_drilldown(Metric::COMMENTED_OUT_CODE_LINES, :highlight => Metric::COMMENTED_OUT_CODE_LINES)) -%> <%= trend_icon(Metric::COMMENTED_OUT_CODE_LINES) -%></p>
+                     <p>
+                       <%= format_measure(public_documented_api_density, :suffix => ' docu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(public_documented_api_density) : trend_icon(public_documented_api_density) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(public_undocumented_api, :suffix => ' undocu. API', :url => url_for_drilldown(public_undocumented_api)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(public_undocumented_api) : trend_icon(public_undocumented_api) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(commented_out_lines, :suffix => ' commented LOCs', :url => url_for_drilldown(commented_out_lines)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(commented_out_lines) : trend_icon(commented_out_lines) -%>
+                     </p>
                    </div>
                    <% end %>
                </td>
                <td valign="top" width="50%" nowrap>
-                   <% if (measure(Metric::DUPLICATED_LINES_DENSITY)) %>
+                   <% if duplicated_lines_density %>
                    <div class="dashbox">
                      <h3>Duplications</h3>
-                     <p><span class="big"><%= format_measure(Metric::DUPLICATED_LINES_DENSITY, :suffix => '', :url => url_for_drilldown(Metric::DUPLICATED_LINES, :highlight =>  Metric::DUPLICATED_LINES_DENSITY)) -%> <%= trend_icon(Metric::DUPLICATED_LINES_DENSITY, :big => true) -%></span></p>
-                     <p><%= format_measure(Metric::DUPLICATED_LINES, :suffix => ' lines', :url => url_for_drilldown(Metric::DUPLICATED_LINES)) -%> <%= trend_icon(Metric::DUPLICATED_LINES) -%></p>
-                     <p><%= format_measure(Metric::DUPLICATED_BLOCKS, :suffix => ' blocks', :url => url_for_drilldown(Metric::DUPLICATED_BLOCKS)) -%> <%= trend_icon(Metric::DUPLICATED_BLOCKS) -%></p>
-                     <p><%= format_measure(Metric::DUPLICATED_FILES, :suffix => ' files', :url => url_for_drilldown(Metric::DUPLICATED_FILES)) -%> <%= trend_icon(Metric::DUPLICATED_FILES) -%></p>
+                     <p>
+                       <span class="big"><%= format_measure(duplicated_lines_density, :suffix => '', :url => url_for_drilldown(Metric::DUPLICATED_LINES, :highlight =>  'duplicated_lines_density')) -%></span>
+                       <%= dashboard_configuration.variation? ? format_variation(duplicated_lines_density) : trend_icon(duplicated_lines_density, :big => true) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(duplicated_lines, :suffix => ' lines', :url => url_for_drilldown(duplicated_lines)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(duplicated_lines) : trend_icon(duplicated_lines) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(duplicated_blocks, :suffix => ' blocks', :url => url_for_drilldown(duplicated_blocks)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(duplicated_blocks) : trend_icon(duplicated_blocks) -%>
+                     </p>
+                     <p>
+                       <%= format_measure(duplicated_files, :suffix => ' files', :url => url_for_drilldown(duplicated_files)) -%>
+                       <%= dashboard_configuration.variation? ? format_variation(duplicated_files) : trend_icon(duplicated_files) -%>
+                     </p>
                    </div>
                    <% end %>
-
                </td>
        </tr>
 </table>
index df900e95bbb37b8775e1a2766dd726f2f475ad7c..c62b359b07eb842bea202cca6c85f1e117af7666 100644 (file)
@@ -16,27 +16,32 @@ complexity=measure('complexity')
          <h3>Complexity</h3>
          <% if function_complexity %>
            <p>
-             <span class="big"><%= format_measure(function_complexity, :suffix => '', :url => url_for_drilldown(function_complexity)) -%> <%= trend_icon(function_complexity, :big => true) -%></span>/ method
+             <span class="big"><%= format_measure(function_complexity, :suffix => '', :url => url_for_drilldown(function_complexity)) -%></span>/ method
+             <%= dashboard_configuration.variation? ? format_variation(function_complexity) : trend_icon(function_complexity, :big => true) -%>
            </p>
          <% end %>
          <% if paragraph_complexity %>
            <p>
-              <span class="big"><%= format_measure(paragraph_complexity, :suffix => '', :url => url_for_drilldown(paragraph_complexity)) -%> <%= trend_icon(paragraph_complexity, :big => true) -%></span>/ paragraph
+              <span class="big"><%= format_measure(paragraph_complexity, :suffix => '', :url => url_for_drilldown(paragraph_complexity)) -%></span>/ paragraph
+              <%= dashboard_configuration.variation? ? format_variation(paragraph_complexity) : trend_icon(paragraph_complexity, :big => true) -%>
            </p>
          <% end %>
          <% if class_complexity %>
            <p>
-             <span class="big"><%= format_measure(class_complexity, :suffix => '', :url => url_for_drilldown(class_complexity)) -%> <%= trend_icon(class_complexity, :big => true) -%></span>/ class
+             <span class="big"><%= format_measure(class_complexity, :suffix => '', :url => url_for_drilldown(class_complexity)) -%></span>/ class
+             <%= dashboard_configuration.variation? ? format_variation(class_complexity) : trend_icon(class_complexity, :big => true) -%>
            </p>
          <% end %>
          <% if file_complexity %>
            <p>
-              <span class="big"><%= format_measure(file_complexity, :suffix => '', :url => url_for_drilldown(file_complexity)) -%> <%= trend_icon(file_complexity, :big => true) -%></span>/ file
+              <span class="big"><%= format_measure(file_complexity, :suffix => '', :url => url_for_drilldown(file_complexity)) -%></span>/ file
+              <%= dashboard_configuration.variation? ? format_variation(file_complexity) : trend_icon(file_complexity, :big => true) -%>
            </p>
          <% end %>
          <% if complexity %>
          <p>
-           Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= trend_icon(complexity) -%>
+           Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%>
+           <%= dashboard_configuration.variation? ? format_variation(complexity) : trend_icon(complexity) -%>
          </p>
          <% end %>
         </div>
@@ -52,7 +57,7 @@ complexity=measure('complexity')
  if distributions.size>0
    selected_distribution=distributions.first
  end
- if selected_distribution && !dashboard_configuration.variation?
+ if selected_distribution
 %>
 <div class="dashbox" id="cmp_charts">
  <script type='text/javascript'>