From 7114c0e8c8213154a2dce8e9797f325e82742b7d Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 16 Jun 2014 22:34:51 +0200 Subject: [PATCH] SONAR-5007 display (in a crappy way) some facets on profile page + remove unused the l10n bundles prefixed by "rules_configuration" --- .../resources/org/sonar/l10n/core.properties | 50 ------------------- .../qualityprofile/QProfileService.java | 3 +- .../qualityprofile/index/ActiveRuleIndex.java | 5 +- .../app/controllers/profiles_controller.rb | 7 +-- .../app/views/drilldown/issues.html.erb | 2 +- .../app/views/profiles/compare.html.erb | 8 +-- .../WEB-INF/app/views/profiles/index.html.erb | 6 +-- .../WEB-INF/app/views/profiles/show.html.erb | 14 +++++- .../views/project/_snapshot_title.html.erb | 4 +- .../ActiveRuleBackendMediumTest.java | 2 +- 10 files changed, 31 insertions(+), 70 deletions(-) diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index cc7bb5204e4..54adbb06fad 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1666,56 +1666,6 @@ quality_gates.delete_condition.confirm.message=Are you sure you want to delete t quality_gates.project_period=over period {0} - defined at project level -#------------------------------------------------------------------------------ -# -# RULES CONFIGURATION -# -#------------------------------------------------------------------------------ - -rules_configuration.tab.new_rule=New rule -rules_configuration.tab.edit_rule=Edit rule -rules_configuration.x_found_in_active_rules={0} found in active rules -rules_configuration.x_found_in_inactive_rules={0} found in inactive rules -rules_configuration.expand=expand -rules_configuration.collapse=collapse -rules_configuration.html_allowed=HTML is allowed. -rules_configuration.inherited_from_parent=Inherited from parent -rules_configuration.overrides_parent_definition=Overrides parent definition -rules_configuration.parent_parameter.empty=empty -rules_configuration.copy_rule=Copy rule -rules_configuration.edit_rule=Edit rule -rules_configuration.revert_to_parent_definition=Revert to parent definition -rules_configuration.not_inherited=Not inherited -rules_configuration.inherited=Inherited -rules_configuration.overrides=Overrides -rules_configuration.rule_not_valid_message_x=Rule is not valid:
{0} -rules_configuration.rule_deleted=Rule deleted -rules_configuration.unknown_rule=Unknown rule -rules_configuration.x_rules_have_been_activated={0} rules have been activated. -rules_configuration.x_rules_have_been_deactivated={0} rules have been deactivated. -rules_configuration.extend_description=Extend Description -rules_configuration.edit_note=Edit Note -rules_configuration.add_note=Add Note -rules_configuration.confirm_delete_note=Do you really want to delete this note? -rules_configuration.rule_inherited_from_profile_x=Rule inherited from profile "{0}" -rules_configuration.rule_overriding_from_profile_x=Rule overrides parent definition from profile "{0}" -rules_configuration.original_value=Original value -rules_configuration.original_severity=Original severity -rules_configuration.repository=Repository -rules_configuration.status_filters=Status -rules_configuration.tags_filters=Tags -rules_configuration.sort_by=Sort by: -rules_configuration.rule_name=Rule name -rules_configuration.creation_date=Creation date -rules_configuration.available_since=Available since -rules_configuration.select_tags=Select Tags -rules_configuration.select_tags_for_rule=Select Tags for Rule: -rules_configuration.available_tags=Available Tags -rules_configuration.update_tags=Update Tags -rules_configuration.new_tag=New Tag... -rules_configuration.create_tag=Create Tag - - #------------------------------------------------------------------------------ # # RULES DOCUMENTATION PAGE diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java index 30305fd41be..36263b08b8d 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java @@ -224,11 +224,10 @@ public class QProfileService implements ServerComponent { } public Map> getAllProfileStats() { - List keys = Lists.newArrayList(); for (QualityProfileDto profile : this.findAll()) { keys.add(profile.getKey()); } - return index.get(ActiveRuleIndex.class).getStatsByProfileKey(keys); + return index.get(ActiveRuleIndex.class).getStatsByProfileKeys(keys); } } diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java index 07cedb501b0..95c30fe0cb3 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java @@ -184,11 +184,10 @@ public class ActiveRuleIndex extends BaseIndex getStatsByProfileKey(QualityProfileKey key) { - return getStatsByProfileKey(ImmutableList.of(key)).get(key); + return getStatsByProfileKeys(ImmutableList.of(key)).get(key); } - public Map> getStatsByProfileKey(List keys) { - + public Map> getStatsByProfileKeys(List keys) { String[] stringKeys = new String[keys.size()]; for (int i = 0; i < keys.size(); i++) { stringKeys[i] = keys.get(i).toString(); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index 194ca1520e3..5c0129b34dc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -30,7 +30,7 @@ class ProfilesController < ApplicationController add_breadcrumbs ProfilesController::root_breadcrumb call_backend do @profiles = Internal.quality_profiles.allProfiles().to_a - @stats = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getAllProfileStats() + @active_rule_counts = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).countAllActiveRules() end Api::Utils.insensitive_sort!(@profiles) { |profile| profile.name() } end @@ -40,6 +40,9 @@ class ProfilesController < ApplicationController require_parameters 'id' call_backend do @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile + @active_rule_count = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).countActiveRulesByProfile(@profile.key()) + @stats = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).getStatsByProfile(@profile.key()) end set_profile_breadcrumbs end @@ -87,7 +90,6 @@ class ProfilesController < ApplicationController require_parameters 'language' call_backend do Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).restoreBuiltInProfilesForLanguage(params[:language].to_s) - #flash_result(@result) end redirect_to :action => 'index' end @@ -180,7 +182,6 @@ class ProfilesController < ApplicationController call_backend do xml=Api::Utils.read_post_request_param(params[:backup]) Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).restore(xml) - #flash_result(result) end end redirect_to :action => 'index' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb index 205bffa30f4..bad41fc2f35 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb @@ -10,7 +10,7 @@ <% profile_measure=@snapshot.measure(Metric::PROFILE) %> - <% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> + <% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => 'profiles', :action => 'show', :id => profile_measure.value.to_i %> <% end %> <% if @snapshot.project_snapshot.periods? %> <% period_options = period_select_option_tags(@snapshot, 'small') %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb index 9941028ae77..a70b6c3939d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb @@ -45,7 +45,7 @@ <%= message('quality_profiles.x_rules_only_in', :params => @in1.size) %> - <%= h @profile1.name %> + <%= h @profile1.name %> @@ -72,7 +72,7 @@ <%= message('quality_profiles.x_rules_only_in', :params => @in2.size) %> - <%= h @profile2.name %> + <%= h @profile2.name %> @@ -96,11 +96,11 @@ <%= message('quality_profiles.x_rules_have_different_configuration', :params =>@modified.size) -%>
-
<%= h @profile1.name %> + <%= h @profile1.name %> -
<%= h @profile2.name %> +
<%= h @profile2.name %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index b424bc0247d..25d653a1548 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -53,9 +53,7 @@ <% @profiles.select { |p| p.language == language.getKey() }.each do |profile| key = profile_key(profile) projects_count = projects_count(profile) - profile_rules_count = profile_rules_count(profile) is_default_profile = !default_profile.nil? && (default_profile.name() == profile.name()) - %> @@ -64,7 +62,9 @@ - <%= profile_rules_count -%> + + <%= @active_rule_counts[profile.key()] || 0 -%> + diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb index d1eaa1ec7a0..a4d9e3237ba 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb @@ -2,6 +2,18 @@ <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Rules'} %>
- +

+ "><%= @active_rule_count -%> <%= message('coding_rules._rules') -%> +

+
+

+ Inheritance:
+ <%= @stats.get('inheritance') if @stats -%> +

+
+

+ Severity:
+ <%= @stats.get('severity') if @stats -%> +

diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb index 3012b22fc9a..733c4ece05a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_snapshot_title.html.erb @@ -5,7 +5,7 @@ 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 profile_measure %> - profile <%= link_to profile_measure.data, :controller => 'profiles', :action => 'show', :id => profile_measure.value.to_i %><% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java index afdbb17a58a..2c2e7f94246 100644 --- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java @@ -319,7 +319,7 @@ public class ActiveRuleBackendMediumTest { assertThat(index.countAll()).isEqualTo(4); // 1. Assert by term aggregation; - Map> stats = index.getStatsByProfileKey( + Map> stats = index.getStatsByProfileKeys( ImmutableList.of(profileDto1.getKey(), profileDto2.getKey())); -- 2.39.5