mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
audit: Show RuboCop offense correction status in output when --fix
is passed
This commit is contained in:
parent
0fcf8abf32
commit
b82dbdcfa8
@ -74,6 +74,7 @@ module Homebrew
|
|||||||
|
|
||||||
formula_count = 0
|
formula_count = 0
|
||||||
problem_count = 0
|
problem_count = 0
|
||||||
|
corrected_problem_count = 0
|
||||||
new_formula_problem_count = 0
|
new_formula_problem_count = 0
|
||||||
new_formula = args.new_formula?
|
new_formula = args.new_formula?
|
||||||
strict = new_formula || args.strict?
|
strict = new_formula || args.strict?
|
||||||
@ -129,6 +130,7 @@ module Homebrew
|
|||||||
formula_count += 1
|
formula_count += 1
|
||||||
problem_count += fa.problems.size
|
problem_count += fa.problems.size
|
||||||
problem_lines = format_problem_lines(fa.problems)
|
problem_lines = format_problem_lines(fa.problems)
|
||||||
|
corrected_problem_count = options[:style_offenses].count(&:corrected?)
|
||||||
new_formula_problem_lines = format_problem_lines(fa.new_formula_problems)
|
new_formula_problem_lines = format_problem_lines(fa.new_formula_problems)
|
||||||
if args.display_filename?
|
if args.display_filename?
|
||||||
puts problem_lines.map { |s| "#{f.path}: #{s}" }
|
puts problem_lines.map { |s| "#{f.path}: #{s}" }
|
||||||
@ -156,7 +158,11 @@ module Homebrew
|
|||||||
total_problems_count = problem_count + new_formula_problem_count
|
total_problems_count = problem_count + new_formula_problem_count
|
||||||
problem_plural = Formatter.pluralize(total_problems_count, "problem")
|
problem_plural = Formatter.pluralize(total_problems_count, "problem")
|
||||||
formula_plural = Formatter.pluralize(formula_count, "formula")
|
formula_plural = Formatter.pluralize(formula_count, "formula")
|
||||||
errors_summary = "#{problem_plural} in #{formula_plural}"
|
corrected_problem_plural = Formatter.pluralize(corrected_problem_count, "problem")
|
||||||
|
errors_summary = "#{problem_plural} in #{formula_plural} detected"
|
||||||
|
if corrected_problem_count.positive?
|
||||||
|
errors_summary += ", #{corrected_problem_plural} corrected"
|
||||||
|
end
|
||||||
|
|
||||||
if problem_count.positive? ||
|
if problem_count.positive? ||
|
||||||
(new_formula_problem_count.positive? && !created_pr_comment)
|
(new_formula_problem_count.positive? && !created_pr_comment)
|
||||||
|
@ -138,11 +138,19 @@ module Homebrew
|
|||||||
@severity[0].upcase
|
@severity[0].upcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def corrected?
|
||||||
|
@corrected
|
||||||
|
end
|
||||||
|
|
||||||
|
def correction_status
|
||||||
|
"[Corrected] " if corrected?
|
||||||
|
end
|
||||||
|
|
||||||
def to_s(options = {})
|
def to_s(options = {})
|
||||||
if options[:display_cop_name]
|
if options[:display_cop_name]
|
||||||
"#{severity_code}: #{location.to_short_s}: #{cop_name}: #{message}"
|
"#{severity_code}: #{location.to_short_s}: #{cop_name}: #{Tty.green}#{correction_status}#{Tty.reset}#{message}"
|
||||||
else
|
else
|
||||||
"#{severity_code}: #{location.to_short_s}: #{message}"
|
"#{severity_code}: #{location.to_short_s}: #{Tty.green}#{correction_status}#{Tty.reset}#{message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user