Skip to content

Commit

Permalink
Add --summary option
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Collins committed Jan 14, 2012
1 parent 756d9bf commit d40589c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/brakeman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module Brakeman
# * :safe_methods - array of methods to consider safe
# * :skip_libs - do not process lib/ directory (default: false)
# * :skip_checks - checks not to run (run all if not specified)
# * :summary_only - only output summary section of report
# (does not apply to tabs format)
#
#Alternatively, just supply a path as a string.
def self.run options
Expand Down
4 changes: 4 additions & 0 deletions lib/brakeman/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def get_options args, destructive = false
options[:collapse_mass_assignment] = false
end

opts.on "--summary", "Only output summary of warnings" do
options[:summary_only] = true
end

opts.on "-w",
"--confidence-level LEVEL",
["1", "2", "3"],
Expand Down
15 changes: 15 additions & 0 deletions lib/brakeman/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ def to_html
generate_overview(true).to_html << "<br/>" <<
generate_warning_overview.to_html

#Return early if only summarizing
if tracker.options[:summary_only]
return out
end

if tracker.options[:report_routes] or tracker.options[:debug]
out << "<h2>Controllers</h2>" <<
generate_controllers.to_html
Expand Down Expand Up @@ -317,6 +322,11 @@ def to_s
generate_overview.to_s << "\n" <<
generate_warning_overview.to_s << "\n"

#Return output early if only summarizing
if tracker.options[:summary_only]
return out
end

if tracker.options[:report_routes] or tracker.options[:debug]
out << "+CONTROLLERS+\n" <<
generate_controllers.to_s << "\n"
Expand Down Expand Up @@ -352,6 +362,11 @@ def to_csv
generate_overview.to_csv << "\n" <<
generate_warning_overview.to_csv << "\n"

#Return output early if only summarizing
if tracker.options[:summary_only]
return out
end

if tracker.options[:report_routes] or tracker.options[:debug]
out << "CONTROLLERS\n" <<
generate_controllers.to_csv << "\n"
Expand Down

0 comments on commit d40589c

Please sign in to comment.