]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2388 Make it possible to search for 'false-positive' reviews
authorFabrice Bellingard <bellingard@gmail.com>
Thu, 26 May 2011 15:53:53 +0000 (17:53 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 26 May 2011 15:53:53 +0000 (17:53 +0200)
- Adds select box on the search page
- Change comment icon color if false-positive
- Add "False positive" label on the permalink page
- Adjust link that opens the resource to directly open the resource
  viewer on the false-positives

12 files changed:
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb
sonar-server/src/main/webapp/images/reviews/+false-positive.png [deleted file]
sonar-server/src/main/webapp/images/reviews/+review.png [deleted file]
sonar-server/src/main/webapp/images/reviews/false_positive.png [new file with mode: 0644]
sonar-server/src/main/webapp/images/reviews/review.png [deleted file]
sonar-server/src/main/webapp/images/reviews/with_false_positives.png [new file with mode: 0644]
sonar-server/src/main/webapp/stylesheets/style.css

index ddf519dca1e82868f86e296114ea1592a8d8bc5f..5062feb382d2ad3dd01ece0af9254cad30c83034 100644 (file)
@@ -272,7 +272,8 @@ class ReviewsController < ApplicationController
     @severities = filter_any(params[:severities]) || ['']
     @statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN]
     @projects = filter_any(params[:projects]) || ['']
-    @id = params[:review_id] || ""
+    @false_positives = params[:false_positives] || 'without'
+    @id = params[:review_id] || ''
     @sort = params[:sort]
     @asc = params[:asc] == "true"
   end
@@ -285,7 +286,7 @@ class ReviewsController < ApplicationController
   end
 
   def search_reviews
-    options = { 'false_positives' => 'without' }
+    options = {}
     unless @statuses == ['']
       options['statuses']=@statuses.join(',')
     end
@@ -301,6 +302,9 @@ class ReviewsController < ApplicationController
     if @assignee_id
       options['assignees']=@assignee_id.to_s
     end
+    if @false_positives
+      options['false_positives']=@false_positives
+    end
     unless @id  == ''
       if is_number? @id
         options['id'] = @id
index ccc33e692ffeeb164db48ef35d528eed6d3a6696..2922bcf0c92b049fd30e7eb0cf6e177ade196937 100644 (file)
@@ -315,13 +315,13 @@ module ApplicationHelper
     period_index=nil if period_index && period_index<=0
     if resource.display_dashboard?
       if options[:dashboard]
-        link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title])
+        link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_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.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title])
+        link_to(name || resource.name, {:overwrite_params => {:id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
       end
     else
-      link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title])
+      link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab], :rule => options[:rule]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title])
     end
   end
 
index a99f1fd7b3094c4bc8c88c0b6319e7e6afba10d6..7999bc9c69da51cbacfe3dc4e75879f7e55f5e1e 100644 (file)
@@ -117,11 +117,14 @@ module UsersHelper
   # field that is submitted is a hidden one that contains the user ID that corresponds
   # to the typed name (if the user exists, of course).
   #
+  # The 'options' argument can be used to pass HTML elements to the text field.
+  # (for the moment 'class' is supported).
+  #
   # Example:
   #   <%= user_autocomplete_field "assignee_id", @assignee_id -%>
   #   # => generates an input field for the parameter 'assignee_id'
   #
-  def user_autocomplete_field(param_id, param_value)
+  def user_autocomplete_field(param_id, param_value, options={})
     param_id_name = param_id
     param_id_value = param_value
     
@@ -134,7 +137,8 @@ module UsersHelper
     server_url = url_for :controller => 'users', :action => 'autocomplete'
     
     render :partial => 'autocomplete/text_field', :locals => {:param_id_name => param_id_name, :param_id_value => param_id_value, 
-                                                              :param_displayed_value => param_displayed_value, :server_url => server_url }
+                                                              :param_displayed_value => param_displayed_value, :server_url => server_url,
+                                                              :options => options.to_options}
   end
 
 end
index 8675ee22515510ed6cbf5cba523186f43cfffdc4..2e9b6f047e7ebb45598395cd257d4dc481aa452a 100644 (file)
@@ -1,4 +1,8 @@
-  <input type="text" id="autocompleteText-<%= param_id_name -%>" value="<%= param_displayed_value -%>" onfocus="$('<%= param_id_name -%>').value=''; this.value=''"/>
+  <input type="text" 
+         id="autocompleteText-<%= param_id_name -%>" 
+         value="<%= param_displayed_value -%>" 
+         onfocus="$('<%= param_id_name -%>').value=''; this.value=''"
+         <%= "class=\"" + options[:class] + "\"" if options[:class] -%>/>
   <input type="hidden" id="<%= param_id_name -%>" name="<%= param_id_name -%>" value="<%= param_id_value -%>"/>
   <div id="autocomplete-<%= param_id_name -%>" class="autocomplete"></div>
   <script>
index ef3ea5b72fa533c19cbfe55141669ee26cb58fc4..dd702ee4158cfa53ffa06df8184016aea55f3f42 100644 (file)
@@ -1,6 +1,11 @@
 <div id="rev_<%= review.id -%>">
   <div class="reportTitle">
     <h2>Review #<%= h(review.id.to_s) -%> - <%= h(review.title) -%></h2>
+    <% if review.false_positive %>
+      <%= image_tag("sep12.png") -%>
+      &nbsp;
+      <span class="falsePositive">False-Positive</span>
+    <% end %>
     
     <% 
       if current_user && review.status != "CLOSED" && review.rule_failure
@@ -91,7 +96,7 @@
           <td class="val" colspan="3">
                <%= qualifier_icon(@review.resource) -%> 
                <% if !review.on_project? %> <%= @review.project.long_name -%> <%= image_tag 'sep12.png' -%> <% end %>
