Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate RuboCop config. #5316

Merged
merged 3 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
144 changes: 0 additions & 144 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,11 @@ Layout/CaseIndentation:
# this is a bit less "floaty"
Layout/EndAlignment:
EnforcedStyleAlignWith: start_of_line
Exclude:
- '**/Casks/**/*'

# enforce use of <<~EOS
Layout/IndentHeredoc:
EnforcedStyle: squiggly

# conflicts with DSL-style path concatenation with `/`
Layout/SpaceAroundOperators:
Enabled: false

# use spaces for indentation; detect tabs
Layout/Tab:
Enabled: true

# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6300).
Layout/EmptyLineAfterGuardClause:
Enabled: false
Expand Down Expand Up @@ -81,8 +71,6 @@ Lint/ParenthesesAsGroupedExpression:
# most metrics don't make sense to apply for formulae/taps
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Expand All @@ -94,52 +82,11 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Enabled: false

# keyword arguments don't have the same readability problems
Metrics/ParameterLists:
CountKeywordArgs: false

# GitHub diff UI wraps beyond 118 characters (so that's the goal)
Metrics/LineLength:
Max: 170
# ignore manpage comments and long single-line strings
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options :']
Exclude:
- '**/Casks/**/*'

# dashes in filenames are typical
Naming/FileName:
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
Exclude:
- '**/Casks/**/*'

# implicitly allow EOS as we use it everywhere
Naming/HeredocDelimiterNaming:
Blacklist:
- END, EOD, EOF

# we have too many variables like sha256 where this harms readability
Naming/VariableNumber:
Enabled: false

# makes code less readable for minor performance increases
Performance/Caller:
Enabled: false

# we're doing this already so why not
Performance/CaseWhenSplat:
Enabled: true

# enable to avoid leaking resources
Style/AutoResourceCleanup:
Enabled: true

# this is a little more obvious what's going on
Style/BarePercentLiterals:
EnforcedStyle: percent_q

# consistency helps readability and helps people who don't know Ruby
Style/CollectionMethods:
Enabled: true

# our current conditional style is established
# TODO: enable this when possible
Expand All @@ -150,14 +97,6 @@ Style/ConditionalAssignment:
Style/Documentation:
Enabled: false

# we don't need UTF-8 encoding comments
Style/Encoding:
Enabled: true

# falsely flags e.g. curl formatting arguments as format strings
Style/FormatStringToken:
EnforcedStyle: template

# we want to add this slowly and manually
# TODO: add to more files
Style/FrozenStringLiteralComment:
Expand All @@ -170,106 +109,23 @@ Style/GuardClause:
# depends_on a: :b looks weird in formulae.
Style/HashSyntax:
EnforcedStyle: hash_rockets
Exclude:
- '**/bin/**/*'
- '**/cmd/**/*'
- '**/lib/**/*'
- '**/spec/**/*'
- '**/Casks/**/*'

# this doesn't make sense for wide lines below maximum line length
# https://github.com/rubocop-hq/rubocop/issues/6149
Style/IfUnlessModifier:
Enabled: false

# only for numbers >= 1_000_000
Style/NumericLiterals:
MinDigits: 7

# zero-prefixed octal literals are just too widely used (and understood)
Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only

# rescuing StandardError is an understood default
Style/RescueStandardError:
EnforcedStyle: implicit

# return nil is unnecessary and a common mistake believing it's required
Style/ReturnNil:
Enabled: true

# We have no use for using `warn` because we are
# calling Ruby with warnings disabled ourselves (for now).
Style/StderrPuts:
Enabled: false

# ruby style guide favorite
Style/StringLiterals:
EnforcedStyle: double_quotes
Exclude:
- '**/Casks/**/*'

# consistency with above
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
Exclude:
- '**/Casks/**/*'

# consistency helps readability and helps people who don't know Ruby
Style/StringMethods:
Enabled: true

# less confusing to non-Rubyists
Style/SymbolArray:
EnforcedStyle: brackets

# make things a bit easier to read
Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex
Exclude:
- '**/Casks/**/*'

# messes with existing plist/caveats style
Style/TrailingBodyOnMethodDefinition:
Enabled: false

# all trailing commas make diffs nicer
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma

# a bit confusing to non-Rubyists but useful for longer arrays
Style/WordArray:
MinSize: 4
Exclude:
- '**/Casks/**/*'

# exclude some styles for casks (for now)
# TODO: make Homebrew/brew, casks and formulae more consistent
Layout/ElseAlignment:
Exclude:
- '**/Casks/**/*'
Layout/IndentArray:
Exclude:
- '**/Casks/**/*'
Layout/IndentHash:
Exclude:
- '**/Casks/**/*'
Layout/IndentationWidth:
Exclude:
- '**/Casks/**/*'
Performance/StringReplacement:
Exclude:
- '**/Casks/**/*'
Style/EmptyElse:
Exclude:
- '**/Casks/**/*'
Style/PercentLiteralDelimiters:
Exclude:
- '**/Casks/**/*'
Style/RegexpLiteral:
Exclude:
- '**/Casks/**/*'
61 changes: 14 additions & 47 deletions Library/.rubocop_cask.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
inherit_from: ./.rubocop_shared.yml

# Cask Cops

Cask/HomepageMatchesUrl:
Description: 'Ensure that the homepage and url match, otherwise add a comment. More info at https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'
Enabled: true
Expand All @@ -22,8 +20,6 @@ Cask/StanzaOrder:
Description: 'Ensure that cask stanzas are sorted correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/master/CONTRIBUTING.md#stanza-order'
Enabled: true

# Built-In Cops

Layout/AlignHash:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
Expand All @@ -34,63 +30,34 @@ Layout/IndentArray:
Layout/IndentHash:
EnforcedStyle: align_braces

Metrics/BlockLength:
Enabled: false

# Casks often contain long URLs and file paths.
Metrics/LineLength:
Enabled: false

Naming/FileName:
Enabled: false

Naming/HeredocDelimiterNaming:
Blacklist:
- END, EOD, EOF

Performance/StringReplacement:
Enabled: false

Style/BarePercentLiterals:
EnforcedStyle: percent_q

# Casks don't need documentation.
Style/Documentation:
Enabled: false

Style/EmptyElse:
Enabled: false

# These would only be distracting in casks.
Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: never

# Don't use hash rockets.
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys

Style/IfUnlessModifier:
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'
'%i': '{}'
'%q': '{}'
'%Q': '{}'
'%r': '{}'
'%s': '()'
'%w': '[]'
'%W': '[]'
'%x': '()'

# This is more readable when the regex contains slashes.
Style/RegexpLiteral:
EnforcedStyle: percent_r

Style/SymbolArray:
# Use consistent style for all arrays.
Style/WordArray:
EnforcedStyle: brackets

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
# This makes multi-line arrays more readable and alignable.
Layout/FirstArrayElementLineBreak:
Enabled: true

Style/WordArray:
EnforcedStyle: brackets
# This makes multi-line hashes more readable and alignable.
Layout/FirstHashElementLineBreak:
Enabled: true