.rubocop.yml
inherit_gem:
rubocop-rails-omakase: rubocop.yml
rswag-specs: .rubocop_rspec_alias_config.yml
# Customizations
require:
- rubocop-rake
- rubocop-rspec
- rubocop-rspec_rails
- rubocop-factory_bot
- rubocop-thread_safety
- rubocop-ordered_methods
- rubocop-capybara
AllCops:
SuggestExtensions: true
NewCops: enable
TargetRubyVersion: 3.2
ExtraDetails: true
Exclude:
- 'db/schema.rb'
- 'app/components/railsboot/**/*'
# Bundler
Bundler/OrderedGems:
Enabled: true
Bundler/GemComment:
Enabled: true
OnlyFor: [ "github", "restrictive_version_specifiers", "source", "gist", "git" ]
Bundler/InsecureProtocolSource:
Enabled: true
# FactoryBot
FactoryBot:
Enabled: true
# Layout
Layout/ClassStructure:
Enabled: true
Categories:
association:
- has_many
- has_one
attribute_macros:
- attr_accessor
- attr_reader
- attr_writer
macros:
- validates
- validate
module_inclusion:
- include
- prepend
- extend
Layout/SpaceInsideArrayLiteralBrackets:
Enabled: true
EnforcedStyle: no_space
EnforcedStyleForEmptyBrackets: no_space
# Lint
Lint/SymbolConversion:
Enabled: true
Lint/RedundantCopDisableDirective:
Enabled: true
# Metrics Cops
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Description: "Avoid modules longer than 100 lines of code."
Max: 100
Enabled: true
Metrics/ParameterLists:
Description: "Pass no more than four parameters into a method."
Max: 4
Enabled: true
# Naming
Naming/BlockForwarding:
Enabled: true
# Ordered Methods
Layout/OrderedMethods:
EnforcedStyle: alphabetical
IgnoredMethods:
- initialize
- index
- show
- new
- edit
- create
- update
- destroy
Layout/MultilineMethodCallBraceLayout:
Enabled: true
EnforcedStyle: symmetrical
#Layout/LineLength:
# Enabled: true
# Max: 120
Layout/HashAlignment:
Enabled: true
EnforcedColonStyle: key
Layout/ArrayAlignment:
Enabled: true
EnforcedStyle: with_fixed_indentation
# Rails
Rails:
Enabled: true
Rails/HasAndBelongsToMany:
Enabled: false
Rails/I18nLocaleTexts: # At some point, we should enable this cop
Enabled: false
Rails/ReversibleMigration: # I don't see a circumstance where we'd want to require reversible migrations
Enabled: false
Rails/SkipsModelValidations:
Enabled: true
Exclude:
- 'db/migrate/*active_storage*.rb' # Rails 7.2 built-in migrations use update_all, which is not reversible
# RSpec
RSpec:
Enabled: true
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/NestedGroups:
Enabled: false # This cop causes issues with RSwag
RSpec/ExampleLength:
Max: 20
Enabled: true
RSpec/MultipleExpectations:
Max: 5 # The default is 1, but we're a bit more lenient due to the nature of RSwag requests
Enabled: true
RSpec/MetadataStyle:
Enabled: false
# Security
Security/IoMethods:
Enabled: true
# Style
Style/FrozenStringLiteralComment:
Enabled: true
Style/SignalException:
Enabled: true
Style/NumericPredicate:
Enabled: true
Style/SymbolArray:
Enabled: true
Style/Lambda:
Enabled: true
Style/RedundantConstantBase:
Enabled: true
Style/GuardClause:
Enabled: true
# Performance
Performance/AncestorsInclude:
Enabled: true
Performance/ArraySemiInfiniteRangeSlice:
Enabled: true
Performance/BigDecimalWithNumericArgument:
Enabled: true
Performance/CaseWhenSplat:
Enabled: true
Performance/CollectionLiteralInLoop:
Enabled: true
MinSize: 3
Performance/IoReadlines:
Enabled: true