.rubocop.yml
# This configuration only includes the cops that differ from the Rubocop
# defaults, which can be found here:
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
# https://github.com/bbatsov/rubocop/blob/master/config/disabled.yml
require:
- rubocop-rails
- rubocop-rspec
AllCops:
Exclude:
- 'bin/**/*'
- 'db/**/*'
- 'spec/i18n_spec.rb'
- 'config/application.rb'
- 'config/boot.rb'
- 'config/deploy.rb'
- 'config/initializers/backtrace_silencers.rb'
- 'config/initializers/content_security_policy.rb'
- 'config/initializers/devise.rb'
- 'config/puma.rb'
- 'db/migrate/*'
- '**/Capfile'
- 'tmp/**/*'
- 'vendor/**/*'
- 'public/**/*'
- 'node_modules/**/*'
TargetRubyVersion: <%= File.read(File.join(__dir__, '.ruby-version')).strip %>
TargetRailsVersion: 7.1
UseCache: true
DisabledByDefault: true
SuggestExtensions: false
Rails:
Enabled: false
Layout/ParameterAlignment:
# Alignment of parameters in multi-line method calls.
#
# The `with_first_parameter` style aligns the following lines along the same
# column as the first parameter.
#
# method_call(a,
# b)
#
# The `with_fixed_indentation` style aligns the following lines with one
# level of indentation relative to the start of the line with the method call.
#
# method_call(a,
# b)
Description: >-
Align the parameters of a method call if they span more
than one line.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
EnforcedStyle: with_first_parameter
SupportedStyles:
- with_first_parameter
- with_fixed_indentation
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~
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
SupportedStyles:
- leading
- trailing
Layout/ExtraSpacing:
# When true, allows most uses of extra spacing if the intent is to align
# things with the previous or next line, not counting empty lines or comment
# lines.
AllowForAlignment: true
# When true, forces the alignment of = in assignments on consecutive lines.
ForceEqualSignAlignment: false
# Checks the indentation of the first element in an array literal.
Layout/FirstArrayElementIndentation:
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
# to the first position inside the parenthesis.
#
# The value `consistent` means that the indentation of the first element shall
# always be relative to the first position of the line where the opening
# bracket is.
#
# The value `align_brackets` means that the indentation of the first element
# shall always be relative to the position of the opening bracket.
EnforcedStyle: special_inside_parentheses
SupportedStyles:
- special_inside_parentheses
- consistent
- align_brackets
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~
Layout/MultilineOperationIndentation:
EnforcedStyle: aligned
SupportedStyles:
- aligned
- indented
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~
Lint/PercentStringArray:
Enabled: true
Exclude:
- 'config/initializers/secure_headers.rb'
Metrics/BlockLength:
CountComments: false # count full line comments?
Enabled: true
Max: 25
Exclude:
- 'spec/**/*.rb'
- 'config/routes.rb'
Layout/LineLength:
Description: Limit lines to 100 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
Enabled: true
Max: 100
AllowURI: true
URISchemes:
- http
- https
Exclude:
- 'config/routes.rb'
Metrics/ModuleLength:
CountComments: false
Max: 200
Description: Avoid modules longer than 100 lines of code.
Enabled: true
Exclude:
- spec/**/*
Rails/HttpPositionalArguments:
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
Enabled: true
Include:
- 'spec/**/*'
- 'test/**/*'
Rails/TimeZone:
# The value `strict` means that `Time` should be used with `zone`.
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
Enabled: true
EnforcedStyle: strict
SupportedStyles:
- strict
- flexible
Style/AndOr:
Description: Use &&/|| instead of and/or.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
EnforcedStyle: conditionals
SupportedStyles:
- always
- conditionals
# Warn on empty else statements
# empty - warn only on empty else
# nil - warn on else with nil in it
# both - warn on empty else and else with nil in it
Style/EmptyElse:
EnforcedStyle: both
SupportedStyles:
- empty
- nil
- both
Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: true
Style/PercentLiteralDelimiters:
# Specify the default preferred delimiter for all types with the 'default' key
# Override individual delimiters (even with default specified) by specifying
# an individual key
PreferredDelimiters:
default: ()
'%i': '[]'
'%I': '[]'
'%r': '{}'
'%w': '[]'
'%W': '[]'
Style/StringLiterals:
Description: Checks if uses of quotes match the configured preference.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
ConsistentQuotesInMultiline: true
Style/TrailingCommaInArguments:
# If `comma`, the cop requires a comma after the last argument, but only for
# parenthesized method calls where each argument is on its own line.
# If `consistent_comma`, the cop requires a comma after the last argument,
# for all parenthesized method calls with arguments.
EnforcedStyleForMultiline: comma
SupportedStylesForMultiline:
- comma
- consistent_comma
- no_comma
Style/TrailingCommaInArrayLiteral:
# If `comma`, the cop requires a comma after the last item in an array or
# hash, but only when each item is on its own line.
# If `consistent_comma`, the cop requires a comma after the last item of all
# non-empty array and hash literals.
EnforcedStyleForMultiline: comma
SupportedStylesForMultiline:
- comma
- consistent_comma
- no_comma
Style/TrailingCommaInHashLiteral:
# If `comma`, the cop requires a comma after the last item in an array or
# hash, but only when each item is on its own line.
# If `consistent_comma`, the cop requires a comma after the last item of all
# non-empty array and hash literals.
EnforcedStyleForMultiline: comma
SupportedStylesForMultiline:
- comma
- consistent_comma
- no_comma
Lint/AmbiguousAssignment:
Enabled: true
Style/HashExcept:
Enabled: true
Lint/DeprecatedConstants:
Enabled: true
Style/NilLambda:
Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
Enabled: true
Style/ArgumentsForwarding:
Enabled: false
Style/ClassEqualityComparison:
Enabled: true
Lint/UselessTimes:
Enabled: true
Layout/BeginEndAlignment:
Enabled: true
Lint/ConstantDefinitionInBlock:
Enabled: true
Lint/IdentityComparison:
Enabled: true
Bundler/DuplicatedGem:
Enabled: true
Naming/BinaryOperatorParameterName:
Enabled: true
Style/KeywordParametersOrder:
Enabled: true
Lint/DuplicateRequire:
Enabled: true
Lint/TrailingCommaInAttributeDeclaration:
Enabled: true
Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Lint/DuplicateRescueException:
Enabled: true
Lint/FloatComparison:
Enabled: true
Lint/OutOfRangeRegexpRef:
Enabled: true
Lint/RedundantRequireStatement:
Enabled: true
Lint/RedundantSplatExpansion:
Enabled: true
Lint/SafeNavigationWithEmpty:
Enabled: true
Lint/SelfAssignment:
Enabled: true
Lint/TopLevelReturnWithArgument:
Enabled: true
Style/RedundantAssignment:
Enabled: true
Style/RedundantFetchBlock:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Lint/MixedRegexpCaptureTypes:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Style/RedundantRegexpCharacterClass:
Enabled: true
Style/RedundantRegexpEscape:
Enabled: true