require:
  - rubocop-factory_bot
  - rubocop-graphql
  - rubocop-performance
  - rubocop-rake
  - rubocop-rails
  - rubocop-rspec

AllCops:
  Exclude:
    - bin/*
    - db/schema.rb
    - db/data_schema.rb
    - vendor/bundle/**/*
  NewCops: enable
  TargetRubyVersion: 3.1

# GraphQL

GraphQL/ExtractInputType:
  Enabled: false

GraphQL/ExtractType:
  Enabled: false

GraphQL/FieldMethod:
  Enabled: false

GraphQL/ObjectDescription:
  Enabled: false

# Layout

Layout/ClassStructure:
  Categories:
    associations:
      - belongs_to
      - has_one
      - has_many
      - has_and_belongs_to_many
    attributes:
      - attr_accessor
      - attr_reader
      - attr_writer
      - attr_accessible
      - attribute
    callbacks:
      - before_validation
      - after_validation
      - before_save
      - around_save
      - before_create
      - around_create
      - after_create
      - after_save
      - after_commit
    encryption:
      - encrypts
    macros:
      - accepts_nested_attributes_for
      - acts_as_sequenced
      - counter_culture
      - has_secure_token
    module_inclusion:
      - include
      - prepend
      - extend
    money:
      - monetize
    platform_prices:
      - expose_financials
      - platform_discounts
      - platform_price
      - platform_resource_key
      - platform_shipping
      - platform_tax
    scopes:
      - default_scope
      - scope
    serialisation:
      - serialize
    state_machine:
      - aasm
    validations:
      - validate
      - validates
      - validates_each
    versioning:
      - has_paper_trail
  ExpectedOrder:
    - module_inclusion
    - constants
    - scopes
    - public_constants
    - public_attributes
    - enum
    - serialisation
    - encryption
    - associations
    - validations
    - delegate
    - callbacks
    - platform_prices
    - money
    - versioning
    - macros
    - state_machine
    - public_class_methods
    - initializer
    - public_methods
    - protected_methods
    - private_constants
    - private_attributes
    - private_methods
  Enabled: true

Layout/EmptyLinesAroundClassBody:
  Enabled: true
  EnforcedStyle: empty_lines

Layout/EmptyLinesAroundModuleBody:
  Enabled: true
  EnforcedStyle: empty_lines_except_namespace

Layout/IndentationConsistency:
  Enabled: true
  EnforcedStyle: normal

Layout/LineEndStringConcatenationIndentation:
  Enabled: false

Layout/LineLength:
  AllowedPatterns:
    - VCR.use_cassette
  Enabled: true
  Exclude:
    - app/graphql/**/*
    - app/types/platform_types.rb
    - db/migrate/*
  Max: 120

Layout/MultilineMethodCallIndentation:
  Enabled: true
  EnforcedStyle: indented

# Metrics

Metrics/AbcSize:
  Max: 35
  Exclude:
    - db/data/*.rb

Metrics/BlockLength:
  AllowedMethods:
    - class_methods
    - context
    - describe
    - expects
    - factory
    - it
    - mutation
    - namespace
    - parse
    - promises
    - routes.draw
    - shared_examples
    - use_cassette
  CountAsOne:
    - array
    - hash
    - heredoc
  CountComments: false
  Enabled: true
  Exclude:
    - config/**/*
    - Gemfile

Metrics/ClassLength:
  CountAsOne:
    - array
    - hash
    - heredoc
  CountComments: false
  Enabled: true
  Max: 200

Metrics/CyclomaticComplexity:
  Max: 10

Metrics/MethodLength:
  CountAsOne:
    - array
    - hash
    - heredoc
  CountComments: false
  Enabled: true
  Max: 20
  Exclude:
    - db/data/*.rb
    - db/migrate/*.rb

Metrics/ModuleLength:
  CountAsOne:
    - array
    - hash
    - heredoc
  CountComments: false
  Enabled: true
  Max: 200

# Naming

Naming/VariableNumber:
  AllowedIdentifiers:
    - address1
    - address2
    - alpha2
    - alpha3
    - street1
    - street2
  CheckSymbols: true
  Enabled: true
  EnforcedStyle: snake_case
  Exclude:
    - app/graphql/types/**/*.rb
    - spec/factories/**/*.rb
    - spec/requests/**/*.rb

# RSpec

RSpec/ExampleLength:
  CountAsOne:
    - array
    - hash
    - heredoc
  Max: 20

RSpec/IndexedLet:
  Enabled: false

RSpec/LetSetup:
  Enabled: false

RSpec/MultipleMemoizedHelpers:
  AllowSubject: true
  Enabled: true
  Max: 20

RSpec/NamedSubject:
  Enabled: false

RSpec/NestedGroups:
  Max: 5

RSpec/MultipleExpectations:
  Max: 10

# Style

Style/Documentation:
  Enabled: false

RSpec/ImplicitSubject:
  EnforcedStyle: single_statement_only

Style/MultilineIfModifier:
  Enabled: false

Style/NegatedIf:
  EnforcedStyle: postfix

Style/NumericLiterals:
  AllowedPatterns:
    - \d{10,}
  Enabled: true
  Strict: false