inherit_from: .rubocop_todo.yml

require:
  - rubocop-performance
  - rubocop-rails
  - rubocop-rspec

# our custom config
# TODO: Uncomment it after fix rubocop-todo RSpec/MultipleExpectations
RSpec/DescribeClass:
  Exclude:
    - spec/requests/**/*
    - spec/system/**/*

RSpec/ExampleLength:
  Max: 10

# TODO: Uncomment it after fix rubocop-todo Metrics/LineLength
# Metrics/LineLength:
#   Description: 'Limit lines to 100 characters.'
#   Max: 100

#############################

AllCops:
  Exclude:
    - bin/**/*
    - db/schema.rb
    - db/migrate/*.rb
    - node_modules/**/*
    - tmp/**/*
  DisplayStyleGuide: true
  ExtraDetails: true
  TargetRubyVersion: 2.6

Naming/AccessorMethodName:
  Description: Check the naming of accessor methods for get_/set_.
  Enabled: false

Metrics/ClassLength:
  Description: 'Avoid classes longer than 100 lines of code.'
  Enabled: false

Metrics/ModuleLength:
  Description: 'Avoid modules longer than 100 lines of code.'
  Enabled: false

# TODO: Uncomment it after fix rubocop-todo Metrics/BlockLength
Metrics/BlockLength:
  CountComments: false # count full line comments?
  #   Max: 25
  ExcludedMethods: []
  Exclude:
    - 'spec/**/*'

Metrics/CyclomaticComplexity:
  Description: >-
    A complexity metric that is strongly correlated to the number
    of test cases needed to validate a method.
  Enabled: true
  Max: 13

Metrics/PerceivedComplexity:
  Enabled: true
  Max: 14

Metrics/MethodLength:
  Description: 'Avoid methods longer than 10 lines of code.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
  Enabled: false

Metrics/ParameterLists:
  Description: 'Avoid parameter lists longer than three or four parameters.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
  Enabled: false

Naming/PredicateName:
  Description: 'Check the names of predicate methods.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
  NamePrefixBlacklist:
    - is_
  Exclude:
    - spec/**/*

# Style

Style/AsciiComments:
  Description: 'Use only ascii symbols in comments.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
  Enabled: false

Style/CollectionMethods:
  Enabled: true
  PreferredMethods:
    find: detect
    inject: reduce
    collect: map
    find_all: select

Style/Documentation:
  Description: 'Document classes and non-namespace modules.'
  Enabled: false

Style/Encoding:
  Description: 'Use UTF-8 as the source file encoding.'
  Enabled: false

Style/FrozenStringLiteralComment:
  Description: >-
    Add the frozen_string_literal comment to the top of files
    to help transition from Ruby 2.3.0 to Ruby 3.0.
  Enabled: false

# https://github.com/rubocop-hq/rubocop/blob/master/manual/cops_style.md#stylehashsyntax
Style/HashSyntax:
  Enabled: true
  EnforcedStyle: ruby19_no_mixed_keys

Style/IfUnlessModifier:
  Description: >-
    Favor modifier if/unless usage when you have a
    single-line body.
  Enabled: false

Style/Next:
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
  Enabled: false

Style/RegexpLiteral:
  Description: 'Use / or %r around regular expressions.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
  Enabled: false

Style/SingleLineBlockParams:
  Description: 'Enforces the names of some block params.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
  Enabled: false

Style/StringLiterals:
  Description: 'Checks if uses of quotes match the configured preference.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
  EnforcedStyle: double_quotes
  Enabled: true

Style/TrailingCommaInArguments:
  Description: 'Checks for trailing comma in argument lists.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  EnforcedStyleForMultiline: comma
  Enabled: true

Style/TrailingCommaInArrayLiteral:
  Description: 'Checks for trailing comma in array literals.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  EnforcedStyleForMultiline: comma
  Enabled: true

# Layout

Layout/DotPosition:
  Description: 'Checks the position of the dot in multi-line method calls.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
  EnforcedStyle: trailing

Layout/MultilineOperationIndentation:
  Description: >-
    Checks indentation of binary operations that span more than
    one line.
  Enabled: true
  EnforcedStyle: indented

Layout/MultilineMethodCallIndentation:
  Description: >-
    Checks indentation of method calls with the dot operator
    that span more than one line.
  Enabled: true
  EnforcedStyle: indented

# Rails

Rails:
  Enabled: true

Rails/HasAndBelongsToMany:
  Description: 'Prefer has_many :through to has_and_belongs_to_many.'
  Enabled: false

Rails/HasManyOrHasOneDependent:
  Enabled: false

Rails/SkipsModelValidations:
  Enabled: false
