diff --git a/Library/Homebrew/dev-cmd/style.rb b/Library/Homebrew/dev-cmd/style.rb index efa36925a4..7e2fcbf136 100644 --- a/Library/Homebrew/dev-cmd/style.rb +++ b/Library/Homebrew/dev-cmd/style.rb @@ -27,6 +27,8 @@ module Homebrew description: "Fix style violations automatically using RuboCop's auto-correct feature." switch "--display-cop-names", description: "Include the RuboCop cop name for each violation in the output." + switch "--reset-cache", + description: "Reset the RuboCop cache." comma_array "--only-cops", description: "Specify a comma-separated list to check for violations of only the "\ "listed RuboCop cops." @@ -51,7 +53,11 @@ module Homebrew except_cops = args.except_cops options = { - fix: args.fix?, display_cop_names: args.display_cop_names?, debug: args.debug?, verbose: args.verbose? + fix: args.fix?, + display_cop_names: args.display_cop_names?, + reset_cache: args.reset_cache?, + debug: args.debug?, + verbose: args.verbose?, } if only_cops options[:only_cops] = only_cops diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 3f10decf18..21689e5a56 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -40,6 +40,7 @@ module Homebrew fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, + reset_cache: false, debug: false, verbose: false) raise ArgumentError, "Invalid output type: #{output_type.inspect}" unless [:print, :json].include?(output_type) @@ -54,6 +55,7 @@ module Homebrew fix: fix, except_cops: except_cops, only_cops: only_cops, display_cop_names: display_cop_names, + reset_cache: reset_cache, debug: debug, verbose: verbose) end @@ -71,7 +73,7 @@ module Homebrew end def run_rubocop(files, output_type, - fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, + fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, reset_cache: false, debug: false, verbose: false) Homebrew.install_bundler_gems! require "rubocop" @@ -130,6 +132,8 @@ module Homebrew cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" } + FileUtils.rm_rf cache_env["XDG_CACHE_HOME"] if reset_cache + case output_type when :print args << "--debug" if debug diff --git a/docs/Manpage.md b/docs/Manpage.md index f8941af446..baf6700ac0 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1207,6 +1207,8 @@ including core code and all formulae. Fix style violations automatically using RuboCop's auto-correct feature. * `--display-cop-names`: Include the RuboCop cop name for each violation in the output. +* `--reset-cache`: + Reset the RuboCop cache. * `--only-cops`: Specify a comma-separated *`cops`* list to check for violations of only the listed RuboCop cops. * `--except-cops`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 3bc17a0e5d..53a8875aaa 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1662,6 +1662,10 @@ Fix style violations automatically using RuboCop\'s auto\-correct feature\. Include the RuboCop cop name for each violation in the output\. . .TP +\fB\-\-reset\-cache\fR +Reset the RuboCop cache\. +. +.TP \fB\-\-only\-cops\fR Specify a comma\-separated \fIcops\fR list to check for violations of only the listed RuboCop cops\. .