From 0a188984259a7e70c2a0a8e61e691ea2496b2e8a Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 3 Mar 2023 22:25:29 +0000 Subject: [PATCH 1/4] rubocop: Move `AllowedMethods` inheritance to the cop it's used in - `Include` and `Exclude` are ubiquitous but `AllowedMethods` less so. - Move the inheritance to the single cop configuration that it's used in. Like we do with some other cop configs where they have default paths/settings that we want to add to, not replace. --- Library/.rubocop.yml | 1 - Library/Homebrew/.rubocop.yml | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index d728e027ce..3aa895169c 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -10,7 +10,6 @@ inherit_mode: merge: - Include - Exclude - - AllowedMethods AllCops: TargetRubyVersion: 2.6 diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 48edd4d332..fa1069dab4 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -16,6 +16,9 @@ Layout/MultilineMethodCallIndentation: - "**/*_spec.rb" Naming/PredicateName: + inherit_mode: + merge: + - AllowedMethods AllowedMethods: - is_32_bit? - is_64_bit? From 87b94d935877f59cbd915ee46636fd0185d53f4b Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 3 Mar 2023 22:32:15 +0000 Subject: [PATCH 2/4] rubocop: Trim `Style/BlockDelimiters` exclude paths without offenses --- Library/.rubocop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 3aa895169c..89e780ab37 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -341,7 +341,6 @@ Style/BlockDelimiters: - "sig" Exclude: - "Homebrew/**/*_spec.rb" - - "Homebrew/**/shared_examples/**/*.rb" # TODO: remove this when possible. Style/ClassVars: From f2e21d5c1eae8934a8222d2476654dc5fda99910 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 3 Mar 2023 23:27:05 +0000 Subject: [PATCH 3/4] rubocop: In-line disables for `Style/{Class,Global}Vars` - Other occurrences of `@@` and `$` variables are individually disabled in-line in other files. - So let's follow the same pattern for Homebrew/homebrew-cask developer scripts, since there are only a few. --- Library/.rubocop.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 89e780ab37..3e9a7a46c6 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -342,11 +342,6 @@ Style/BlockDelimiters: Exclude: - "Homebrew/**/*_spec.rb" -# TODO: remove this when possible. -Style/ClassVars: - Exclude: - - "**/developer/bin/*" - # Use consistent style for better readability. Style/CollectionMethods: Enabled: true @@ -386,11 +381,6 @@ Style/FrozenStringLiteralComment: - "**/*.rbi" - "**/Brewfile" -# TODO: remove this when possible. -Style/GlobalVars: - Exclude: - - "**/developer/bin/*" - # potential for errors in formulae too high with this Style/GuardClause: Exclude: From 72a694d9cb45089d903bd709a212d4623f144c4e Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 3 Mar 2023 23:33:38 +0000 Subject: [PATCH 4/4] rubocop: Further alphabetization, M comes before N --- Library/.rubocop.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 3e9a7a46c6..b748ea063e 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -395,6 +395,10 @@ Style/HashAsLastArrayItem: - "/**/Formula/**/*.rb" - "**/Formula/**/*.rb" +# would rather freeze too much than too little +Style/MutableConstant: + EnforcedStyle: strict + # Zero-prefixed octal literals are widely used and understood. Style/NumericLiteralPrefix: EnforcedOctalStyle: zero_only @@ -471,7 +475,3 @@ Style/UnlessLogicalOperators: # a bit confusing to non-Rubyists but useful for longer arrays Style/WordArray: MinSize: 4 - -# would rather freeze too much than too little -Style/MutableConstant: - EnforcedStyle: strict