-               <%= link_to_resource(review.resource, review.resource.long_name, { :tab => :violations } ) %>
+               <%= link_to_resource(review.resource, review.resource.long_name, { :tab => :violations, :rule => "f-positive" } ) %>
           </td>
         </tr>
   </table>
index 0b1d521a58360cacfd0c55f69bc3fea53b1f6431..bb2b91e8aa9155dad9501dbbb87bc629dba5b60d 100644 (file)
@@ -7,7 +7,8 @@ function reviewIdFieldModified(field) {
     $('author_id').value = ''
     $('autocompleteText-author_id').value = ''
     $('assignee_id').value = ''
-    $('autocompleteText-assignee_id').value = ''    
+    $('autocompleteText-assignee_id').value = ''  
+    $('false_positives').value = 'with'  
   }
 }
 function launchSearch(columnName, link) {
@@ -63,13 +64,19 @@ function launchSearch(columnName, link) {
         </td>
         <td width="1%" nowrap>
           <span class="note">Created by</span><br/>
-          <%= user_autocomplete_field "author_id", @author_id -%>
+          <%= user_autocomplete_field "author_id", @author_id, { :class => "max-width" } -%>
           <br/>
           <span class="note">Assigned to</span><br/>
-          <%= user_autocomplete_field "assignee_id", @assignee_id -%>
+          <%= user_autocomplete_field "assignee_id", @assignee_id, { :class => "max-width" } -%>
           <br/>
+          <br/>
+          <select name="false_positives" id="false_positives" class="withIcons">
+            <option <%= 'selected' if @false_positives=='without' -%> value="without" class="sel-without-false-positives">Without false positives</option>
+            <option <%= 'selected' if @false_positives=='only' -%> value="only" class="sel-only-false-positives">Only false positives</option>
+            <option <%= 'selected' if @false_positives=='with' -%> value="with" class="sel-with-false-positives">With false positives</option>
+          </select>
         </td>
-        <td width="1%" nowrap>
+        <td width="1%" style="padding-left: 20px" nowrap>
           <span class="note">Id</span><br/>
           <%= text_field_tag "review_id", @id, :size => 10, :onkeyup => "reviewIdFieldModified(this)" -%>
           <br/>
@@ -140,7 +147,8 @@ function launchSearch(columnName, link) {
           <td>
             <%= link_to h(review.title), :controller => "reviews", :action => "view", :id => review.id -%>
             <div class="comment-excerpt">
-              <%= image_tag("reviews/comment.png") -%> &nbsp;<b><%= comment.user.name -%> :</b> 
+              <img src="<%= ApplicationController.root_context -%>/images/reviews/<%= review.false_positive ? "false_positive" : "comment" -%>.png" title="<%= 'False positive' if review.false_positive -%>"/>
+              &nbsp;<b><%= comment.user.name -%> :</b> 
               <%= comment.excerpt -%>
                </div>            
           </td>
diff --git a/sonar-server/src/main/webapp/images/reviews/+false-positive.png b/sonar-server/src/main/webapp/images/reviews/+false-positive.png
deleted file mode 100644 (file)
index 84edfdf..0000000
Binary files a/sonar-server/src/main/webapp/images/reviews/+false-positive.png and /dev/null differ
diff --git a/sonar-server/src/main/webapp/images/reviews/+review.png b/sonar-server/src/main/webapp/images/reviews/+review.png
deleted file mode 100644 (file)
index 622e48e..0000000
Binary files a/sonar-server/src/main/webapp/images/reviews/+review.png and /dev/null differ
diff --git a/sonar-server/src/main/webapp/images/reviews/false_positive.png b/sonar-server/src/main/webapp/images/reviews/false_positive.png
new file mode 100644 (file)
index 0000000..42e6a02
Binary files /dev/null and b/sonar-server/src/main/webapp/images/reviews/false_positive.png differ
diff --git a/sonar-server/src/main/webapp/images/reviews/review.png b/sonar-server/src/main/webapp/images/reviews/review.png
deleted file mode 100644 (file)
index 3af02f4..0000000
Binary files a/sonar-server/src/main/webapp/images/reviews/review.png and /dev/null differ
diff --git a/sonar-server/src/main/webapp/images/reviews/with_false_positives.png b/sonar-server/src/main/webapp/images/reviews/with_false_positives.png
new file mode 100644 (file)
index 0000000..64e06e1
Binary files /dev/null and b/sonar-server/src/main/webapp/images/reviews/with_false_positives.png differ
index c3d24f1689f14c01357558f507c14868b676c039..3b137d5fd6a5c0a39b56f9c0fc4d34c83f0b0c5a 100644 (file)
@@ -693,6 +693,8 @@ div.vtitle{
 }
 .falsePositive {
   background-color: #FFF6BF;
+  padding-left: 5px;
+  padding-right: 5px;
 }
 div.vtitle a.action {
   color: #777;
@@ -898,11 +900,23 @@ div.discussionComment li {
   list-style: square inside;
 }
 div.comment-excerpt {
-       background-color: transparent;
-       margin-top: 5px;
-       margin-bottom: 5px;
-       color: #777777;
-       font-size: 90%;
+  background-color: transparent;
+  margin-top: 5px;
+  margin-bottom: 5px;
+  color: #777777;
+  font-size: 90%;
+}
+.max-width {
+  width: 100%;
+}
+option.sel-with-false-positives {
+  background-image: url('../images/reviews/with_false_positives.png');
+}
+option.sel-only-false-positives {
+  background-image: url('../images/reviews/false_positive.png');
+}
+option.sel-without-false-positives {
+  background-image: url('../images/reviews/comment.png');
 }