}
protected String generateUpdateToReopenResolvedReviewsForNonFixedViolation(int resourceId) {
- return "UPDATE reviews SET status='REOPENED', updated_at=CURRENT_TIMESTAMP WHERE status='RESOLVED' AND resource_id = " + resourceId;
+ return "UPDATE reviews SET status='REOPENED', resolution=NULL, updated_at=CURRENT_TIMESTAMP WHERE status='RESOLVED' AND resource_id = " + resourceId;
}
protected String generateUpdateToCloseReviewsForDeletedResources(int projectId, int projectSnapshotId) {
rule_id="1" failure_level="1"/>
<!-- Existing reviews -->
+ <!-- Note that DbUnit uses the first tag for a table to define the columns to be populated. So that's why "resolution" column here. -->
<reviews
id="1"
status="OPEN"
rule_failure_permanent_id="1"
+ resolution="[null]"
resource_id="555"/>
<reviews
id="2"
<reviews
id="6"
status="RESOLVED"
+ resolution="FIXED"
rule_failure_permanent_id="3"
resource_id="666"/>
<reviews
<reviews
id="8"
status="RESOLVED"
+ resolution="FIXED"
rule_failure_permanent_id="2"
resource_id="666"/>
status="OPEN"
rule_failure_permanent_id="1"
resource_id="555"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="2"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="3"
status="OPEN"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="4"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="5"
status="REOPENED"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="6"
status="RESOLVED"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="FIXED" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="7"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="8"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="FIXED" severity="[null]" resource_line="[null]" project_id="[null]"/>
</dataset>
\ No newline at end of file
status="OPEN"
rule_failure_permanent_id="1"
resource_id="555"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="2"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="3"
status="OPEN"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="4"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="5"
status="REOPENED"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="6"
status="REOPENED"
rule_failure_permanent_id="3"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="7"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
<reviews
id="8"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]" project_id="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="FIXED" severity="[null]" resource_line="[null]" project_id="[null]"/>
</dataset>
\ No newline at end of file
rule_failure_permanent_id="1"
resource_id="555"
project_id="1"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]"/>
<!-- Following must have been deleted
<reviews
rule_failure_permanent_id="2"
resource_id="666"
project_id="2"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]"/>
-->
<review_comments
rule_failure_permanent_id="1"
resource_id="555"
project_id="1"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]"/>
<reviews
id="2"
status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
project_id="2"
- created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" false_positive="[null]" severity="[null]" resource_line="[null]"/>
+ created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" resolution="[null]" severity="[null]" resource_line="[null]"/>
<review_comments
id="1"
end
end
create_comment(:user => params[:user], :text => params[:text])
- self.false_positive = is_false_positive
self.assignee = nil
- self.status = STATUS_OPEN
- self.save!
+ self.status = is_false_positive ? STATUS_RESOLVED : STATUS_REOPENED
+ self.resolution = is_false_positive ? 'FALSE-POSITIVE' : nil
+ self.save!
end
end
+ def false_positive
+ resolution == 'FALSE-POSITIVE'
+ end
+
+ def can_change_false_positive_flag?
+ (status == STATUS_RESOLVED && resolution == 'FALSE-POSITIVE') || status == STATUS_OPEN || status == STATUS_REOPENED
+ end
+
def isResolved?
status == STATUS_RESOLVED
end
def reopen
self.status = STATUS_REOPENED
+ self.resolution = nil
self.save!
end
def resolve
self.status = STATUS_RESOLVED
+ self.resolution = 'FIXED'
self.save!
end
# Following code just for backward compatibility
review_type = options['review_type']
if review_type
- conditions << 'false_positive=:false_positive'
if review_type == 'FALSE_POSITIVE'
- values[:false_positive]=true
+ conditions << "resolution='FALSE-POSITIVE'"
else
- values[:false_positive]=false
+ conditions << "(resolution<>'FALSE-POSITIVE' OR resolution IS NULL)"
end
end
# --- End of code for backward compatibility code ---
false_positives = options['false_positives']
if false_positives == "only"
- conditions << 'false_positive=:false_positive'
- values[:false_positive]=true
+ conditions << "resolution='FALSE-POSITIVE'"
elsif false_positives == "without"
- conditions << 'false_positive=:false_positive'
- values[:false_positive]=false
+ conditions << "(resolution<>'FALSE-POSITIVE' OR resolution IS NULL)"
end
ids=options['ids'].split(',') if options['ids']
<% end %>
- <% unless violation.review && violation.review.isResolved? %>
+ <% if violation.review && violation.review.can_change_false_positive_flag? %>
<%= link_to_remote (violation.switched_off? ? "Unflag as false-positive" : "Flag as false-positive"),
:url => { :controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.switched_off? },
:update => "reviewForm" + violation.id.to_s,
<% end %>
<% end %>
- <% unless review.isResolved? %>
+ <% if review.can_change_false_positive_flag? %>
<%= link_to_remote (violation_switched_off ? "Unflag as false-positive" : "Flag as false-positive"),
:url => { :controller => "reviews", :action => "false_positive_form", :id => review.id, :false_positive => !violation_switched_off },
:update => "reviewForm",
class ChangeFalsePositiveOnReviews < ActiveRecord::Migration
def self.up
- add_column 'reviews', 'false_positive', :boolean, :null => true, :default => false
+ add_column 'reviews', 'resolution', :string, :limit => 200, :null => true
Review.reset_column_information
-
+
Review.find(:all).each do |review|
- review.false_positive= (review.review_type == 'FALSE_POSITIVE')
+ if review.review_type == 'FALSE_POSITIVE'
+ review.status = 'RESOLVED'
+ review.resolution = 'FALSE-POSITIVE'
+ end
review.save!
end
-
+
remove_column 'reviews', 'review_type'
Review.reset_column_information
end
PROJECT_ID INTEGER,
RESOURCE_ID INTEGER,
RESOURCE_LINE INTEGER,
- FALSE_POSITIVE SMALLINT,
+ RESOLUTION VARCHAR(200),
primary key (id)
);