Skip to content

Instantly share code, notes, and snippets.

@alextakitani
Created July 7, 2021 18:10
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 alextakitani/09ee34b1fc172beb1796a9b5e0a2515d to your computer and use it in GitHub Desktop.
Save alextakitani/09ee34b1fc172beb1796a9b5e0a2515d to your computer and use it in GitHub Desktop.
require:
- rubocop-rspec
- rubocop-performance
- rubocop-rails
AllCops:
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.7
Lint/Debugger:
DebuggerMethods:
Jard: jard
Rails:
Enabled: true
Performance:
Enabled: true
Rails/UniqueValidationWithoutIndex:
Enabled: true
Rails/DynamicFindBy:
Enabled: false
Lint/RescueException:
Enabled: false
Rails/SkipsModelValidations:
Enabled: false
Layout/LineLength:
Max: 200
Metrics/MethodLength:
Max: 400
Style/Documentation:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
Enabled: false
Style/AsciiComments:
Enabled: false
Bundler/OrderedGems:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
Style/FrozenStringLiteralComment:
EnforcedStyle: never
Style/AndOr:
Enabled: false
Rails/LexicallyScopedActionFilter:
Enabled: false
Rails/UnknownEnv:
Environments:
- production
- development
- staging
- qa
Style/HashTransformValues:
Enabled: false
Metrics/BlockNesting:
Description: 'Avoid excessive block nesting'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
Enabled: false
Security/MarshalLoad:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/ClassLength:
Description: 'Avoid classes longer than 100 lines of code.'
Enabled: false
Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false
Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Enabled: false
Metrics/BlockLength:
CountComments: false # count full line comments?
Max: 250
Exclude:
- "spec/**/*"
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: false
RSpec/NestedGroups:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/ContextWording:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
Naming/VariableNumber:
Enabled: false
Layout/AccessModifierIndentation:
Enabled: true
Layout/HashAlignment:
Enabled: true
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect
Layout/ParameterAlignment:
Enabled: true
EnforcedStyle: with_first_parameter
Layout/BlockAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_block
Layout/CaseIndentation:
Enabled: true
Layout/ClosingParenthesisIndentation:
Enabled: true
Layout/DotPosition:
EnforcedStyle: leading
Layout/EmptyLineBetweenDefs:
Enabled: true
Layout/EmptyLines:
Enabled: true
Layout/EmptyLineAfterGuardClause:
Enabled: false
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
Layout/EmptyLinesAroundBlockBody:
Enabled: true
# Note(maxh): Not sure about this one given we already have EmptyLines above.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# Why AllowForAlignment: false?
# 1) Cleaner diffs. For example, when you add a longer key to a hash,
# you need to update all the other rows to maintain alignment. This
# means your diffs become harder to read. It looks like more is changing
# than actually is.
# 2) Better to have one way to do things than two.
# 3) You can still use rubocop:disable comments in exceptional cases.
Layout/ExtraSpacing:
Enabled: true
AllowForAlignment: false
Layout/FirstArrayElementLineBreak:
Enabled: true
Layout/FirstHashElementLineBreak:
Enabled: true
Layout/FirstMethodArgumentLineBreak:
Enabled: true
Layout/HeredocArgumentClosingParenthesis:
Enabled: true
Layout/FirstArgumentIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/FirstArrayElementIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/FirstParameterIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/IndentationConsistency:
Enabled: true
Layout/IndentationWidth:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/MultilineArrayLineBreaks:
Enabled: true
Layout/MultilineBlockLayout:
Enabled: true
Layout/MultilineHashBraceLayout:
Enabled: true
Layout/MultilineHashKeyLineBreaks:
Enabled: true
Layout/MultilineMethodArgumentLineBreaks:
Enabled: true
Layout/MultilineMethodCallBraceLayout:
Enabled: true
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/MultilineOperationIndentation:
Enabled: true
# This doesn't play nice with private_class_method.
Layout/RescueEnsureAlignment:
Enabled: false
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeBlockBraces:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: false
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyle: space
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
EnforcedStyle: no_space
Layout/SpaceInLambdaLiteral:
Enabled: true
SupportedStyles:
- require_no_space
# Enforce final new line.
Layout/TrailingEmptyLines:
Enabled: true
SupportedStyles:
- final_newline
Layout/TrailingWhitespace:
Enabled: true
######
# Lint
######
Lint/AmbiguousBlockAssociation:
Enabled: true
inherit_mode:
# RSpec has a canonical syntax that violates this rule
Exclude:
- !ruby/regexp /_spec\.rb$/
Lint/AssignmentInCondition:
Enabled: false
Lint/BigDecimalNew:
Enabled: false
Lint/HeredocMethodCallPosition:
Enabled: true
Lint/NestedMethodDefinition:
Enabled: true
# Sandbox uses Sinatra which is heavily uses nested methods
Exclude:
- !ruby/regexp /sandbox/dashboard/app/.*.rb/
Lint/ShadowingOuterLocalVariable:
Enabled: false
Lint/UnusedMethodArgument:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Style/EmptyMethod:
Enabled: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment