diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 2a7f370310341b9284676f0f56f1d82f0482d570..d89c9b72f50054b818e7ed68ac04d37884707583 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -15,6 +15,8 @@ require "utils" require "json" +require "rubocop" +require_relative "../rubocops" module Homebrew module_function @@ -54,6 +56,10 @@ module Homebrew ] args << "--auto-correct" if fix + if options[:only] + args << "--only" << RuboCop::Cop::Cop.registry.with_department(options[:only]).names.join(" ") + end + if files.nil? args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" args += [HOMEBREW_LIBRARY_PATH] diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index be53e1d6fd80f4d0b3e279a3c82e2728488e0b48..2f4b37096ec93d8c739e97e3036e76ab431bf3c4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -75,9 +75,14 @@ module Homebrew style_results = check_style_json(files, options) end + if !strict + options = { fix: ARGV.flag?("--fix"), realpath: true, only: :Homebrew } + style_results = check_style_json(files, options) + end + ff.each do |f| options = { new_formula: new_formula, strict: strict, online: online } - options[:style_offenses] = style_results.file_offenses(f.path) if strict + options[:style_offenses] = style_results.file_offenses(f.path) fa = FormulaAuditor.new(f, options) fa.audit