lib/brakeman/report/ignore/interactive.rb in brakeman-min-3.3.5 vs lib/brakeman/report/ignore/interactive.rb in brakeman-min-3.4.0
- old
+ new
@@ -17,10 +17,11 @@
initial_menu
@ignore_config.filter_ignored
unless @quit
+ penultimate_menu
final_menu
end
if @restart
@restart = false
@@ -63,10 +64,14 @@
m.choice "Hide previously ignored warnings" do
@skip_ignored = true
process_warnings
end
+ m.choice "Prune obsolete ignored warnings" do
+ prune_obsolete
+ end
+
m.choice "Skip - use current ignore configuration" do
@quit = true
@ignore_config.filter_ignored
end
end
@@ -99,9 +104,39 @@
HELP
"?"
end
end
+ end
+
+ def penultimate_menu
+ obsolete = @ignore_config.obsolete_fingerprints
+ return unless obsolete.any?
+
+ if obsolete.length > 1
+ plural = 's'
+ verb = 'are'
+ else
+ plural = ''
+ verb = 'is'
+ end
+
+ say "\n#{obsolete.length} fingerprint#{plural} #{verb} unused:", :green
+ obsolete.each do |obs|
+ say obs
+ end
+
+ if yes_or_no "\nRemove fingerprint#{plural}?"
+ @ignore_config.prune_obsolete
+ end
+ end
+
+ def prune_obsolete
+ @ignore_config.filter_ignored
+ obsolete = @ignore_config.obsolete_fingerprints
+ @ignore_config.prune_obsolete
+
+ say "Removed #{obsolete.length} obsolete fingerprint#{'s' if obsolete.length > 1} from ignore config.", :yellow
end
def final_menu
summarize_changes