Skip to content

Instantly share code, notes, and snippets.

@andrewfoster73
Created June 7, 2022 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewfoster73/78f732ed2785250537677088716c131a to your computer and use it in GitHub Desktop.
Save andrewfoster73/78f732ed2785250537677088716c131a to your computer and use it in GitHub Desktop.
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
inherit_from:
- '.rubocop-rails.yml'
require:
- rubocop-performance
- rubocop-rails
AllCops:
TargetRubyVersion: 3.0
TargetRailsVersion: 7.0
Exclude:
- '**/db/migrate/*'
- '**/Gemfile.lock'
- '**/Rakefile'
- '**/rails'
- '**/vendor/**/*'
- '**/spec_helper.rb'
- 'bin/*'
###########################################################
###################### Rubocop ############################
###########################################################
# You can find all configuration options for rubocop here: https://docs.rubocop.org/rubocop/cops_bundler.html
# ============== Layout =================
Layout/ClassStructure:
ExpectedOrder:
- module_inclusion
- constants
- association
- public_attribute_macros
- public_delegate
- macros
- initializer
- public_class_methods
- public_methods
- protected_attribute_macros
- protected_methods
- private_attribute_macros
- private_delegate
- private_methods
Layout/EmptyLineAfterMultilineCondition:
Enabled: true
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/FirstArrayElementLineBreak:
Enabled: true
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/FirstHashElementLineBreak:
Enabled: true
Layout/LineLength:
Max: 120
Exclude:
- '**/spec/**/*'
Layout/MultilineArrayBraceLayout:
EnforcedStyle: new_line
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
Layout/MultilineHashBraceLayout:
EnforcedStyle: new_line
Layout/MultilineHashKeyLineBreaks:
Enabled: true
Layout/MultilineMethodCallBraceLayout:
EnforcedStyle: new_line
Layout/MultilineMethodDefinitionBraceLayout:
EnforcedStyle: new_line
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Layout/SpaceInLambdaLiteral:
EnforcedStyle: require_space
Lint/AmbiguousBlockAssociation:
Exclude:
- '**/spec/**/*'
Lint/AssignmentInCondition:
AllowSafeAssignment: false
Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Lint/DuplicateRequire:
Enabled: true
Lint/DuplicateRescueException:
Enabled: true
Lint/EmptyConditionalBody:
Enabled: true
Lint/EmptyFile:
Enabled: true
Lint/FloatComparison:
Enabled: true
Lint/MissingSuper:
Enabled: true
Lint/MixedRegexpCaptureTypes:
Enabled: true
Lint/NumberConversion:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/SelfAssignment:
Enabled: true
Lint/TrailingCommaInAttributeDeclaration:
Enabled: true
Lint/UnusedBlockArgument:
IgnoreEmptyBlocks: false
Lint/UnusedMethodArgument:
IgnoreEmptyMethods: false
Lint/UselessMethodDefinition:
Enabled: true
# ============== Metric =================
Metrics/AbcSize:
Max: 45
Metrics/BlockLength:
CountComments: false
Max: 50
Exclude:
- '**/spec/**/*'
- '**/*.rake'
- '**/factories/**/*'
- '**/config/routes.rb'
Metrics/ClassLength:
CountAsOne: ['array', 'hash']
Max: 150
Metrics/CyclomaticComplexity:
Max: 10
Metrics/MethodLength:
CountAsOne: ['array', 'hash']
Max: 30
Metrics/ModuleLength:
CountAsOne: ['array', 'hash']
Max: 250
Exclude:
- '**/spec/**/*'
Metrics/PerceivedComplexity:
Max: 10
# ============== Variable ==================
# Most of the Naming configurations are enabled by default, we should enable or disable configuration depending on what the team needs
### Example
##
# Naming/VariableNumber:
# Enabled: false
##
###
# ============== Style ================
Style/AccessorGrouping:
Enabled: true
Style/ArrayCoercion:
Enabled: true
Style/AutoResourceCleanup:
Enabled: true
Style/BisectedAttrAccessor:
Enabled: true
Style/CaseLikeIf:
Enabled: true
Style/ClassAndModuleChildren:
Enabled: false
Style/CollectionMethods:
Enabled: true
Style/CombinableLoops:
Enabled: true
Style/CommandLiteral:
EnforcedStyle: percent_x
Style/ConstantVisibility:
Enabled: true
Style/Documentation:
Enabled: false
Style/ExplicitBlockArgument:
Enabled: true
Style/GlobalStdStream:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashLikeCase:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/ImplicitRuntimeError:
Enabled: true
Style/InlineComment:
Enabled: true
Style/IpAddresses:
Enabled: true
Style/KeywordParametersOrder:
Enabled: true
Style/MethodCallWithArgsParentheses:
Enabled: true
Style/MissingElse:
Enabled: true
EnforcedStyle: case
Style/MultilineMethodSignature:
Enabled: true
Style/OptionalBooleanParameter:
Enabled: true
Style/RedundantAssignment:
Enabled: true
Style/RedundantBegin:
Enabled: true
Style/RedundantFetchBlock:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Style/RedundantSelfAssignment:
Enabled: true
Style/SingleArgumentDig:
Enabled: true
Style/StringConcatenation:
Enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment