audit: Use fetch with default value prevent NPE

This commit is contained in:
Gautham Goli 2018-08-27 22:37:19 +05:30
parent 771eb4f4bd
commit 5d2ca08a93
No known key found for this signature in database
GPG Key ID: 6A9ABBC284468364

View File

@ -130,7 +130,7 @@ module Homebrew
formula_count += 1
problem_count += fa.problems.size
problem_lines = format_problem_lines(fa.problems)
corrected_problem_count = options[:style_offenses]&.count(&:corrected?)
corrected_problem_count = options.fetch(:style_offenses, []).count(&:corrected?)
new_formula_problem_lines = format_problem_lines(fa.new_formula_problems)
if args.display_filename?
puts problem_lines.map { |s| "#{f.path}: #{s}" }