mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-08-08 03:05:57 +02:00
SONAR-249 rename FILTERS.VARIATION_INDEX to FILTERS.PERIOD_INDEX + support variations in the resources web service + add IT
This commit is contained in:
parent
dfbfcb1f08
commit
9e75d602fc
@ -30,7 +30,7 @@ import java.util.Date;
|
||||
public class PastSnapshotFinder implements BatchExtension {
|
||||
|
||||
/**
|
||||
* IMPORTANT : please update default values in the ruby side too. See app/helpers/FiltersHelper.rb
|
||||
* IMPORTANT : please update default values in the ruby side too. See app/helpers/FiltersHelper.rb, method period_names()
|
||||
*/
|
||||
public static final String DEFAULT_VALUE_1 = PastSnapshotFinderByPreviousAnalysis.MODE;
|
||||
public static final String DEFAULT_VALUE_2 = "5";
|
||||
|
@ -13,37 +13,37 @@
|
||||
<p class="title">Code coverage</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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure) -%>
|
||||
</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)) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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)) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown(Metric::TESTS)) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(tests_measure) : trend_icon(tests_measure) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(tests_measure) : trend_icon(tests_measure) -%>
|
||||
</p>
|
||||
<% skipped_measure=measure(Metric::SKIPPED_TESTS)
|
||||
if skipped_measure
|
||||
%>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(execution_time) : trend_icon(execution_time) -%>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -55,15 +55,15 @@
|
||||
<h3>Test success</h3>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(success_percentage) : trend_icon(success_percentage) -%>
|
||||
</p>
|
||||
<p>
|
||||
<%= 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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)) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -19,30 +19,30 @@
|
||||
<h3>Comments</h3>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density) -%>
|
||||
</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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(comment_lines) : trend_icon(comment_lines) -%>
|
||||
</p>
|
||||
<%
|
||||
if comment_blank_lines && comment_blank_lines.value>0
|
||||
%>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(comment_blank_lines) : trend_icon(comment_blank_lines) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(commented_out_lines) : trend_icon(commented_out_lines) -%>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
@ -53,19 +53,19 @@
|
||||
<h3>Duplications</h3>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(duplicated_lines_density) : trend_icon(duplicated_lines_density) -%>
|
||||
</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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(duplicated_files) : trend_icon(duplicated_files) -%>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -17,30 +17,30 @@ complexity=measure('complexity')
|
||||
<% if function_complexity %>
|
||||
<p>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(function_complexity) : trend_icon(function_complexity) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if paragraph_complexity %>
|
||||
<p>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(paragraph_complexity) : trend_icon(paragraph_complexity) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if class_complexity %>
|
||||
<p>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(class_complexity) : trend_icon(class_complexity) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if file_complexity %>
|
||||
<p>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(file_complexity) : trend_icon(file_complexity) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if complexity %>
|
||||
<p>
|
||||
Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= dashboard_configuration.variation? ? format_variation(complexity) : trend_icon(complexity) -%>
|
||||
Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= dashboard_configuration.selected_period? ? format_variation(complexity) : trend_icon(complexity) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -16,22 +16,22 @@
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(violations) : trend_icon(violations) -%>
|
||||
</div>
|
||||
<h3>Rules compliance</h3>
|
||||
<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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(density) : trend_icon(density) -%>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td valign="top" nowrap>
|
||||
<%
|
||||
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}
|
||||
if dashboard_configuration.selected_period?
|
||||
values=values.map{|m| m ? (m.variation(dashboard_configuration.period_index)||0) : 0}
|
||||
else
|
||||
values=values.map{|m| m ? (m.value||0) : 0}
|
||||
end
|
||||
@ -45,11 +45,11 @@
|
||||
<%= format_measure(blocker_violations) -%>
|
||||
</td>
|
||||
<td>
|
||||
<%= dashboard_configuration.variation? ? format_variation(blocker_violations) : trend_icon(blocker_violations, :empty => true) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(blocker_violations) : trend_icon(blocker_violations, :empty => true) -%>
|
||||
</td>
|
||||
<td align="left" style="padding-bottom:2px; padding-top:2px;">
|
||||
<% if max > 0 %>
|
||||
<% if dashboard_configuration.variation? %>
|
||||
<% if dashboard_configuration.selected_period? %>
|
||||
<%= 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 %>
|
||||
@ -65,11 +65,11 @@
|
||||
<%= format_measure(critical_violations) -%>
|
||||
</td>
|
||||
<td>
|
||||
<%= dashboard_configuration.variation? ? format_variation(critical_violations) : trend_icon(critical_violations, :empty => true) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(critical_violations) : trend_icon(critical_violations, :empty => true) -%>
|
||||
</td>
|
||||
<td align="left" style="padding-bottom:2px; padding-top:2px;">
|
||||
<% if max > 0 %>
|
||||
<% if dashboard_configuration.variation? %>
|
||||
<% if dashboard_configuration.selected_period? %>
|
||||
<%= 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 %>
|
||||
@ -85,11 +85,11 @@
|
||||
<%= format_measure(major_violations) -%>
|
||||
</td>
|
||||
<td>
|
||||
<%= dashboard_configuration.variation? ? format_variation(major_violations) : trend_icon(major_violations, :empty => true) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(major_violations) : trend_icon(major_violations, :empty => true) -%>
|
||||
</td>
|
||||
<td align="left" style="padding-bottom:2px; padding-top:2px;">
|
||||
<% if max > 0 %>
|
||||
<% if dashboard_configuration.variation? %>
|
||||
<% if dashboard_configuration.selected_period? %>
|
||||
<%= 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 %>
|
||||
@ -105,11 +105,11 @@
|
||||
<%= format_measure(minor_violations) -%>
|
||||
</td>
|
||||
<td>
|
||||
<%= dashboard_configuration.variation? ? format_variation(minor_violations) : trend_icon(minor_violations, :empty => true) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(minor_violations) : trend_icon(minor_violations, :empty => true) -%>
|
||||
</td>
|
||||
<td align="left" style="padding-bottom:2px; padding-top:2px;">
|
||||
<% if max > 0 %>
|
||||
<% if dashboard_configuration.variation? %>
|
||||
<% if dashboard_configuration.selected_period? %>
|
||||
<%= 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 %>
|
||||
@ -125,11 +125,11 @@
|
||||
<%= format_measure(info_violations) -%>
|
||||
</td>
|
||||
<td>
|
||||
<%= dashboard_configuration.variation? ? format_variation(info_violations) : trend_icon(info_violations, :empty => true) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(info_violations) : trend_icon(info_violations, :empty => true) -%>
|
||||
</td>
|
||||
<td align="left" style="padding-bottom:2px; padding-top:2px;">
|
||||
<% if max > 0 %>
|
||||
<% if dashboard_configuration.variation? %>
|
||||
<% if dashboard_configuration.selected_period? %>
|
||||
<%= 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 %>
|
||||
|
@ -17,15 +17,15 @@
|
||||
<% 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) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(ncloc) : trend_icon(ncloc) -%>
|
||||
</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)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%></p>
|
||||
<p>+<%= format_measure(generated_ncloc, :suffix => ' generated', :url => url_for_drilldown(generated_ncloc)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%></p>
|
||||
<% end %>
|
||||
<p><%= format_measure(lines, :suffix => ' lines', :url => url_for_drilldown(lines)) -%> <%= dashboard_configuration.variation? ? format_variation(lines) : trend_icon(lines) -%></p>
|
||||
<p><%= format_measure(lines, :suffix => ' lines', :url => url_for_drilldown(lines)) -%> <%= dashboard_configuration.selected_period? ? format_variation(lines) : trend_icon(lines) -%></p>
|
||||
<% else%>
|
||||
<p><span class="big"><%= format_measure(lines, :suffix => '', :url => url_for_drilldown(lines)) -%> <%= trend_icon(lines) -%></span></p>
|
||||
<% end %>
|
||||
@ -33,15 +33,15 @@
|
||||
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)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_lines) : trend_icon(generated_lines) -%></p>
|
||||
<p>incl. <%= format_measure(generated_lines, :suffix => ' generated', :url => url_for_drilldown(generated_lines)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_lines) : trend_icon(generated_lines) -%></p>
|
||||
<% end %>
|
||||
<% if statements %>
|
||||
<p>
|
||||
<%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= dashboard_configuration.variation? ? format_variation(statements) : trend_icon(statements) -%>
|
||||
<%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= dashboard_configuration.selected_period? ? format_variation(statements) : trend_icon(statements) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if files && measure('classes') %>
|
||||
<p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files) -%></p>
|
||||
<p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= dashboard_configuration.selected_period? ? format_variation(files) : trend_icon(files) -%></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
@ -52,25 +52,25 @@
|
||||
<h3>Classes</h3>
|
||||
<p>
|
||||
<span class="big"><%= format_measure(classes, :url => url_for_drilldown(classes)) -%></span>
|
||||
<%= dashboard_configuration.variation? ? format_variation(classes) : trend_icon(classes) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(classes) : trend_icon(classes) -%>
|
||||
</p>
|
||||
<p><%= format_measure(packages, :suffix => ' packages', :url => url_for_drilldown(packages)) -%> <%= dashboard_configuration.variation? ? format_variation(packages) : trend_icon(packages) -%></p>
|
||||
<p><%= format_measure(packages, :suffix => ' packages', :url => url_for_drilldown(packages)) -%> <%= dashboard_configuration.selected_period? ? format_variation(packages) : trend_icon(packages) -%></p>
|
||||
<% else %>
|
||||
<h3>Files</h3>
|
||||
<p><span class="big"><%= format_measure(files, :url => url_for_drilldown(files)) -%></span>
|
||||
<%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(files) : trend_icon(files) -%>
|
||||
</p>
|
||||
<p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= dashboard_configuration.variation? ? format_variation('directories') : trend_icon('directories') -%></p>
|
||||
<p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= dashboard_configuration.selected_period? ? format_variation('directories') : trend_icon('directories') -%></p>
|
||||
<% end %>
|
||||
<p><%= format_measure(functions, :suffix => ' methods', :url => url_for_drilldown(functions)) -%> <%= dashboard_configuration.variation? ? format_variation(functions) : trend_icon(functions) -%></p>
|
||||
<p><%= format_measure(functions, :suffix => ' methods', :url => url_for_drilldown(functions)) -%> <%= dashboard_configuration.selected_period? ? format_variation(functions) : trend_icon(functions) -%></p>
|
||||
<%
|
||||
if (measure('accessors'))
|
||||
prefix=(dashboard_configuration.variation? ? '' : '+')
|
||||
prefix=(dashboard_configuration.selected_period? ? '' : '+')
|
||||
%>
|
||||
<p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= dashboard_configuration.variation? ? format_variation('accessors') : trend_icon('accessors') -%></p>
|
||||
<p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= dashboard_configuration.selected_period? ? format_variation('accessors') : trend_icon('accessors') -%></p>
|
||||
<% end %>
|
||||
<% if measure('paragraphs') %>
|
||||
<p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= dashboard_configuration.variation? ? format_variation('paragraphs') : trend_icon('paragraphs') -%></p>
|
||||
<p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= dashboard_configuration.selected_period? ? format_variation('paragraphs') : trend_icon('paragraphs') -%></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -14,10 +14,10 @@ if lcom || rfc
|
||||
<div class="dashbox">
|
||||
<h3>LCOM4</h3>
|
||||
<p>
|
||||
<span class="big"><%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%></span> /class <%= dashboard_configuration.variation? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%>
|
||||
<span class="big"><%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%></span> /class <%= dashboard_configuration.selected_period? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%>
|
||||
</p>
|
||||
<p>
|
||||
<%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.variation? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%>
|
||||
<%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.selected_period? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -27,7 +27,7 @@ if lcom || rfc
|
||||
<div class="dashbox">
|
||||
<h3>RFC</h3>
|
||||
<p><span class="big">
|
||||
<%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%></span> /class <%= dashboard_configuration.variation? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%>
|
||||
<%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%></span> /class <%= dashboard_configuration.selected_period? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -11,11 +11,11 @@
|
||||
<div class="dashbox">
|
||||
<p class="title">File tangle index</p>
|
||||
<p>
|
||||
<span class="big"><%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%></span> <%= dashboard_configuration.variation? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>
|
||||
<span class="big"><%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>
|
||||
</p>
|
||||
<% if file_cycles %>
|
||||
<p>
|
||||
> <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>
|
||||
> <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -25,7 +25,7 @@
|
||||
<div class="dashbox">
|
||||
<p class="title">Suspect file dependencies</p>
|
||||
<p>
|
||||
<span class="big"><%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%></span> <%= dashboard_configuration.variation? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>
|
||||
<span class="big"><%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -15,11 +15,11 @@
|
||||
<div class="dashbox">
|
||||
<p class="title">Package tangle index</p>
|
||||
<p>
|
||||
<span class="big"><%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%></span> <%= dashboard_configuration.variation? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%>
|
||||
<span class="big"><%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%>
|
||||
</p>
|
||||
<% if package_cycles %>
|
||||
<p>
|
||||
> <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>
|
||||
> <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -30,11 +30,11 @@
|
||||
<p class="title">Dependencies to cut</p>
|
||||
<p>
|
||||
<%= format_measure(package_feedback_edges, :suffix => ' between packages', :url => url_for_drilldown('package_feedback_edges')) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>
|
||||
</p>
|
||||
<p>
|
||||
<%= format_measure(package_tangles, :suffix => ' between files', :url => url_for_drilldown('package_tangles')) %>
|
||||
<%= dashboard_configuration.variation? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>
|
||||
<%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
5
pom.xml
5
pom.xml
@ -154,6 +154,11 @@
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
|
@ -350,9 +350,16 @@ class Api::ResourcesController < Api::ApiController
|
||||
json_measure[:alert]=measure.alert_status
|
||||
json_measure[:alert_text]=measure.alert_text
|
||||
end
|
||||
if include_trends && measure.tendency
|
||||
json_measure[:trend]=measure.tendency_qualitative
|
||||
json_measure[:var]=measure.tendency
|
||||
if include_trends
|
||||
if measure.tendency
|
||||
json_measure[:trend]=measure.tendency_qualitative
|
||||
json_measure[:var]=measure.tendency
|
||||
end
|
||||
json_measure[:var1]=measure.variation_value_1.to_f if measure.variation_value_1
|
||||
json_measure[:var2]=measure.variation_value_2.to_f if measure.variation_value_2
|
||||
json_measure[:var3]=measure.variation_value_3.to_f if measure.variation_value_3
|
||||
json_measure[:var4]=measure.variation_value_4.to_f if measure.variation_value_4
|
||||
json_measure[:var5]=measure.variation_value_5.to_f if measure.variation_value_5
|
||||
end
|
||||
if measure.rule_id
|
||||
rule = rules_by_id[measure.rule_id]
|
||||
@ -391,6 +398,29 @@ class Api::ResourcesController < Api::ApiController
|
||||
xml.date(format_datetime(snapshot.created_at))
|
||||
xml.description(resource.description) if include_descriptions && resource.description
|
||||
xml.copy(resource.copy_resource_id) if resource.copy_resource_id
|
||||
|
||||
if include_trends
|
||||
xml.period1(snapshot.period1_mode) if snapshot.period1_mode
|
||||
xml.period1_param(snapshot.period1_param) if snapshot.period1_param
|
||||
xml.period1_date(format_datetime(snapshot.period1_date)) if snapshot.period1_date
|
||||
|
||||
xml.period2(snapshot.period2_mode) if snapshot.period2_mode
|
||||
xml.period2_param(snapshot.period2_param) if snapshot.period2_param
|
||||
xml.period2_date(format_datetime(snapshot.period2_date)) if snapshot.period2_date
|
||||
|
||||
xml.period3(snapshot.period3_mode) if snapshot.period3_mode
|
||||
xml.period3_param(snapshot.period3_param) if snapshot.period3_param
|
||||
xml.period3_date(format_datetime(snapshot.period3_date)) if snapshot.period3_date
|
||||
|
||||
xml.period4(snapshot.period4_mode) if snapshot.period4_mode
|
||||
xml.period4_param(snapshot.period4_param) if snapshot.period4_param
|
||||
xml.period4_date(format_datetime(snapshot.period4_date)) if snapshot.period4_date
|
||||
|
||||
xml.period5(snapshot.period5_mode) if snapshot.period5_mode
|
||||
xml.period5_param(snapshot.period5_param) if snapshot.period5_param
|
||||
xml.period5_date(format_datetime(snapshot.period5_date)) if snapshot.period5_date
|
||||
end
|
||||
|
||||
if measures
|
||||
measures.each do |measure|
|
||||
xml.msr do
|
||||
@ -405,9 +435,16 @@ class Api::ResourcesController < Api::ApiController
|
||||
xml.alert(measure.alert_status) if measure.alert_status
|
||||
xml.alert_text(measure.alert_text) if measure.alert_text
|
||||
end
|
||||
if include_trends && measure.tendency
|
||||
xml.trend(measure.tendency_qualitative)
|
||||
xml.var(measure.tendency)
|
||||
if include_trends
|
||||
if measure.tendency
|
||||
xml.trend(measure.tendency_qualitative)
|
||||
xml.var(measure.tendency)
|
||||
end
|
||||
xml.var1(measure.variation_value_1.to_f) if measure.variation_value_1
|
||||
xml.var2(measure.variation_value_2.to_f) if measure.variation_value_2
|
||||
xml.var3(measure.variation_value_3.to_f) if measure.variation_value_3
|
||||
xml.var4(measure.variation_value_4.to_f) if measure.variation_value_4
|
||||
xml.var5(measure.variation_value_5.to_f) if measure.variation_value_5
|
||||
end
|
||||
if measure.rule_id
|
||||
rule = rules_by_id[measure.rule_id]
|
||||
|
@ -169,7 +169,7 @@ class DashboardController < ApplicationController
|
||||
end
|
||||
end
|
||||
@dashboard=(@active ? @active.dashboard : nil)
|
||||
@dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :variation_index => params[:var])
|
||||
@dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period])
|
||||
end
|
||||
|
||||
def load_resource
|
||||
|
@ -65,11 +65,11 @@ class DrilldownController < ApplicationController
|
||||
@rule=Rule.by_key_or_id(params[:rule])
|
||||
|
||||
# variation measures
|
||||
if params[:var].blank?
|
||||
@variation_index=nil
|
||||
if params[:period].blank?
|
||||
@period_index=nil
|
||||
metric_prefix = ''
|
||||
else
|
||||
@variation_index=params[:var].to_i
|
||||
@period_index=params[:period].to_i
|
||||
metric_prefix = 'new_'
|
||||
end
|
||||
|
||||
@ -93,7 +93,7 @@ class DrilldownController < ApplicationController
|
||||
|
||||
|
||||
# options for Drilldown
|
||||
options={:exclude_zero_value => true, :variation_index => @variation_index}
|
||||
options={:exclude_zero_value => true, :period_index => @period_index}
|
||||
if @rule
|
||||
params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id
|
||||
options[:rule_id]=@rule.id
|
||||
|
@ -51,8 +51,8 @@ class FiltersController < ApplicationController
|
||||
load_filter_from_params(@filter, params)
|
||||
|
||||
@filter.columns.build(:family => 'name', :order_index => 1, :sort_direction => 'ASC')
|
||||
@filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.default_period?)
|
||||
@filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.default_period?)
|
||||
@filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.period?)
|
||||
@filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.period?)
|
||||
@filter.columns.build(:family => 'date', :order_index => 4)
|
||||
|
||||
column_index=0
|
||||
@ -408,7 +408,7 @@ class FiltersController < ApplicationController
|
||||
@width=(params[:width]||'800').to_i
|
||||
@height=(params[:height]||'500').to_i
|
||||
|
||||
treemap_options={:variation_index => @filter_context.variation_index}
|
||||
treemap_options={:period_index => @filter_context.period_index}
|
||||
@treemap=Sonar::Treemap.new(@filter_context.measures_by_snapshot, @width, @height, @size_metric, @color_metric, treemap_options)
|
||||
render :action => "treemap", :layout => false
|
||||
end
|
||||
@ -428,7 +428,7 @@ class FiltersController < ApplicationController
|
||||
filter.favourites=params[:favourites].present?
|
||||
filter.resource_id=(params[:path_id].present? ? Project.by_key(params[:path_id]).id : nil)
|
||||
filter.user_id=current_user.id
|
||||
filter.variation_index=params[:variation_index].to_i
|
||||
filter.period_index=params[:period_index].to_i
|
||||
filter.criteria=[]
|
||||
filter.criteria<<Criterion.new_for_qualifiers(params['qualifiers'])
|
||||
filter.criteria<<Criterion.new(:family => 'date', :operator => params['date_operator'], :value => params['date_value']) if params['date_operator'].present?
|
||||
@ -484,7 +484,7 @@ class FiltersController < ApplicationController
|
||||
end
|
||||
|
||||
@filter=nil
|
||||
@variation_index=params[:var].to_i
|
||||
@period_index=params[:period].to_i
|
||||
if @active
|
||||
@filter=@active.filter
|
||||
unless @filter.ajax_loading?
|
||||
|
@ -440,8 +440,8 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
index=options[:index]
|
||||
if index.nil? && defined?(@dashboard_configuration) && @dashboard_configuration.variation?
|
||||
index = @dashboard_configuration.variation_index
|
||||
if index.nil? && defined?(@dashboard_configuration) && @dashboard_configuration.selected_period?
|
||||
index = @dashboard_configuration.period_index
|
||||
end
|
||||
|
||||
m.variation(index)
|
||||
|
@ -28,7 +28,7 @@ module DashboardHelper
|
||||
@snapshot.measure(metric_key)
|
||||
end
|
||||
|
||||
def variation_select_option(snapshot, index)
|
||||
def period_select_options(snapshot, index)
|
||||
return nil if snapshot.nil? || snapshot.project_snapshot.nil?
|
||||
mode=snapshot.project_snapshot.send "period#{index}_mode"
|
||||
mode_param=snapshot.project_snapshot.send "period#{index}_param"
|
||||
@ -44,7 +44,7 @@ module DashboardHelper
|
||||
label = "Compare to #{localize(Date.parse(mode_param))}"
|
||||
end
|
||||
if label
|
||||
selected=(params[:var]==index.to_s ? 'selected' : '')
|
||||
selected=(params[:period]==index.to_s ? 'selected' : '')
|
||||
"<option value='#{index}' #{selected}>#{label}</option>"
|
||||
end
|
||||
else
|
||||
|
@ -19,7 +19,7 @@
|
||||
#
|
||||
module DrilldownHelper
|
||||
|
||||
def variation_select_option(snapshot, index)
|
||||
def period_select_options(snapshot, index)
|
||||
return nil if snapshot.nil? || snapshot.project_snapshot.nil?
|
||||
mode=snapshot.project_snapshot.send "period#{index}_mode"
|
||||
mode_param=snapshot.project_snapshot.send "period#{index}_param"
|
||||
@ -35,7 +35,7 @@ module DrilldownHelper
|
||||
label = "New violations since #{localize(Date.parse(mode_param))}"
|
||||
end
|
||||
if label
|
||||
selected=(params[:var]==index.to_s ? 'selected' : '')
|
||||
selected=(params[:period]==index.to_s ? 'selected' : '')
|
||||
"<option value='#{index}' #{selected}>#{label}</option>"
|
||||
end
|
||||
else
|
||||
@ -46,7 +46,7 @@ module DrilldownHelper
|
||||
|
||||
def measure_or_variation_value(measure)
|
||||
if measure
|
||||
@variation_index ? measure.variation(@variation_index) : measure.value
|
||||
@period_index ? measure.variation(@period_index) : measure.value
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
@ -98,7 +98,7 @@ module FiltersHelper
|
||||
|
||||
|
||||
#----- VARIATION
|
||||
java_filter.setSortedVariationIndex(filter_context.variation_index)
|
||||
java_filter.setSortedVariationIndex(filter_context.period_index)
|
||||
|
||||
#----- EXECUTION
|
||||
java_result=java_facade.execute_filter(java_filter)
|
||||
@ -160,9 +160,9 @@ module FiltersHelper
|
||||
end
|
||||
|
||||
def period_names
|
||||
p1=Property.value('sonar.timemachine.variation1', nil, 'previous_analysis')
|
||||
p2=Property.value('sonar.timemachine.variation2', nil, '5')
|
||||
p3=Property.value('sonar.timemachine.variation3', nil, '30')
|
||||
p1=Property.value('sonar.timemachine.period1', nil, 'previous_analysis')
|
||||
p2=Property.value('sonar.timemachine.period2', nil, '5')
|
||||
p3=Property.value('sonar.timemachine.period3', nil, '30')
|
||||
[period_name(p1), period_name(p2), period_name(p3)]
|
||||
end
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
#
|
||||
class Api::DashboardConfiguration
|
||||
|
||||
attr_accessor :dashboard, :variation_index, :variation
|
||||
attr_accessor :dashboard, :period_index, :selected_period
|
||||
|
||||
def initialize(dashboard, options={})
|
||||
@dashboard=dashboard
|
||||
@variation_index=options[:variation_index].to_i
|
||||
@variation=(@variation_index>0)
|
||||
@period_index=options[:period_index].to_i
|
||||
@selected_period=(@period_index>0)
|
||||
end
|
||||
|
||||
def name
|
||||
@ -43,8 +43,8 @@ class Api::DashboardConfiguration
|
||||
@dashboard.number_of_columns
|
||||
end
|
||||
|
||||
def variation?
|
||||
@variation
|
||||
def selected_period?
|
||||
@selected_period
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -45,7 +45,7 @@ class DrilldownColumn
|
||||
@scope=scope
|
||||
@snapshot = snapshot
|
||||
|
||||
value_column = (options[:variation_index] ? "variation_value_#{options[:variation_index]}" : 'value')
|
||||
value_column = (options[:period_index] ? "variation_value_#{options[:period_index]}" : 'value')
|
||||
order="project_measures.#{value_column}"
|
||||
if metric.direction<0
|
||||
order += ' DESC'
|
||||
|
@ -125,20 +125,20 @@ class Filter < ActiveRecord::Base
|
||||
def advanced_search?
|
||||
@advanced_search ||=
|
||||
begin
|
||||
!(criterion('language').nil?) || favourites || !(criterion('name').nil?) || !(criterion('key').nil?) || !(criterion('date').nil?) || default_period?
|
||||
!(criterion('language').nil?) || favourites || !(criterion('name').nil?) || !(criterion('key').nil?) || !(criterion('date').nil?) || period?
|
||||
end
|
||||
end
|
||||
|
||||
def variation_index=(vi)
|
||||
def period_index=(vi)
|
||||
if vi && vi>0
|
||||
write_attribute(:variation_index, vi)
|
||||
write_attribute(:period_index, vi)
|
||||
else
|
||||
write_attribute(:variation_index, nil)
|
||||
write_attribute(:period_index, nil)
|
||||
end
|
||||
end
|
||||
|
||||
def default_period?
|
||||
variation_index && variation_index>0
|
||||
def period?
|
||||
period_index && period_index>0
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -18,7 +18,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
|
||||
#
|
||||
class FilterContext
|
||||
attr_accessor :filter, :page_size, :page_id, :security_exclusions, :variation_index, :user, :sorted_column_id, :ascending_sort
|
||||
attr_accessor :filter, :page_size, :page_id, :security_exclusions, :period_index, :user, :sorted_column_id, :ascending_sort
|
||||
|
||||
def initialize(filter, options={})
|
||||
@filter = filter
|
||||
@ -27,7 +27,7 @@
|
||||
@sorted_column_id=(options[:sort].blank? ? nil : options[:sort].to_i)
|
||||
@ascending_sort=(options[:asc].blank? ? nil : options[:asc]=='true')
|
||||
@user=options[:user]
|
||||
@variation_index = (options[:var] ? options[:var].to_i : @filter.variation_index )
|
||||
@period_index = (options[:period] ? options[:period].to_i : @filter.period_index )
|
||||
@metric_ids=(options[:metric_ids] || @filter.columns.map{|col| col.metric ? col.metric.id : nil}.compact.uniq)
|
||||
end
|
||||
|
||||
@ -132,8 +132,8 @@
|
||||
@security_exclusions==true
|
||||
end
|
||||
|
||||
def variation?
|
||||
@variation_index && @variation_index>0
|
||||
def selected_period?
|
||||
@period_index && @period_index>0
|
||||
end
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ class MeasureColor
|
||||
# Options :
|
||||
# * min : min value, else the metric worst_value
|
||||
# * max : max value, else the metric best_value
|
||||
# * variation_index: integer between 1 and 5 if set, else nil
|
||||
# * period_index: integer between 1 and 5 if set, else nil
|
||||
# * check_alert_status: true|false. Default is true.
|
||||
#
|
||||
def self.color(measure, options={})
|
||||
@ -38,9 +38,9 @@ class MeasureColor
|
||||
min_value = options[:min] || measure.metric.worst_value
|
||||
percent=-1.0
|
||||
|
||||
if options[:variation_index]
|
||||
if options[:period_index]
|
||||
if min_value && max_value
|
||||
value=measure.variation(options[:variation_index])
|
||||
value=measure.variation(options[:period_index])
|
||||
percent = value_to_percent(value, min_value, max_value)
|
||||
end
|
||||
else
|
||||
|
@ -110,9 +110,9 @@ class ProjectMeasure < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def variation(variation_index)
|
||||
def variation(period_index)
|
||||
result = nil
|
||||
case variation_index
|
||||
case period_index
|
||||
when 1
|
||||
result=variation_value_1
|
||||
when 2
|
||||
|
@ -29,8 +29,8 @@ class Sonar::Treemap
|
||||
@width = width
|
||||
@height = height
|
||||
|
||||
if options[:variation_index] && options[:variation_index]>0
|
||||
@variation_index = options[:variation_index]
|
||||
if options[:period_index] && options[:period_index]>0
|
||||
@period_index = options[:period_index]
|
||||
end
|
||||
end
|
||||
|
||||
@ -91,8 +91,8 @@ class Sonar::Treemap
|
||||
end
|
||||
|
||||
def size_value(measure)
|
||||
if @variation_index
|
||||
var=measure.variation(@variation_index)
|
||||
if @period_index
|
||||
var=measure.variation(@period_index)
|
||||
var ? var.to_f.abs : 0.0
|
||||
elsif measure.value
|
||||
measure.value.to_f.abs||0.0
|
||||
|
@ -16,28 +16,21 @@
|
||||
<% if @snapshot %>
|
||||
<div id="snapshot_title" class="page_title">
|
||||
<h4>
|
||||
<%
|
||||
profile_measure=@snapshot.measure(Metric::PROFILE)
|
||||
%>
|
||||
<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
|
||||
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
|
||||
<% if @snapshot.project_snapshot.periods? %>
|
||||
-
|
||||
<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
|
||||
<select id="select-comparison" name="var" onchange="submit()" class="small">
|
||||
<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
|
||||
<select id="select-comparison" name="period" onchange="submit()" class="small">
|
||||
<option value="">Display trends</option>
|
||||
<%= variation_select_option(@snapshot, 1) -%>
|
||||
<%= variation_select_option(@snapshot, 2) -%>
|
||||
<%= variation_select_option(@snapshot, 3) -%>
|
||||
<%= variation_select_option(@snapshot, 4) -%>
|
||||
<%= variation_select_option(@snapshot, 5) -%>
|
||||
<%= period_select_options(@snapshot, 1) -%>
|
||||
<%= period_select_options(@snapshot, 2) -%>
|
||||
<%= period_select_options(@snapshot, 3) -%>
|
||||
<%= period_select_options(@snapshot, 4) -%>
|
||||
<%= period_select_options(@snapshot, 5) -%>
|
||||
</select>
|
||||
</form>
|
||||
<% end %>
|
||||
</h4>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
@ -1,8 +1,8 @@
|
||||
<tr class="<%= css -%> <%= 'selected' if Sonar::RulePriority.to_s(priority_id)==params[:priority] -%>">
|
||||
<td><%= image_tag "priority/#{priority_id}.png" %></td>
|
||||
<td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :var => @variation_index} %></td>
|
||||
<td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period_index} %></td>
|
||||
<td style="padding-left: 10px;" align="right">
|
||||
<%= @variation_index ? format_variation(measure, :index => @variation_index) : format_measure(measure) -%>
|
||||
<%= @period_index ? format_variation(measure, :index => @period_index) : format_measure(measure) -%>
|
||||
</td>
|
||||
<td align="left">
|
||||
<% value = measure_or_variation_value(measure) %>
|
||||
|
@ -6,14 +6,14 @@
|
||||
<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
|
||||
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
|
||||
<% if @snapshot.project_snapshot.periods? %>
|
||||
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
|
||||
<select id="select-comparison" name="var" onchange="submit()" class="small">
|
||||
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
|
||||
<select id="select-comparison" name="period" onchange="submit()" class="small">
|
||||
<option value="">All violations</option>
|
||||
<%= variation_select_option(@snapshot, 1) -%>
|
||||
<%= variation_select_option(@snapshot, 2) -%>
|
||||
<%= variation_select_option(@snapshot, 3) -%>
|
||||
<%= variation_select_option(@snapshot, 4) -%>
|
||||
<%= variation_select_option(@snapshot, 5) -%>
|
||||
<%= period_select_options(@snapshot, 1) -%>
|
||||
<%= period_select_options(@snapshot, 2) -%>
|
||||
<%= period_select_options(@snapshot, 3) -%>
|
||||
<%= period_select_options(@snapshot, 4) -%>
|
||||
<%= period_select_options(@snapshot, 5) -%>
|
||||
</select>
|
||||
</form>
|
||||
<% end %>
|
||||
@ -28,9 +28,9 @@
|
||||
<td align="left" width="1%" nowrap class="column first">
|
||||
|
||||
<%
|
||||
value_column = (@variation_index ? "variation_value_#{@variation_index}" : 'value')
|
||||
value_column = (@period_index ? "variation_value_#{@period_index}" : 'value')
|
||||
max = 0
|
||||
if @variation_index
|
||||
if @period_index
|
||||
blocker_violations=@snapshot.measure('new_blocker_violations')
|
||||
critical_violations=@snapshot.measure('new_critical_violations')
|
||||
major_violations=@snapshot.measure('new_major_violations')
|
||||
@ -63,7 +63,7 @@
|
||||
<div class="scrollable">
|
||||
<table class="spacedicon" width="100%" id="col_rules">
|
||||
<%
|
||||
if @variation_index
|
||||
if @period_index
|
||||
rule_measures=@snapshot.rule_measures(Metric.by_key('new_violations'), @priority_id)
|
||||
else
|
||||
rule_measures=@snapshot.rule_measures(Metric.by_key('violations'), @priority_id)
|
||||
@ -103,7 +103,7 @@
|
||||
<%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %>
|
||||
</td>
|
||||
<td class="right" nowrap="nowrap">
|
||||
<span><%= @variation_index ? format_variation(rule_measure, :index => @variation_index) : rule_measure.formatted_value -%></span>
|
||||
<span><%= @period_index ? format_variation(rule_measure, :index => @period_index) : rule_measure.formatted_value -%></span>
|
||||
</td>
|
||||
<td class="left last">
|
||||
<%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => '#777') if max>0 %>
|
||||
@ -158,7 +158,7 @@
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="right last" nowrap>
|
||||
<%= @variation_index ? format_variation(measure, :index => @variation_index) : measure.formatted_value -%>
|
||||
<%= @period_index ? format_variation(measure, :index => @period_index) : measure.formatted_value -%>
|
||||
<!--[if IE]> <![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<% filter=@filter_context.filter %>
|
||||
<div>
|
||||
Period:
|
||||
<form action="<%= url_for :overwrite_params => {:var => nil} -%>" style="display: inline" method="get">
|
||||
<select name="var" onchange="submit()" class="small">
|
||||
<form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get">
|
||||
<select name="period" onchange="submit()" class="small">
|
||||
<option value="">None</option>
|
||||
<% period_names.each_with_index do |name, index| %>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if @filter_context.variation_index==index+1 -%>><%= name -%></value>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value>
|
||||
<% end %>
|
||||
</select>
|
||||
</form>
|
||||
@ -84,11 +84,11 @@ Period:
|
||||
measure = @filter_context.measure(snapshot, column.metric)
|
||||
%>
|
||||
<% if column.variation %>
|
||||
<%= format_variation(measure, :index => @filter_context.variation_index) -%>
|
||||
<%= format_variation(measure, :index => @filter_context.period_index) -%>
|
||||
<% else %>
|
||||
<%= format_measure(measure) -%>
|
||||
<% if @filter_context.variation? %>
|
||||
<%= format_variation(measure, :index => @filter_context.variation_index) -%>
|
||||
<% if @filter_context.selected_period? %>
|
||||
<%= format_variation(measure, :index => @filter_context.period_index) -%>
|
||||
<% else %>
|
||||
<%= trend_icon(measure, :empty => true) -%>
|
||||
<% end %>
|
||||
|
@ -10,12 +10,12 @@ color_metric=metrics[1]
|
||||
<script>
|
||||
var treemap_width = $('treemap').getDimensions().width - 15;
|
||||
var treemap_height = document.viewport.getDimensions().height - 220;
|
||||
function load_treemap(size_metric, color_metric, hide_form, variation_index) {
|
||||
function load_treemap(size_metric, color_metric, hide_form, period_index) {
|
||||
$('treemap_loading').show();
|
||||
$('treemap').hide();
|
||||
<%= remote_function :update => 'treemap', :url => {:action => 'treemap', :id => @filter.id, :show_periods => true},
|
||||
:complete => "$('treemap_loading').hide();$('treemap').show();",
|
||||
:with => "'width=' + treemap_width + '&height=' + treemap_height + '&size_metric=' + size_metric + '&color_metric=' + color_metric + '&hide_form=' + hide_form + '&var=' + variation_index" %>
|
||||
:with => "'width=' + treemap_width + '&height=' + treemap_height + '&size_metric=' + size_metric + '&color_metric=' + color_metric + '&hide_form=' + hide_form + '&period=' + period_index" %>
|
||||
}
|
||||
load_treemap('<%= size_metric.key -%>', '<%= color_metric.key -%>', <%= edit_mode -%>, <%= params[:var].to_i -%>);
|
||||
load_treemap('<%= size_metric.key -%>', '<%= color_metric.key -%>', <%= edit_mode -%>, <%= params[:period].to_i -%>);
|
||||
</script>
|
@ -102,10 +102,10 @@ table#columns td {
|
||||
<tr>
|
||||
<td class="first">Default period:</td>
|
||||
<td>
|
||||
<select id="variation_index" name="variation_index">
|
||||
<select id="period_index" name="period_index">
|
||||
<option value="">None</option>
|
||||
<% period_names.each_with_index do |name, index| %>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if @filter.variation_index==index+1 -%>><%= name -%></value>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if @filter.period_index==index+1 -%>><%= name -%></value>
|
||||
<% end %>
|
||||
</select>
|
||||
</td>
|
||||
|
@ -19,10 +19,10 @@
|
||||
<td>
|
||||
<span class="comments">Period:</span>
|
||||
<br/>
|
||||
<select name="var" onchange="submit()" class="small">
|
||||
<select name="period" onchange="submit()" class="small">
|
||||
<option value="">None</option>
|
||||
<% period_names.each_with_index do |name, index| %>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if params[:var].to_i==index+1 -%>><%= name -%></value>
|
||||
<option value="<%= index+1 -%>" <%= 'selected' if params[:period].to_i==index+1 -%>><%= name -%></value>
|
||||
<% end %>
|
||||
</select>
|
||||
</td>
|
||||
|
@ -21,10 +21,10 @@
|
||||
#
|
||||
# Sonar 2.5
|
||||
#
|
||||
class AddVariationsToFilters < ActiveRecord::Migration
|
||||
class AddPeriodsToFilters < ActiveRecord::Migration
|
||||
|
||||
def self.up
|
||||
add_column :filters, :variation_index, :integer, :null => true
|
||||
add_column :filters, :period_index, :integer, :null => true
|
||||
Filter.reset_column_information
|
||||
|
||||
add_column :filter_columns, :variation, :boolean, :null => true
|
@ -44,6 +44,8 @@ public class Measure extends Model {
|
||||
*/
|
||||
private String ruleCategory;
|
||||
|
||||
private Double variation1, variation2, variation3, variation4, variation5;
|
||||
|
||||
public String getMetricKey() {
|
||||
return metricKey;
|
||||
}
|
||||
@ -223,6 +225,86 @@ public class Measure extends Model {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation value on period 1. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
|
||||
* @since 2.5
|
||||
*/
|
||||
public Double getVariation1() {
|
||||
return variation1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Measure setVariation1(Double variation1) {
|
||||
this.variation1 = variation1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation value on period 2. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
|
||||
* @since 2.5
|
||||
*/
|
||||
public Double getVariation2() {
|
||||
return variation2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Measure setVariation2(Double variation2) {
|
||||
this.variation2 = variation2;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation value on period 3. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
|
||||
* @since 2.5
|
||||
*/
|
||||
public Double getVariation3() {
|
||||
return variation3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Measure setVariation3(Double variation3) {
|
||||
this.variation3 = variation3;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation value on period 4. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
|
||||
* @since 2.5
|
||||
*/
|
||||
public Double getVariation4() {
|
||||
return variation4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Measure setVariation4(Double variation4) {
|
||||
this.variation4 = variation4;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation value on period 5. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
|
||||
* @since 2.5
|
||||
*/
|
||||
public Double getVariation5() {
|
||||
return variation5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Measure setVariation5(Double variation5) {
|
||||
this.variation5 = variation5;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder().append("Measure{")
|
||||
|
@ -29,7 +29,7 @@ public class Resource extends Model {
|
||||
public static final String SCOPE_SET = "PRJ";
|
||||
public static final String SCOPE_SPACE = "DIR";
|
||||
public static final String SCOPE_ENTITY = "FIL";
|
||||
|
||||
|
||||
/* QUALIFIERS */
|
||||
public static final String QUALIFIER_VIEW = "VW";
|
||||
public static final String QUALIFIER_SUBVIEW = "SVW";
|
||||
@ -58,6 +58,11 @@ public class Resource extends Model {
|
||||
private Date date;
|
||||
private List<Measure> measures;
|
||||
|
||||
// periods used for variations and tracking of violations
|
||||
private String period1Mode, period2Mode, period3Mode, period4Mode, period5Mode;
|
||||
private String period1Param, period2Param, period3Param, period4Param, period5Param;
|
||||
private Date period1Date, period2Date, period3Date, period4Date, period5Date;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@ -208,6 +213,231 @@ public class Resource extends Model {
|
||||
this.measures = measures;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod1Mode() {
|
||||
return period1Mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod1Mode(String period1Mode) {
|
||||
this.period1Mode = period1Mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod2Mode() {
|
||||
return period2Mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod2Mode(String period2Mode) {
|
||||
this.period2Mode = period2Mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod3Mode() {
|
||||
return period3Mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod3Mode(String period3Mode) {
|
||||
this.period3Mode = period3Mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod4Mode() {
|
||||
return period4Mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod4Mode(String period4Mode) {
|
||||
this.period4Mode = period4Mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod5Mode() {
|
||||
return period5Mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod5Mode(String period5Mode) {
|
||||
this.period5Mode = period5Mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod1Param() {
|
||||
return period1Param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod1Param(String period1Param) {
|
||||
this.period1Param = period1Param;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod2Param() {
|
||||
return period2Param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod2Param(String period2Param) {
|
||||
this.period2Param = period2Param;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod3Param() {
|
||||
return period3Param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod3Param(String period3Param) {
|
||||
this.period3Param = period3Param;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod4Param() {
|
||||
return period4Param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod4Param(String period4Param) {
|
||||
this.period4Param = period4Param;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public String getPeriod5Param() {
|
||||
return period5Param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod5Param(String period5Param) {
|
||||
this.period5Param = period5Param;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public Date getPeriod1Date() {
|
||||
return period1Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod1Date(Date period1Date) {
|
||||
this.period1Date = period1Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public Date getPeriod2Date() {
|
||||
return period2Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod2Date(Date period2Date) {
|
||||
this.period2Date = period2Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public Date getPeriod3Date() {
|
||||
return period3Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod3Date(Date period3Date) {
|
||||
this.period3Date = period3Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public Date getPeriod4Date() {
|
||||
return period4Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod4Date(Date period4Date) {
|
||||
this.period4Date = period4Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5 only on projects, else null
|
||||
*/
|
||||
public Date getPeriod5Date() {
|
||||
return period5Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
public Resource setPeriod5Date(Date period5Date) {
|
||||
this.period5Date = period5Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
|
@ -47,7 +47,22 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
|
||||
.setLanguage(JsonUtils.getString(json, "lang"))
|
||||
.setDescription(JsonUtils.getString(json, "description"))
|
||||
.setDate(JsonUtils.getDateTime(json, "date"))
|
||||
.setVersion(JsonUtils.getString(json, "version"));
|
||||
.setVersion(JsonUtils.getString(json, "version"))
|
||||
.setPeriod1Mode(JsonUtils.getString(json, "p1"))
|
||||
.setPeriod1Param(JsonUtils.getString(json, "p1p"))
|
||||
.setPeriod1Date(JsonUtils.getDateTime(json, "p1d"))
|
||||
.setPeriod2Mode(JsonUtils.getString(json, "p2"))
|
||||
.setPeriod2Param(JsonUtils.getString(json, "p2p"))
|
||||
.setPeriod2Date(JsonUtils.getDateTime(json, "p2d"))
|
||||
.setPeriod3Mode(JsonUtils.getString(json, "p3"))
|
||||
.setPeriod3Param(JsonUtils.getString(json, "p3p"))
|
||||
.setPeriod3Date(JsonUtils.getDateTime(json, "p3d"))
|
||||
.setPeriod4Mode(JsonUtils.getString(json, "p4"))
|
||||
.setPeriod4Param(JsonUtils.getString(json, "p4p"))
|
||||
.setPeriod4Date(JsonUtils.getDateTime(json, "p4d"))
|
||||
.setPeriod5Mode(JsonUtils.getString(json, "p5"))
|
||||
.setPeriod5Param(JsonUtils.getString(json, "p5p"))
|
||||
.setPeriod5Date(JsonUtils.getDateTime(json, "p5d"));
|
||||
}
|
||||
|
||||
private void parseMeasures(JSONObject json, Resource resource) {
|
||||
@ -85,7 +100,12 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
|
||||
.setRuleCategory(JsonUtils.getString(json, "rule_category"))
|
||||
.setRuleSeverity(JsonUtils.getString(json, "rule_priority"))
|
||||
.setCharacteristicKey(JsonUtils.getString(json, "ctic_key"))
|
||||
.setCharacteristicName(JsonUtils.getString(json, "ctic_name"));
|
||||
.setCharacteristicName(JsonUtils.getString(json, "ctic_name"))
|
||||
.setVariation1(JsonUtils.getDouble(json, "var1"))
|
||||
.setVariation2(JsonUtils.getDouble(json, "var2"))
|
||||
.setVariation3(JsonUtils.getDouble(json, "var3"))
|
||||
.setVariation4(JsonUtils.getDouble(json, "var4"))
|
||||
.setVariation5(JsonUtils.getDouble(json, "var5"));
|
||||
return measure;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package org.sonar.tests.violationstimemachine;
|
||||
|
||||
public class SecondFileAddedInV2 {
|
||||
|
||||
public void hasOneViolation() {
|
||||
int i = 0; // unused local variable
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
@ -19,5 +19,45 @@
|
||||
*/
|
||||
package org.sonar.tests.integration;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.sonar.wsclient.Sonar;
|
||||
import org.sonar.wsclient.services.Resource;
|
||||
import org.sonar.wsclient.services.ResourceQuery;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.number.OrderingComparisons.greaterThan;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class VariationsIT {
|
||||
|
||||
private static final String TIMEMACHINE_PROJECT = "org.sonar.tests:violations-timemachine";
|
||||
|
||||
private static Sonar sonar;
|
||||
|
||||
@BeforeClass
|
||||
public static void buildServer() {
|
||||
sonar = ITUtils.createSonarWsClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkBaseVariations() {
|
||||
|
||||
Resource project = getProject("files", "ncloc", "violations");
|
||||
|
||||
// period 1 : previous analysis
|
||||
assertThat(project.getPeriod1Mode(), is("previous_analysis"));
|
||||
assertThat(project.getPeriod1Date(), notNullValue());
|
||||
|
||||
// variations from previous analysis
|
||||
assertThat(project.getMeasure("files").getVariation1(), is(1.0));
|
||||
assertThat(project.getMeasure("ncloc").getVariation1(), is(8.0));
|
||||
assertThat(project.getMeasure("violations").getVariation1(), greaterThan(0.0));
|
||||
}
|
||||
|
||||
private Resource getProject(String... metricKeys) {
|
||||
return sonar.find(ResourceQuery.createForMetrics(TIMEMACHINE_PROJECT, metricKeys).setIncludeTrends(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ViolationsTimeMachineIT {
|
||||
assertThat(snapshot1.getValues(), is(Arrays.asList("0.0", "0.0", "3.0", "4.0", "0.0")));
|
||||
|
||||
assertThat(snapshot2.getDate().getMonth(), is(10));
|
||||
assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "4.0", "3.0", "0.0")));
|
||||
assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "5.0", "4.0", "0.0")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user