Skip to content

Instantly share code, notes, and snippets.

@eirvandelden
Last active October 7, 2020 13:03
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 eirvandelden/c6c9bc30d8ecf4bcef365fd73d005cd1 to your computer and use it in GitHub Desktop.
Save eirvandelden/c6c9bc30d8ecf4bcef365fd73d005cd1 to your computer and use it in GitHub Desktop.
my default rubocop file with settings from standardrb and rubocop-performance
require:
- rubocop-rspec
- rubocop-performance
AllCops:
TargetRubyVersion: 2.7
Exclude:
- db/**/*schema.rb
# Layout
Layout/LineLength:
Max: 120
# Metrics
Metrics/AbcSize:
Max: 20
Metrics/BlockLength:
Exclude:
- spec/**/*_spec.rb
Metrics/MethodLength:
Max: 20
# Style
Style/Documentation:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Lint/StructNewOverride:
Enabled: true
Style/AccessorGrouping:
Enabled: true
Style/ArrayCoercion:
Enabled: true
Style/BisectedAttrAccessor:
Enabled: true
Style/CaseLikeIf:
Enabled: true
Style/ExponentialNotation:
Enabled: true
Style/HashAsLastArrayItem:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashLikeCase:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/RedundantAssignment:
Enabled: true
Style/RedundantFetchBlock:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Style/SlicingWithRange:
Enabled: true
Performance/AncestorsInclude:
Enabled: true
Performance/BigDecimalWithNumericArgument:
Enabled: true
Performance/RedundantSortBlock:
Enabled: true
Performance/RedundantStringChars:
Enabled: true
Performance/ReverseFirst:
Enabled: true
Performance/SortReverse:
Enabled: true
Performance/Squeeze:
Enabled: true
Performance/StringInclude:
Enabled: true
# from https://github.com/testdouble/standard/blob/master/config/base.yml. I refuse to add a gem for a rubocop wrapper
Bundler/InsecureProtocolSource:
Enabled: true
Include:
- "**/*.gemfile"
- "**/Gemfile"
- "**/gems.rb"
Gemspec/DuplicatedAssignment:
Enabled: true
Include:
- "**/*.gemspec"
Layout/AccessModifierIndentation:
Enabled: true
EnforcedStyle: indent
IndentationWidth: ~
Layout/ArgumentAlignment:
Enabled: true
EnforcedStyle: with_fixed_indentation
Layout/ArrayAlignment:
Enabled: true
EnforcedStyle: with_fixed_indentation
Layout/HashAlignment:
Enabled: true
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect
Layout/ParameterAlignment:
Enabled: true
EnforcedStyle: with_fixed_indentation
IndentationWidth: ~
Layout/BlockAlignment:
Enabled: true
EnforcedStyleAlignWith: either
Layout/BlockEndNewline:
Enabled: true
# Disabled because IndentOneStep can't be configured for one-liner cases. See:
# https://github.com/rubocop-hq/rubocop/issues/6447
# Layout/CaseIndentation:
# Enabled: true
Layout/ClosingHeredocIndentation:
Enabled: true
Layout/ClosingParenthesisIndentation:
Enabled: true
Layout/CommentIndentation:
Enabled: true
Layout/ConditionPosition:
Enabled: true
Layout/DefEndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line
AutoCorrect: true
Severity: warning
Layout/DotPosition:
Enabled: true
EnforcedStyle: leading
Layout/ElseAlignment:
Enabled: true
Layout/EmptyComment:
Enabled: true
AllowBorderComment: true
AllowMarginComment: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
Layout/EmptyLineBetweenDefs:
Enabled: true
AllowAdjacentOneLineDefs: false
NumberOfEmptyLines: 1
Layout/EmptyLines:
Enabled: true
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
Layout/EmptyLinesAroundArguments:
Enabled: true
Layout/EmptyLinesAroundBeginBody:
Enabled: true
Layout/EmptyLinesAroundBlockBody:
Enabled: true
EnforcedStyle: no_empty_lines
Layout/EmptyLinesAroundClassBody:
Enabled: true
EnforcedStyle: no_empty_lines
Layout/EmptyLinesAroundExceptionHandlingKeywords:
Enabled: true
Layout/EmptyLinesAroundMethodBody:
Enabled: true
Layout/EmptyLinesAroundModuleBody:
Enabled: true
EnforcedStyle: no_empty_lines
Layout/EndAlignment:
Enabled: true
AutoCorrect: true
EnforcedStyleAlignWith: variable
Severity: warning
Layout/EndOfLine:
Enabled: true
EnforcedStyle: native
Layout/ExtraSpacing:
Enabled: true
AllowForAlignment: true
AllowBeforeTrailingComments: false
ForceEqualSignAlignment: true
Layout/FirstArgumentIndentation:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~
Layout/FirstArrayElementIndentation:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~
Layout/AssignmentIndentation:
Enabled: true
IndentationWidth: ~
Layout/FirstHashElementIndentation:
Enabled: true
EnforcedStyle: consistent
IndentationWidth: ~
Layout/HeredocIndentation:
Enabled: true
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal
Layout/IndentationWidth:
Enabled: true
Width: 2
IgnoredPatterns: []
Layout/InitialIndentation:
Enabled: true
Layout/LeadingEmptyLines:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/MultilineArrayBraceLayout:
Enabled: true
EnforcedStyle: symmetrical
Layout/MultilineBlockLayout:
Enabled: true
Layout/MultilineHashBraceLayout:
Enabled: true
EnforcedStyle: symmetrical
Layout/MultilineMethodCallBraceLayout:
Enabled: true
EnforcedStyle: symmetrical
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
IndentationWidth: ~
Layout/MultilineMethodDefinitionBraceLayout:
Enabled: true
EnforcedStyle: symmetrical
Layout/MultilineOperationIndentation:
Enabled: true
EnforcedStyle: indented
IndentationWidth: ~
Layout/RescueEnsureAlignment:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAfterMethodName:
Enabled: true
Layout/SpaceAfterNot:
Enabled: true
Layout/SpaceAfterSemicolon:
Enabled: true
Layout/SpaceAroundBlockParameters:
Enabled: true
EnforcedStyleInsidePipes: no_space
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
EnforcedStyle: space
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
AllowForAlignment: true
Layout/SpaceBeforeBlockBraces:
Enabled: true
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeComment:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
AllowForAlignment: true
Layout/SpaceBeforeSemicolon:
Enabled: true
Layout/SpaceInLambdaLiteral:
Enabled: true
EnforcedStyle: require_no_space
Layout/SpaceInsideArrayLiteralBrackets:
Enabled: true
EnforcedStyle: no_space
EnforcedStyleForEmptyBrackets: no_space
Layout/SpaceInsideArrayPercentLiteral:
Enabled: true
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyle: space
EnforcedStyleForEmptyBraces: no_space
SpaceBeforeBlockParameters: true
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
EnforcedStyle: compact
EnforcedStyleForEmptyBraces: no_space
Layout/SpaceInsideParens:
Enabled: true
EnforcedStyle: no_space
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: true
Layout/SpaceInsideRangeLiteral:
Enabled: true
Layout/SpaceInsideReferenceBrackets:
Enabled: true
EnforcedStyle: no_space
EnforcedStyleForEmptyBrackets: no_space
Layout/SpaceInsideStringInterpolation:
Enabled: true
EnforcedStyle: no_space
Layout/IndentationStyle:
Enabled: true
IndentationWidth: ~
Layout/TrailingEmptyLines:
Enabled: true
EnforcedStyle: final_newline
Layout/TrailingWhitespace:
Enabled: true
AllowInHeredoc: true
Lint/AmbiguousOperator:
Enabled: true
Lint/AmbiguousRegexpLiteral:
Enabled: true
Lint/AssignmentInCondition:
Enabled: true
AllowSafeAssignment: true
Lint/BigDecimalNew:
Enabled: true
Lint/BooleanSymbol:
Enabled: true
Lint/CircularArgumentReference:
Enabled: true
Lint/Debugger:
Enabled: true
Lint/DeprecatedClassMethods:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/DuplicateCaseCondition:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
Lint/DuplicateHashKey:
Enabled: true
Lint/EachWithObjectArgument:
Enabled: true
Lint/ElseLayout:
Enabled: true
Lint/EmptyEnsure:
Enabled: true
AutoCorrect: true
Lint/EmptyExpression:
Enabled: true
Lint/EmptyInterpolation:
Enabled: true
Lint/EmptyWhen:
Enabled: true
AllowComments: true
Lint/EnsureReturn:
Enabled: true
Lint/ErbNewArguments:
Enabled: true
Lint/FlipFlop:
Enabled: true
Lint/FloatOutOfRange:
Enabled: true
Lint/FormatParameterMismatch:
Enabled: true
Lint/ImplicitStringConcatenation:
Enabled: true
Lint/IneffectiveAccessModifier:
Enabled: true
Lint/InheritException:
Enabled: true
EnforcedStyle: runtime_error
Lint/InterpolationCheck:
Enabled: true
Lint/LiteralAsCondition:
Enabled: true
Lint/LiteralInInterpolation:
Enabled: true
Lint/Loop:
Enabled: true
Lint/MissingCopEnableDirective:
Enabled: true
MaximumRangeSize: .inf
Lint/MixedRegexpCaptureTypes:
Enabled: true
Lint/MultipleComparison:
Enabled: true
Lint/NestedMethodDefinition:
Enabled: true
Lint/NestedPercentLiteral:
Enabled: true
Lint/NextWithoutAccumulator:
Enabled: true
Lint/NonDeterministicRequireOrder:
Enabled: true
Lint/NonLocalExitFromIterator:
Enabled: true
Lint/OrderedMagicComments:
Enabled: true
Lint/ParenthesesAsGroupedExpression:
Enabled: true
Lint/PercentSymbolArray:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/RandOne:
Enabled: true
Lint/RedundantStringCoercion:
Enabled: true
Lint/RedundantWithIndex:
Enabled: true
Lint/RedundantWithObject:
Enabled: true
Lint/RegexpAsCondition:
Enabled: true
Lint/RequireParentheses:
Enabled: true
Lint/RescueException:
Enabled: true
Lint/RescueType:
Enabled: true
Lint/ReturnInVoidContext:
Enabled: true
Lint/SafeNavigationChain:
Enabled: true
AllowedMethods:
- present?
- blank?
- presence
- try
- try!
Lint/SafeNavigationConsistency:
Enabled: true
AllowedMethods:
- present?
- blank?
- presence
- try
- try!
Lint/ShadowedArgument:
Enabled: true
IgnoreImplicitReferences: false
Lint/ShadowedException:
Enabled: true
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/Syntax:
Enabled: true
Lint/UnderscorePrefixedVariableName:
Enabled: true
Lint/UnifiedInteger:
Enabled: true
Lint/RedundantRequireStatement:
Enabled: true
Lint/RedundantSplatExpansion:
Enabled: true
Lint/UnreachableCode:
Enabled: true
Lint/UriEscapeUnescape:
Enabled: true
Lint/UriRegexp:
Enabled: true
Lint/UselessAssignment:
Enabled: true
Lint/UselessComparison:
Enabled: true
Lint/UselessElseWithoutRescue:
Enabled: true
Lint/UselessSetterCall:
Enabled: true
Lint/Void:
Enabled: true
CheckForMethodsWithNoSideEffects: false
Migration/DepartmentName:
Enabled: true
Naming/ClassAndModuleCamelCase:
Enabled: true
Naming/ConstantName:
Enabled: true
Naming/HeredocDelimiterCase:
Enabled: true
EnforcedStyle: uppercase
Naming/BlockParameterName:
Enabled: true
MinNameLength: 1
AllowNamesEndingInNumbers: true
AllowedNames: []
ForbiddenNames: []
Naming/VariableName:
Enabled: true
EnforcedStyle: snake_case
Performance/BindCall:
Enabled: true
Performance/Caller:
Enabled: true
Performance/CompareWithBlock:
Enabled: true
Performance/Count:
Enabled: true
Performance/DeletePrefix:
Enabled: true
Performance/DeleteSuffix:
Enabled: true
Performance/Detect:
Enabled: true
Performance/DoubleStartEndWith:
Enabled: true
IncludeActiveSupportAliases: false
Performance/EndWith:
Enabled: true
Performance/FixedSize:
Enabled: true
Performance/FlatMap:
Enabled: true
EnabledForFlattenWithoutParams: false
Performance/InefficientHashSearch:
Enabled: true
Safe: false
Performance/RangeInclude:
Enabled: true
Safe: false
Performance/RedundantMatch:
Enabled: true
Performance/RedundantMerge:
Enabled: true
MaxKeyValuePairs: 2
Performance/RegexpMatch:
Enabled: true
Performance/ReverseEach:
Enabled: true
Performance/Size:
Enabled: true
Performance/StartWith:
Enabled: true
Performance/StringReplacement:
Enabled: true
Performance/UnfreezeString:
Enabled: true
Performance/UriDefaultParser:
Enabled: true
Security/Eval:
Enabled: true
Security/JSONLoad:
Enabled: true
AutoCorrect: false
SafeAutoCorrect: false
Security/Open:
Enabled: true
Safe: false
Security/YAMLLoad:
Enabled: true
SafeAutoCorrect: false
Style/Alias:
Enabled: true
EnforcedStyle: prefer_alias
Style/AndOr:
Enabled: true
EnforcedStyle: always
Style/ArrayJoin:
Enabled: true
Style/Attr:
Enabled: true
Style/BarePercentLiterals:
Enabled: true
EnforcedStyle: bare_percent
Style/BeginBlock:
Enabled: true
Style/BlockComments:
Enabled: true
Style/CharacterLiteral:
Enabled: true
Style/ClassCheck:
Enabled: true
EnforcedStyle: is_a?
Style/ClassMethods:
Enabled: true
Style/ColonMethodCall:
Enabled: true
Style/ColonMethodDefinition:
Enabled: true
Style/CommandLiteral:
Enabled: true
EnforcedStyle: mixed
AllowInnerBackticks: false
Style/CommentedKeyword:
Enabled: true
Style/ConditionalAssignment:
Enabled: true
EnforcedStyle: assign_to_condition
SingleLineConditionsOnly: true
IncludeTernaryExpressions: true
Style/DefWithParentheses:
Enabled: true
Style/Dir:
Enabled: true
Style/EachForSimpleLoop:
Enabled: true
Style/EachWithObject:
Enabled: true
Style/EmptyBlockParameter:
Enabled: true
Style/EmptyCaseCondition:
Enabled: true
Style/EmptyElse:
Enabled: true
EnforcedStyle: both
Style/EmptyLambdaParameter:
Enabled: true
Style/EmptyLiteral:
Enabled: true
Style/EmptyMethod:
Enabled: true
EnforcedStyle: expanded
Style/Encoding:
Enabled: true
Style/EndBlock:
Enabled: true
AutoCorrect: true
Style/EvalWithLocation:
Enabled: true
Style/For:
Enabled: true
EnforcedStyle: each
Style/GlobalVars:
Enabled: true
AllowedVariables: []
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
Style/IdenticalConditionalBranches:
Enabled: true
Style/IfInsideElse:
Enabled: true
Style/IfUnlessModifierOfIfUnless:
Enabled: true
Style/IfWithSemicolon:
Enabled: true
Style/InfiniteLoop:
Enabled: true
SafeAutoCorrect: true
Style/LambdaCall:
Enabled: true
EnforcedStyle: call
Style/LineEndConcatenation:
Enabled: true
SafeAutoCorrect: false
Style/MethodCallWithoutArgsParentheses:
Enabled: true
IgnoredMethods: []
Style/MethodMissingSuper:
Enabled: true
Style/MissingRespondToMissing:
Enabled: true
Style/MixinGrouping:
Enabled: true
EnforcedStyle: separated
Style/MixinUsage:
Enabled: true
Style/MultilineIfModifier:
Enabled: true
Style/MultilineIfThen:
Enabled: true
Style/MultilineMemoization:
Enabled: true
EnforcedStyle: keyword
Style/NegatedIf:
Enabled: true
EnforcedStyle: both
Style/NegatedWhile:
Enabled: true
Style/NestedModifier:
Enabled: true
Style/NestedParenthesizedCalls:
Enabled: true
AllowedMethods:
- be
- be_a
- be_an
- be_between
- be_falsey
- be_kind_of
- be_instance_of
- be_truthy
- be_within
- eq
- eql
- end_with
- include
- match
- raise_error
- respond_to
- start_with
Style/NestedTernaryOperator:
Enabled: true
Style/NilComparison:
Enabled: true
EnforcedStyle: predicate
Style/NonNilCheck:
Enabled: true
IncludeSemanticChanges: false
Style/Not:
Enabled: true
Style/NumericLiteralPrefix:
Enabled: true
EnforcedOctalStyle: zero_with_o
Style/OneLineConditional:
Enabled: true
Style/OptionalArguments:
Enabled: true
Style/OrAssignment:
Enabled: true
Style/ParenthesesAroundCondition:
Enabled: true
AllowSafeAssignment: true
AllowInMultilineConditions: false
Style/PercentLiteralDelimiters:
Enabled: true
PreferredDelimiters:
default: ()
"%i": "[]"
"%I": "[]"
"%r": "{}"
"%w": "[]"
"%W": "[]"
Style/Proc:
Enabled: true
Style/RandomWithOffset:
Enabled: true
Style/RedundantBegin:
Enabled: true
Style/RedundantConditional:
Enabled: true
Style/RedundantException:
Enabled: true
Style/RedundantFreeze:
Enabled: true
Style/RedundantParentheses:
Enabled: true
Style/RedundantRegexpCharacterClass:
Enabled: true
Style/RedundantRegexpEscape:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: false
Style/RedundantSelf:
Enabled: true
Style/RedundantSortBy:
Enabled: true
Style/RescueModifier:
Enabled: true
Style/RescueStandardError:
Enabled: true
EnforcedStyle: implicit
Style/SafeNavigation:
Enabled: true
ConvertCodeThatCanStartToReturnNil: false
AllowedMethods:
- present?
- blank?
- presence
- try
- try!
Style/Sample:
Enabled: true
Style/SelfAssignment:
Enabled: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: false
Style/SingleLineMethods:
Enabled: true
AllowIfMethodIsEmpty: false
Style/StabbyLambdaParentheses:
Enabled: true
EnforcedStyle: require_parentheses
Style/StderrPuts:
Enabled: true
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
ConsistentQuotesInMultiline: false
Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes
Style/Strip:
Enabled: true
Style/SymbolLiteral:
Enabled: true
Style/TernaryParentheses:
Enabled: true
EnforcedStyle: require_no_parentheses
AllowSafeAssignment: true
Style/TrailingBodyOnClass:
Enabled: true
Style/TrailingBodyOnMethodDefinition:
Enabled: true
Style/TrailingBodyOnModule:
Enabled: true
Style/TrailingCommaInArguments:
Enabled: true
EnforcedStyleForMultiline: no_comma
Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: no_comma
Style/TrailingCommaInBlockArgs:
Enabled: true
Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: no_comma
Style/TrailingMethodEndStatement:
Enabled: true
Style/TrivialAccessors:
Enabled: true
ExactNameMatch: true
AllowPredicates: true
AllowDSLWriters: false
IgnoreClassMethods: false
AllowedMethods:
- to_ary
- to_a
- to_c
- to_enum
- to_h
- to_hash
- to_i
- to_int
- to_io
- to_open
- to_path
- to_proc
- to_r
- to_regexp
- to_str
- to_s
- to_sym
Style/UnlessElse:
Enabled: true
Style/RedundantCondition:
Enabled: true
Style/RedundantInterpolation:
Enabled: true
Style/RedundantPercentQ:
Enabled: true
Style/RedundantSort:
Enabled: true
Style/UnpackFirst:
Enabled: true
Style/VariableInterpolation:
Enabled: true
Style/WhenThen:
Enabled: true
Style/WhileUntilDo:
Enabled: true
Style/YodaCondition:
Enabled: true
EnforcedStyle: forbid_for_all_comparison_operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment