sanger/sequencescape

View on GitHub
.rubocop.yml

Summary

Maintainability
Test Coverage
inherit_from:
  - node_modules/@prettier/plugin-ruby/rubocop.yml
  - .rubocop_todo.yml
require:
  - test_prof/rubocop
  - rubocop-performance
  - rubocop-rails
  - rubocop-rspec

RSpec/AggregateExamples:
  # Aggregate examples can be useful, but the cop gets into nasty battles with
  # other Spec cops, and is only really of value in expensive tests.
  Enabled: false
# Added exclude because api and feature specs do not have a specific class.
RSpec/DescribeClass:
  Exclude:
    - "spec/requests/**/*.rb"
    - "spec/api/**/*.rb"
    - "spec/features/**/*.rb"
    - "spec/views/**/*.rb"
AllCops:
  NewCops: enable
  Exclude:
    - db/schema.rb
    - db/views_schema.rb
    - db/archived_migrations/*
    # CI installs gems in the vendor directory, which causes rubocop to try
    # and cop our gems. We don't want it to.
    - vendor/**/*
    - bin/*
    - sbin/*
    - node_modules/**/*
    - tmp/**/*

Rails/SkipsModelValidations:
  Exclude:
    - "db/migrate/*.rb"
    - "db/migrate_asset_refactor/*.rb"
    - "features/support/step_definitions/*.rb"

Style/Documentation:
  Enabled: false

Rails:
  Enabled: true
# Step definitions are defined with Given /regex/ do ...
# There is little ambiguity here, and brackets just break convention
Lint/AmbiguousRegexpLiteral:
  Exclude:
    - features/support/step_definitions/**/*
# Enforces 1234565789 as 123_456_789: While nice when dealing with actual big
# numbers, we're more likely to see it shout at us about barcodes.
Style/NumericLiterals:
  Enabled: false

# Blocks are used to structure tests and are part of the shoulda dsl.
# The standard BlockLength limits are too stringent for this purpose.
# Block DSL is also used in routes
# We should be careful keeping rake tasks here, as large tasks are still an issue.
# Not sure if we need to split namespaces across several files though.
# We exclude builders, as they are concerned with rendering xml
Metrics/BlockLength:
  Exclude:
    - Gemfile
    - "db/seeds/**/*"
    - "**/*.builder"
  CountAsOne:
    - array
    - hash
    - heredoc
  AllowedMethods:
    - describe
    - context
    - background
    - scenario
    - namespace
    - task
    - included
    - shared_context
    - shared_examples
    - shared_examples_for
    - state_machine
    - configure
    - draw
    - feature
    - subject
    - let
    - let!
    - factory
    - define
    - guard
    - transient
    - with_nested_has_many_association
    - with_association
    - it
    - class_eval
    - has_metadata
    - resources
    - aasm
    - redefine_aasm
    - model
    - step
# We have a few custom find_by methods which we maintain.
# At least for now. find_by_id_or_name is a bit clunky.
Rails/DynamicFindBy:
  Exclude:
    - "app/sample_manifest_excel/**/*"
    - "test/app/sample_manifest_excel/**/*"
  AllowedMethods:
    - find_by_sql
    - find_by_id_or_name
    - find_by_id_or_name!
    - find_by_barcode
# Method length limits make little sense when you are describing a table schema
# or a view.
Metrics/MethodLength:
  Exclude:
    - "db/migrate/*"
  CountAsOne:
    - array
    - hash
    - heredoc
Style/ClassAndModuleChildren:
  Enabled: false
Rails/UnknownEnv:
  Environments:
    - production
    - development
    - test
    - cucumber
    - profile

RSpec/ExampleLength:
  inherit_mode:
    merge:
      - Exclude
  CountAsOne:
    - array
    - hash
    - heredoc
  # Disable for features, as we might want to step through long processes
  Exclude:
    - "spec/features/**/*"

Metrics/ClassLength:
  inherit_mode:
    merge:
      - Exclude
  CountAsOne:
    - array
    - hash
    - heredoc
  # Disable for features and tests, we want lots of tests
  Exclude:
    - "spec/**/*"
    - "test/**/*"
RSpec/Rails/AvoidSetupHook:
  Exclude:
    - "test/**/*"

RSpec/MultipleExpectations:
  Exclude:
    - "spec/features/**/*"
Lint/UnusedMethodArgument:
  # Unused keyword arguments are good for maintaining API compatibility, and
  # applying an underscore before the keyword name breaks that API.
  AllowUnusedKeywordArguments: true

# This seems to be causing all sorts of issues with failing tests
Rails/RedundantPresenceValidationOnBelongsTo:
  Enabled: false

Rails/UniqueValidationWithoutIndex:
  Enabled: false

# Disabling newly introduced cops until we have time to sort out the offenses
FactoryBot/ConsistentParenthesesStyle:
  Enabled: false

Rails/I18nLocaleTexts: # new in 2.14
  Enabled: false

RSpec/Rails/InferredSpecType: # new in 2.14
  Enabled: false

Lint/NonAtomicFileOperation: # new in 1.31
  Enabled: false

Rails/ActionControllerTestCase: # new in 2.14
  Enabled: false

RSpec/NoExpectationExample: # new in 2.13
  Enabled: false

# New in ruby 3 upgrade
RSpec/IndexedLet:
  Enabled: false

RSpec/SpecFilePathFormat:
  Enabled: false

RSpec/PendingWithoutReason:
  Enabled: false

Capybara/ClickLinkOrButtonStyle:
  Enabled: false

FactoryBot/FactoryAssociationWithStrategy:
  Enabled: false

Performance/MapMethodChain:
  Enabled: false

Rails/ThreeStateBooleanColumn:
  Enabled: false

RSpec/ExpectInHook:
  Enabled: false

# New in Ruby 3.2 upgrade

Naming/BlockForwarding:
  Enabled: false

Style/ArgumentsForwarding:
  Enabled: false

Style/ArrayIntersect:
  Enabled: false

Style/EmptyMethod:
  Enabled: false

Style/HashSyntax:
  Enabled: false