summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-13 17:49:46 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-13 17:49:46 +0100
commit864e78743095d214311c6acdc73c195220b020c1 (patch)
treecb2cce6ca756725005ad86fbfee43c2fe59497af
parentcf3ce5bd552c16b65eea2afd995f25524247f4a9 (diff)
parente3776e7ccf6fdceacdbf7b332e74122f8303e54a (diff)
downloadsonarqube-864e78743095d214311c6acdc73c195220b020c1.tar.gz
sonarqube-864e78743095d214311c6acdc73c195220b020c1.zip
Merge remote branch 'origin/master'
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/filters/Filter.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications.html.erb12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb1
-rw-r--r--sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java8
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml2
16 files changed, 90 insertions, 22 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index f5416c41594..32e934c4bf0 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -788,6 +788,7 @@ violations_viewer.review_filter.unreviewed_violations=Unreviewed violations
#------------------------------------------------------------------------------
duplications.no_duplicated_block=No duplicated blocks.
+duplications.dups_found_on_deleted_resource=This file contains duplicated blocks with some deleted resources. This project should be reanalyzed to remove these obsolete duplicated blocks.
duplications.blocks=Blocks
duplications.number_of_lines=Nb Lines
duplications.from_line=From line
diff --git a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
index e7e997bbf3e..0e302115282 100644
--- a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
+++ b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
@@ -56,6 +56,7 @@ public class Filter {
private Boolean sortedByMeasureVariation = Boolean.FALSE;
private boolean sortedByLanguage;
private boolean sortedByName;
+ private boolean sortedByKey;
private boolean sortedByDate;
private boolean sortedByVersion;
private boolean isNumericMetric = true;
@@ -178,7 +179,7 @@ public class Filter {
}
public boolean isTextSort() {
- return !isNumericMetric || sortedByLanguage || sortedByName || sortedByVersion;
+ return !isNumericMetric || sortedByLanguage || sortedByName || sortedByVersion || sortedByKey;
}
public Filter setSortedMetricId(Integer id, boolean isNumericValue, Boolean isVariation) {
@@ -203,6 +204,10 @@ public class Filter {
return sortedByName;
}
+ public boolean isSortedByKey() {
+ return sortedByKey;
+ }
+
public boolean isSortedByVersion() {
return sortedByVersion;
}
@@ -214,7 +219,7 @@ public class Filter {
}
public boolean isSorted() {
- return isSortedByLanguage() || isSortedByName() || isSortedByDate() || isSortedByVersion() || getSortedMetricId() != null;
+ return isSortedByLanguage() || isSortedByName() || isSortedByKey() || isSortedByDate() || isSortedByVersion() || getSortedMetricId() != null;
}
public boolean isSortedByDate() {
@@ -233,10 +238,17 @@ public class Filter {
return this;
}
+ public Filter setSortedByKey() {
+ unsetSorts();
+ this.sortedByKey = true;
+ return this;
+ }
+
private void unsetSorts() {
this.sortedByDate = false;
this.sortedByLanguage = false;
this.sortedByName = false;
+ this.sortedByKey = false;
this.sortedMetricId = null;
this.sortedByVersion = false;
this.isNumericMetric = true;
diff --git a/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java b/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java
index 11c44f424e6..2a656f30051 100644
--- a/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java
+++ b/sonar-server/src/main/java/org/sonar/server/filters/FilterExecutor.java
@@ -85,6 +85,9 @@ public class FilterExecutor implements ServerComponent {
} else if (filter.isSortedByName()) {
sql.append(", MAX(p.long_name) as name ");
+ } else if (filter.isSortedByKey()) {
+ sql.append(", MAX(p.kee) as kee ");
+
} else if (filter.isSortedByDate()) {
sql.append(", MAX(s.created_at) as createdat ");
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
index 710b796937a..56a6adbb316 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
@@ -282,6 +282,7 @@ class ResourceController < ApplicationController
def parse_duplications(dups, duplication_groups)
resource_by_key = {}
resource_by_key[@resource.key] = @resource
+ dups_found_on_deleted_resource = false
dups.elements.each("duplications/g") do |group|
dup_group = []
group.each_element("b") do |block|
@@ -292,10 +293,15 @@ class ResourceController < ApplicationController
resource = Project.by_key(resource_key)
resource_by_key[resource_key] = resource
end
- dup_group << {:resource => resource, :lines_count => block.attributes['l'], :from_line => block.attributes['s']} if resource
+ if resource
+ dup_group << {:resource => resource, :lines_count => block.attributes['l'], :from_line => block.attributes['s']}
+ else
+ dups_found_on_deleted_resource = true
+ end
end
duplication_groups << dup_group if dup_group.size > 1
end
+ @duplication_group_warning = message('duplications.dups_found_on_deleted_resource') if dups_found_on_deleted_resource
end
# Format before sonar 2.12
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
index f55ef40d90a..17b0894601b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
@@ -326,8 +326,20 @@ module ApplicationHelper
def link_to_resource(resource, name=nil, options={})
period_index=options[:period]
period_index=nil if period_index && period_index<=0
- link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => resource.id, :period => period_index,
- :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
+ if resource.display_dashboard?
+ if options[:dashboard]
+ link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => resource.id, :period => period_index,
+ :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
+ else
+ # stay on the same page (for example components)
+ link_to(name || resource.name, {:overwrite_params => {:id => resource.id, :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
+ end
+ else
+ if options[:line]
+ anchor= 'L' + options[:line].to_s
+ end
+ link_to(name || resource.name, {:controller => 'resource', :action => 'index', :anchor => anchor, :id => resource.id, :period => period_index, :tab => options[:tab], :rule => options[:rule], :metric => options[:metric]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title])
+ end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
index 07f3db432f6..6d89067a591 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
@@ -45,11 +45,14 @@ class Api::Utils
markdown ? Java::OrgSonarServerUi::JRubyFacade.markdownToHtml(ERB::Util.html_escape(markdown)) : ''
end
- # splits a string into an array of lines
+ # Splits a string into an array of lines
+ # For history reference:
+ # - http://jira.codehaus.org/browse/SONAR-2282 first modified the behaviour to keep the trailing lines
+ # - then http://jira.codehaus.org/browse/SONAR-3003 reverted this modification to remove potential last empty line
def self.split_newlines(input)
- # Don't limit number of returned fields and don't suppress trailing empty fields by setting second parameter to negative value.
- # See http://jira.codehaus.org/browse/SONAR-2282
- input.split(/\r?\n|\r/, -1)
+ result = input.split(/\r?\n|\r/, -1)
+ result.pop if result.last==''
+ result
end
def self.convert_string_to_unix_newlines(input)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb
index 75312ecb27c..af1c7257f42 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb
@@ -86,6 +86,9 @@ class Filters
elsif filter.sorted_column.on_language?
java_filter.setSortedByLanguage()
+
+ elsif filter.sorted_column.on_key?
+ java_filter.setSortedByKey()
elsif filter.sorted_column.on_metric? && filter.sorted_column.metric
metric=filter.sorted_column.metric
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb
index 3076abcf0bf..4ea90f9441a 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb
@@ -43,10 +43,15 @@
<td width="1%" nowrap>
<% if logged_in? %><%= link_to_favourite(project) -%>
<% end %>
+ <%= link_to_resource(project, image_tag('zoom.png')) %>
</td>
<td class="left" x="<%= u(snapshot.project.name) -%>">
<%= qualifier_icon(snapshot) %>
- <%= link_to_resource(project, project.name) %>
+ <% if snapshot.display_dashboard? %>
+ <a href="<%= ApplicationController.root_context + "/dashboard/index/#{snapshot.project.id}" -%>"><%= snapshot.project.name -%></a>
+ <% else %>
+ <%= snapshot.project.name %>
+ <% end %>
</td>
<% @columns.each do |column| %>
<%= get_column_content(column, snapshot, @measures_by_snapshot) -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb
index 6d99650df91..4043a26546b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb
@@ -5,12 +5,23 @@
<div id="resource_container"></div>
<script type="text/javascript">
- new Ajax.Updater('resource_container', '<%= ApplicationController.root_context-%>/resource/index/<%= @file.id -%>',
+ // see if an anchor has been passed
+ var anchor;
+ var stripped_url = document.location.toString().split("#");
+ if (stripped_url.length > 1) {
+ anchor = stripped_url[1];
+ }
+
+ // and call the resource page
+ new Ajax.Updater('resource_container', '<%= url_for params.merge({:controller => 'resource', :action => 'index', :id => @file.id}) -%>',
{
asynchronous:true,
evalScripts:true,
onComplete:function (transport) {
- $('page_loading').hide()
+ $('page_loading').hide();
+ if (anchor!=null) {
+ window.location.hash = anchor;
+ }
}
});
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb
index 68ab903da18..bdd465d4e95 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb
@@ -102,7 +102,7 @@
<%= trend_icon(measure, :empty => true) -%>
<% end %>
<% end %>
- <% elsif column.on_name? %><%= qualifier_icon(@masterproject) %> <%= link_to_resource(@masterproject.project, h(@masterproject.project.name(true)), {:title => @masterproject.project.key}) %>
+ <% elsif column.on_name? %><%= qualifier_icon(@masterproject) %> <%= link_to_resource(@masterproject.project, h(@masterproject.project.name(true)), {:dashboard => true, :title => @masterproject.project.key}) %>
<% elsif column.on_date? %><%= human_short_date(@masterproject.created_at) %>
<% end %>
</td>
@@ -134,7 +134,7 @@
<% end %>
<% end %>
<% elsif column.on_name? %>
- <%= qualifier_icon(snapshot) %> <%= link_to_resource(snapshot.project, snapshot.project.name(true), {:title => snapshot.project.key, :period => @filter_context.period_index}) %>
+ <%= qualifier_icon(snapshot) %> <%= link_to_resource(snapshot.project, snapshot.project.name(true), {:dashboard => true, :title => snapshot.project.key, :period => @filter_context.period_index}) %>
<% elsif column.on_version? %><%= h snapshot.version %>
<% elsif column.on_language? %><%= snapshot.project.language %>
<% elsif column.on_date? %><%= human_short_date(snapshot.created_at) %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb
index 52f8ea303f7..bb7a04e1cfc 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb
@@ -14,8 +14,7 @@
</thead>
<tbody >
<% @groups.each do |group|%>
- <% clazz = cycle("even", "odd", :name => 'index_user') %>
- <tr class="<%= clazz %>" id="group-<%= u group.name -%>">
+ <tr id="group-<%= u group.name -%>">
<td class="left"><%= group.name %></td>
<td class="left" style="word-break:break-all"><%=group.description%></td>
<td class="left">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications.html.erb
index 3fc24f80bac..81bca4a8fbd 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications.html.erb
@@ -1,8 +1,14 @@
-<% if @duplication_groups.empty? %>
+<%
+ if @duplication_groups.empty?
+ warning_message = message('duplications.no_duplicated_block')
+ warning_message = @duplication_group_warning if @duplication_group_warning
+%>
- <%= message('duplications.no_duplicated_block') -%>
+ <%= warning_message -%>
-<% else %>
+<% else %>
+
+ <%= @duplication_group_warning if @duplication_group_warning -%>
<table id="duplications" class="data">
<thead>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb
index eeab570dba4..a4c3490b177 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb
@@ -5,7 +5,7 @@
%>
<p>
<%= qualifier_icon(parent_project) -%>
- <%= link_to_resource(parent_project, parent_project.path_name) -%>
+ <%= link_to_resource(parent_project, parent_project.path_name, {:dashboard => true}) -%>
&nbsp;&nbsp;
<%= qualifier_icon(resource) -%>
<%= link_to_resource(resource, resource.name(true), {:line => from_line}) -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
index def16e51634..9df129cb061 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
@@ -14,7 +14,6 @@
</thead>
<tbody >
<% @users.each do |user|%>
- <% clazz = cycle("even", "odd", :name => 'index_user') %>
<tr id="user-<%= u user.login -%>">
<td class="left" valign="top"><%=user.login %></td>
<td class="left" valign="top"><%=user.name %></td>
diff --git a/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java b/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java
index 4feb4c7abea..6022e0191d5 100644
--- a/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java
@@ -102,6 +102,14 @@ public class FilterExecutorTest extends AbstractDbUnitTestCase {
}
@Test
+ public void sortByKey() {
+ setupData("shared");
+ FilterExecutor executor = new FilterExecutor(getSession());
+ FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByKey());
+ assertSortedSnapshotIds(result, 3, 2, 4);
+ }
+
+ @Test
public void sortByDate() {
setupData("shared");
FilterExecutor executor = new FilterExecutor(getSession());
diff --git a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml
index 26eed6f6800..03e194f11aa 100644
--- a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml
@@ -3,7 +3,7 @@
root_id="[null]"
description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
- <projects long_name="php project" id="2" scope="PRJ" kee="project:php" qualifier="TRK" name="php project"
+ <projects long_name="php project" id="2" scope="PRJ" kee="project:a-php-project" qualifier="TRK" name="php project"
root_id="[null]"
description="[null]" enabled="true" profile_id="[null]" language="php" copy_resource_id="[null]" person_id="[null]"/>