Skip to content

Instantly share code, notes, and snippets.

@Dmoment
Created May 31, 2024 05:09
Show Gist options
  • Select an option

  • Save Dmoment/617f96b3435b6dd4f74a01843bc2dd42 to your computer and use it in GitHub Desktop.

Select an option

Save Dmoment/617f96b3435b6dd4f74a01843bc2dd42 to your computer and use it in GitHub Desktop.
# cspell:Disable
require:
- rubocop-rails
AllCops:
TargetRubyVersion: 3.2.2
DisabledByDefault: true
NewCops: enable
Exclude:
- "app/javascript/**/*"
- "app/assets/**/*"
- "app/views/**/*.erb"
- "lib/tasks/**/*"
- ".vscode/**/*"
- ".husky/**/*"
- ".bundle/**/*"
- ".circleci/**/*"
- ".semaphore/**/*"
- "**/log/**/*"
- "**/public/**/*"
- "**/tmp/**/*"
- "**/templates/**/*"
- "**/vendor/**/*"
- "node_modules/**/*"
- "bin/**/*"
- "config/webpack/**/*"
- "db/schema.rb"
# Access modifier related rules
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
Lint/UselessAccessModifier:
Enabled: true
Style/AccessModifierDeclarations:
Enabled: true
Layout/AccessModifierIndentation:
Enabled: true
# Comment related rules
Layout/CommentIndentation:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
SafeAutoCorrect: true
# Class related rules
Layout/ClassStructure:
Enabled: true
Description: "Enforces a canonical order of definitions within a class body."
StyleGuide: "https://github.com/rubocop/rails-style-guide#macro-style-methods"
Categories:
module_inclusions:
- include
- prepend
- extend
third_party:
- neeto_sso_track_widget_tokens
- devise
scopes:
- default_scope
- scope
attributes:
- attribute
- attr_reader
- attr_writer
- attr_accessor
enum:
- enum
store:
- store
associations:
- belongs_to
- has_one
- has_many
- has_and_belongs_to_many
other_macros:
- delegate
- accepts_nested_attributes_for
validations:
- validate
- validates
- validates_acceptance_of
- validates_associated
- validates_confirmation_of
- validates_exclusion_of
- validates_format_of
- validates_inclusion_of
- validates_length_of
- validates_numericality_of
- validates_presence_of
- validates_uniqueness_of
- validates_each
- validate_with
callbacks:
- before_validation
- after_validation
- before_save
- around_save
- after_save
- before_update
- around_update
- after_update
- before_create
- after_create
- before_destroy
- around_destroy
- after_destroy
- after_commit
- after_create_commit
ExpectedOrder:
- module_inclusions
- third_party
- scopes
- constants
- attributes
- enum
- store
- associations
- validations
- callbacks
- other_macros
- initializer
- public_class_methods
- public_methods
- protected_methods
- private_methods
Layout/EmptyLinesAroundClassBody:
Enabled: true
# Method related rules
Layout/EmptyLineBetweenDefs:
Enabled: true
Layout/DotPosition:
Enabled: true
EnforcedStyle: leading
Lint/ParenthesesAsGroupedExpression:
Enabled: true
Lint/RequireParentheses:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Layout/SpaceBeforeFirstArg:
Enabled: true
Style/DefWithParentheses:
Enabled: true
Style/MethodDefParentheses:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/FirstMethodArgumentLineBreak:
Enabled: true
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: indented_internal_methods
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/FirstParameterIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/FirstArgumentIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/ArgumentAlignment:
Enabled: true
EnforcedStyle: with_fixed_indentation
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# Hash related rules
Layout/HashAlignment:
Enabled: true
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect
Layout/FirstHashElementLineBreak:
Enabled: true
Layout/MultilineHashBraceLayout:
Enabled: true
EnforcedStyle: new_line
Layout/FirstHashElementIndentation:
Enabled: true
EnforcedStyle: consistent
Style/HashSyntax:
Enabled: false
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Style/TrailingCommaInHashLiteral:
Enabled: true
# Misc whitespace related rules
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
AllowForAlignment: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeBlockBraces:
Enabled: true
Layout/SpaceInsideBlockBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
Layout/TrailingWhitespace:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
# Empty lines related rules
Layout/EndOfLine:
Enabled: true
EnforcedStyle: lf
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/EmptyLineAfterGuardClause:
Enabled: true
Layout/TrailingEmptyLines:
Enabled: true
Layout/EmptyLines:
Enabled: true
# Naming convention rules for variables
Naming/MemoizedInstanceVariableName:
Enabled: true
EnforcedStyleForLeadingUnderscores: required
# Miscellaneous rules
Style/AndOr:
Enabled: true
Layout/CaseIndentation:
Enabled: true
Layout/LineLength:
Enabled: true
Max: 120
AllowedPatterns: [
'^\s*#', # line that begins with comment
'^\s*"', # line that begins with double quote (long string literal)
"^\\s*'", # line that begins with single quote (long string literal)
'"$', # line that ends with double quote (long string variable assignment)
"'$", # line that ends with single quote (long string variable assignment)
'\/$', # line that ends with slash (long regex variable assignment)
]
Layout/IndentationWidth:
Enabled: true
Width: 2
Layout/IndentationStyle:
Enabled: true
EnforcedStyle: spaces
Layout/ExtraSpacing:
Enabled: true
AllowForAlignment: false
Style/ParenthesesAroundCondition:
Enabled: true
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
Style/RedundantPercentQ:
Enabled: true
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: false
Lint/BooleanSymbol:
Enabled: true
# Flow statements related rules
Lint/AssignmentInCondition:
Enabled: true
AllowSafeAssignment: true
# Bundler cop rules
Bundler/OrderedGems:
Enabled: true
TreatCommentsAsGroupSeparators: true
# Rails cop rules
Rails:
Enabled: false
Rails/Date:
Enabled: true
Rails/TimeZone:
Enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment