From 4498303f9a347184d9fc0bb6e93351bbfc4d1091 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 13 Mar 2020 21:14:24 +0000 Subject: [PATCH] rubocop: adjust rules. --- Library/.rubocop.yml | 31 ++++++++++------------------- Library/Homebrew/.rubocop.yml | 4 ++++ Library/Homebrew/formula_creator.rb | 6 +++--- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index b9bae1ea7c..63c34b2e15 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -21,10 +21,6 @@ Layout/HashAlignment: Layout/ArgumentAlignment: Enabled: false -# favour parens-less DSL-style arguments -Lint/AmbiguousOperator: - Enabled: false - # this is a bit less "floaty" Layout/CaseIndentation: EnforcedStyle: end @@ -37,8 +33,7 @@ Layout/EndAlignment: Layout/SpaceAroundOperators: Enabled: false -# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6258) -# and layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254). +# layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254). Layout/RescueEnsureAlignment: Enabled: false @@ -51,15 +46,6 @@ Lint/AmbiguousBlockAssociation: Lint/AmbiguousRegexpLiteral: Enabled: false -# assignment in conditions are useful sometimes -# TODO: add parentheses for these and remove -Lint/AssignmentInCondition: - Enabled: false - -# we output how to use interpolated strings too often -Lint/InterpolationCheck: - Enabled: false - # so many of these in formulae and can't be autocorrected Lint/ParenthesesAsGroupedExpression: Enabled: false @@ -84,11 +70,6 @@ Layout/LineLength: # ignore manpage comments and long single-line strings IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options :'] -# our current conditional style is established -# TODO: enable this when possible -Style/ConditionalAssignment: - Enabled: false - # most of our APIs are internal so don't require docs Style/Documentation: Enabled: false @@ -97,7 +78,7 @@ Style/Documentation: Style/FrozenStringLiteralComment: Enabled: false -# so many of these in formulae and can't be autocorrected +# potential for errors in formulae too high with this Style/GuardClause: Enabled: false @@ -110,6 +91,14 @@ Style/HashSyntax: - '**/lib/**/*.rb' - '**/spec/**/*.rb' +# autocorrectable and more readable +Style/HashEachMethods: + Enabled: true +Style/HashTransformKeys: + Enabled: true +Style/HashTransformValues: + Enabled: true + # ruby style guide favorite Style/StringLiterals: EnforcedStyle: double_quotes diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 6635212f3d..36836fb781 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -22,6 +22,10 @@ Layout/MultilineMethodCallIndentation: Lint/AmbiguousRegexpLiteral: Enabled: true +# TODO: add parentheses for these and remove +Lint/AssignmentInCondition: + Enabled: false + # `formula do` uses nested method definitions Lint/NestedMethodDefinition: Exclude: diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 53777d1e09..3e4c8aeb96 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -27,10 +27,10 @@ module Homebrew end end update_path - if @version - @version = Version.create(@version) + @version = if @version + Version.create(@version) else - @version = Version.detect(url, {}) + Version.detect(url, {}) end end