diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/.rubocop.yml | 117 | ||||
| -rw-r--r-- | Library/Homebrew/.rubocop.yml | 14 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/style.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/style.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/constants.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/tests.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/extend/string.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/test/Gemfile.lock | 3 |
8 files changed, 92 insertions, 66 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 12886a508..66e71027e 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -23,70 +23,94 @@ FormulaAuditStrict/ComponentsRedundancy: FormulaAudit/Homepage: Enabled: true -Metrics/AbcSize: - Enabled: false - -Metrics/BlockLength: - Enabled: false - -Metrics/ClassLength: +# `system` is a special case and aligns on second argument +Layout/AlignParameters: Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false +Layout/CaseIndentation: + EnforcedStyle: end -Metrics/LineLength: - Enabled: false +Layout/EmptyLineBetweenDefs: + AllowAdjacentOneLineDefs: true -Metrics/MethodLength: - Enabled: false +Layout/IndentArray: + EnforcedStyle: special_inside_parentheses -Metrics/ModuleLength: - CountComments: false - Exclude: - - '**/bin/**/*' - - '**/cmd/**/*' - - '**/lib/**/*' - - '**/spec/**/*' +Layout/IndentHeredoc: + EnforcedStyle: unindent -Metrics/PerceivedComplexity: +# conflicts with DSL-style path concatenation with `/` +Layout/SpaceAroundOperators: Enabled: false # favor parens-less DSL-style arguments Lint/AmbiguousOperator: Enabled: false +# so many of these in formulae and can't be autocorrected Lint/AmbiguousRegexpLiteral: Enabled: false +# favor parens-less DSL-style arguments +Lint/AmbiguousBlockAssociation: + Enabled: false + +# assignment in conditions are useful sometimes Lint/AssignmentInCondition: Enabled: false Lint/EndAlignment: EnforcedStyleAlignWith: variable +# so many of these in formulae and can't be autocorrected Lint/ParenthesesAsGroupedExpression: Enabled: false -Style/Alias: - EnforcedStyle: prefer_alias +# TODO: try to bring down all metrics maximums +Metrics/AbcSize: + Max: 250 -Style/AlignHash: - Enabled: false +Metrics/BlockLength: + Max: 1250 -# `system` is a special case and aligns on second argument -Style/AlignParameters: +Metrics/ClassLength: + Max: 1500 + +Metrics/CyclomaticComplexity: + Max: 75 + +Metrics/LineLength: + Max: 400 + +Metrics/MethodLength: + Max: 250 + +Metrics/ModuleLength: + CountComments: false + Exclude: + - '**/bin/**/*' + - '**/cmd/**/*' + - '**/lib/**/*' + +Metrics/PerceivedComplexity: + Max: 80 + +# makes code less readable for minor performance increases +Performance/Caller: Enabled: false +Style/Alias: + EnforcedStyle: prefer_alias + +Style/AutoResourceCleanup: + Enabled: true + Style/BarePercentLiterals: EnforcedStyle: percent_q Style/BlockDelimiters: EnforcedStyle: line_count_based -Style/CaseIndentation: - EnforcedStyle: end - Style/ClassAndModuleChildren: EnforcedStyle: nested @@ -99,16 +123,22 @@ Style/CommandLiteral: Style/ConditionalAssignment: Enabled: false +# most of our APIs are internal so don't require docs Style/Documentation: Enabled: false -Style/EmptyLineBetweenDefs: - AllowAdjacentOneLineDefs: true +Style/Encoding: + Enabled: true # dashes in filenames are typical Style/FileName: Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/ +# falsely flags e.g. curl formatting arguments as format strings +Style/FormatStringToken: + Enabled: false + +# so many of these in formulae and can't be autocorrected Style/GuardClause: Enabled: false @@ -121,13 +151,6 @@ Style/HashSyntax: - '**/lib/**/*' - '**/spec/**/*' -# disabled until it respects line length -Style/IfUnlessModifier: - Enabled: false - -Style/IndentArray: - EnforcedStyle: special_inside_parentheses - # only for numbers >= 1_000_000 Style/NumericLiterals: MinDigits: 7 @@ -160,13 +183,6 @@ Style/RaiseArgs: Style/RegexpLiteral: EnforcedStyle: slashes -# conflicts with DSL-style path concatenation with `/` -Style/SpaceAroundOperators: - Enabled: false - -Style/SingleLineBlockParams: - Enabled: false - # not a problem for typical shell users Style/SpecialGlobalVars: Enabled: false @@ -179,17 +195,22 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes +Style/SymbolArray: + EnforcedStyle: brackets + Style/TernaryParentheses: - Enabled: false + EnforcedStyle: require_parentheses_when_complex # makes diffs nicer Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma + Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma +# we have too many variables like sha256 where this harms readability Style/VariableNumber: Enabled: false Style/WordArray: - Enabled: false + MinSize: 4 diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 4158f9f64..26c944529 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -9,9 +9,8 @@ AllCops: - '**/Casks/**/*' - '**/vendor/**/*' -Style/BlockDelimiters: +Layout/MultilineMethodCallIndentation: Exclude: - - '**/cask/spec/**/*' - '**/*_spec.rb' # so many of these in formulae but none in here @@ -27,16 +26,13 @@ Lint/NestedMethodDefinition: Lint/ParenthesesAsGroupedExpression: Enabled: true -Metrics/ModuleLength: - CountComments: false - Exclude: - - 'cask/lib/hbc/locations.rb' - - 'cask/lib/hbc/macos.rb' - - 'cask/lib/hbc/utils.rb' - Metrics/ParameterLists: CountKeywordArgs: false +Style/BlockDelimiters: + Exclude: + - '**/*_spec.rb' + # so many of these in formulae but none in here Style/GuardClause: Enabled: true diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index 03159a0cf..97208232b 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -11,7 +11,8 @@ module Hbc def run install_rubocop - system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *rubocop_args, "--", *cask_paths) + cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" } + system(cache_env, "rubocop", *rubocop_args, "--", *cask_paths) raise CaskError, "style check failed" unless $CHILD_STATUS.success? true end diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 228aa360e..e469c47bb 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -73,7 +73,11 @@ module Homebrew args = %w[ --force-exclusion ] - args << "--auto-correct" if fix + if fix + args << "--auto-correct" + else + args << "--parallel" + end if options[:except_cops] options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") } @@ -101,14 +105,16 @@ module Homebrew args += files end + cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" } + case output_type when :print args << "--display-cop-names" if ARGV.include? "--display-cop-names" args << "--format" << "simple" if files - system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *args) + system(cache_env, "rubocop", *args) !$?.success? when :json - json, _, status = Open3.capture3({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", "--format", "json", *args) + json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args) # exit status of 1 just means violations were found; other numbers mean # execution errors. # exitstatus can also be nil if RuboCop process crashes, e.g. due to diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb index 827d5827f..4ccf18624 100644 --- a/Library/Homebrew/constants.rb +++ b/Library/Homebrew/constants.rb @@ -1,3 +1,3 @@ # RuboCop version used for `brew style` and `brew cask style` -HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.12.0".freeze # has to be updated when RuboCop version changes +HOMEBREW_RUBOCOP_VERSION = "0.49.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.13.0".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index d90326768..f434868b6 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -91,12 +91,12 @@ module Homebrew end args = ["-I", HOMEBREW_LIBRARY_PATH/"test"] - args += %w[ + args += %W[ --color --require spec_helper --format progress --format ParallelTests::RSpec::RuntimeLogger - --out tmp/parallel_runtime_rspec.log + --out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log ] args << "--seed" << ARGV.next if ARGV.include? "--seed" diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index 162666d2d..809242db9 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -2,6 +2,7 @@ class String def undent gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "") end + alias unindent undent # eg: # if foo then <<-EOS.undent_________________________________________________________72 diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock index 1f6adae93..ccfd91542 100644 --- a/Library/Homebrew/test/Gemfile.lock +++ b/Library/Homebrew/test/Gemfile.lock @@ -36,7 +36,8 @@ GEM rspec-support (3.6.0) rspec-wait (0.0.9) rspec (>= 3, < 4) - rubocop (0.48.1) + rubocop (0.49.1) + parallel (~> 1.10) parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) |
