# TODO: Try getting more rules in sync.

require: ./Homebrew/rubocops.rb

AllCops:
  TargetRubyVersion: 2.6
  DisplayCopNames: false

# Use `<<~` for heredocs.
Layout/HeredocIndentation:
  Enabled: true

# Not useful in casks and formulae.
Metrics/BlockLength:
  Enabled: false

# Keyword arguments don't have the same readability
# problems as normal parameters.
Metrics/ParameterLists:
  CountKeywordArgs: false

# Implicitly allow EOS as we use it everywhere.
Naming/HeredocDelimiterNaming:
  ForbiddenDelimiters:
    - END, EOD, EOF

# Allow dashes in filenames.
Naming/FileName:
  Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/

# Both styles are used depending on context,
# e.g. `sha256` and `something_countable_1`.
Naming/VariableNumber:
  Enabled: false

# Avoid leaking resources.
Style/AutoResourceCleanup:
  Enabled: true

# This makes these a little more obvious.
Style/BarePercentLiterals:
  EnforcedStyle: percent_q

# Use consistent style for better readability.
Style/CollectionMethods:
  Enabled: true

# Prefer tokens with type annotations for consistency
# between formatting numbers and strings.
Style/FormatStringToken:
  EnforcedStyle: annotated

# autocorrectable and more readable
Style/HashEachMethods:
  Enabled: true
Style/HashTransformKeys:
  Enabled: true
Style/HashTransformValues:
  Enabled: true

# Enabled now LineLength is lowish.
Style/IfUnlessModifier:
  Enabled: true

# Only use this for numbers >= `1_000_000`.
Style/NumericLiterals:
  MinDigits: 7
  Strict: true

# Zero-prefixed octal literals are widely used and understood.
Style/NumericLiteralPrefix:
  EnforcedOctalStyle: zero_only

# Rescuing `StandardError` is an understood default.
Style/RescueStandardError:
  EnforcedStyle: implicit

# Returning `nil` is unnecessary.
Style/ReturnNil:
  Enabled: true

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

# Use consistent method names.
Style/StringMethods:
  Enabled: true

# An array of symbols is more readable than a symbol array
# and also allows for easier grepping.
Style/SymbolArray:
  EnforcedStyle: brackets

# Trailing commas make diffs nicer.
Style/TrailingCommaInArguments:
  EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
  EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
  EnforcedStyleForMultiline: comma

# Does not hinder readability, so might as well enable it.
Performance/CaseWhenSplat:
  Enabled: true

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