.rubocop.yml
AllCops:
DisabledByDefault: true
TargetRubyVersion: 2.5
#################### Lint ################################
Lint/AmbiguousOperator:
Description: >-
Checks for ambiguous operators in the first argument of a
method invocation without parentheses.
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#parens-as-args"
Enabled: true
Lint/AmbiguousRegexpLiteral:
Description: >-
Checks for ambiguous regexp literals in the first argument of
a method invocation without parenthesis.
Enabled: true
Lint/AssignmentInCondition:
Description: "Don't use assignment in conditions."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition"
Enabled: true
Lint/CircularArgumentReference:
Description: "Don't refer to the keyword argument in the default value."
Enabled: true
Lint/Debugger:
Description: "Check for debugger calls."
Enabled: true
Lint/DeprecatedClassMethods:
Description: "Check for deprecated class method calls."
Enabled: true
Lint/DuplicateMethods:
Description: "Check for duplicate methods calls."
Enabled: true
Lint/EachWithObjectArgument:
Description: "Check for immutable argument given to each_with_object."
Enabled: true
Lint/ElseLayout:
Description: "Check for odd code arrangement in an else block."
Enabled: true
Lint/EmptyEnsure:
Description: "Checks for empty ensure block."
Enabled: true
Lint/EmptyInterpolation:
Description: "Checks for empty string interpolation."
Enabled: true
Lint/EndInMethod:
Description: "END blocks should not be placed inside method definitions."
Enabled: true
Lint/EnsureReturn:
Description: "Do not use return in an ensure block."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-return-ensure"
Enabled: true
Security/Eval:
Description: "The use of eval represents a serious security risk."
Enabled: true
Lint/FormatParameterMismatch:
Description: "The number of parameters to format/sprint must match the fields."
Enabled: true
Lint/HandleExceptions:
Description: "Don't suppress exception."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions"
Enabled: true
Lint/LiteralAsCondition:
Description: "Checks of literals used as conditions."
Enabled: true
Lint/LiteralInInterpolation:
Description: "Checks for literals used in interpolation."
Enabled: true
Lint/Loop:
Description: >-
Use Kernel#loop with break rather than begin/end/until or
begin/end/while for post-loop tests.
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#loop-with-break"
Enabled: true
Lint/NestedMethodDefinition:
Description: "Do not use nested method definitions."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-nested-methods"
Enabled: true
Lint/NonLocalExitFromIterator:
Description: "Do not use return in iterator to cause non-local exit."
Enabled: true
Lint/ParenthesesAsGroupedExpression:
Description: >-
Checks for method calls with a space before the opening
parenthesis.
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#parens-no-spaces"
Enabled: true
Lint/RequireParentheses:
Description: >-
Use parentheses in the method call to avoid confusion
about precedence.
Enabled: true
Lint/RescueException:
Description: "Avoid rescuing the Exception class."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-blind-rescues"
Enabled: true
Lint/ShadowingOuterLocalVariable:
Description: >-
Do not use the same name as outer local variable
for block arguments or block local variables.
Enabled: true
Lint/StringConversionInInterpolation:
Description: "Checks for Object#to_s usage in string interpolation."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-to-s"
Enabled: true
Lint/UnderscorePrefixedVariableName:
Description: "Do not use prefix `_` for a variable that is used."
Enabled: false
Lint/UnusedBlockArgument:
Description: "Checks for unused block arguments."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars"
Enabled: true
Lint/UnusedMethodArgument:
Description: "Checks for unused method arguments."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars"
Enabled: true
Lint/UnreachableCode:
Description: "Unreachable code."
Enabled: true
Lint/UselessAccessModifier:
Description: "Checks for useless access modifiers."
Enabled: true
Lint/UselessAssignment:
Description: "Checks for useless assignment to a local variable."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars"
Enabled: true
Lint/UselessComparison:
Description: "Checks for comparison of something with itself."
Enabled: true
Lint/UselessElseWithoutRescue:
Description: "Checks for useless `else` in `begin..end` without `rescue`."
Enabled: true
Lint/UselessSetterCall:
Description: "Checks for useless setter call to a local variable."
Enabled: true
Lint/Void:
Description: "Possible use of operator/literal/variable in void context."
Enabled: true
###################### Metrics ####################################
Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Reference: "http://c2.com/cgi/wiki?AbcMetric"
Enabled: false
Max: 20
Metrics/BlockNesting:
Description: "Avoid excessive block nesting"
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count"
Enabled: true
Max: 4
Metrics/ClassLength:
Description: "Avoid classes longer than 300 lines of code."
Enabled: true
Max: 300
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: true
Metrics/LineLength:
Description: "Limit lines to 80 characters."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#80-character-limits"
Enabled: false
Metrics/MethodLength:
Description: "Avoid methods longer than 30 lines of code."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#short-methods"
Enabled: true
Max: 30
Metrics/ModuleLength:
Description: "Avoid modules longer than 300 lines of code."
Enabled: true
Max: 300
Metrics/ParameterLists:
Description: "Avoid parameter lists longer than three or four parameters."
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#too-many-params"
Enabled: true
Metrics/PerceivedComplexity:
Description: >-
A complexity metric geared towards measuring complexity for a
human reader.
Enabled: false
##################### Performance #############################
Performance/Count:
Description: >-
Use `count` instead of `select...size`, `reject...size`,
`select...count`, `reject...count`, `select...length`,
and `reject...length`.
Enabled: true
Performance/Detect:
Description: >-
Use `detect` instead of `select.first`, `find_all.first`,
`select.last`, and `find_all.last`.
Reference: "https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code"
Enabled: true
Performance/FlatMap:
Description: >-
Use `Enumerable#flat_map`
instead of `Enumerable#map...Array#flatten(1)`
or `Enumberable#collect..Array#flatten(1)`
Reference: "https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code"
Enabled: true
EnabledForFlattenWithoutParams: false
# If enabled, this cop will warn about usages of
# `flatten` being called without any parameters.
# This can be dangerous since `flat_map` will only flatten 1 level, and
# `flatten` without any parameters can flatten multiple levels.
Performance/ReverseEach:
Description: "Use `reverse_each` instead of `reverse.each`."
Reference: "https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code"
Enabled: true
Performance/Sample:
Description: >-
Use `sample` instead of `shuffle.first`,
`shuffle.last`, and `shuffle[Fixnum]`.
Reference: "https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code"
Enabled: true
Performance/Size:
Description: >-
Use `size` instead of `count` for counting
the number of elements in `Array` and `Hash`.
Reference: "https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code"
Enabled: true
Performance/StringReplacement:
Description: >-
Use `tr` instead of `gsub` when you are replacing the same
number of characters. Use `delete` instead of `gsub` when
you are deleting characters.
Reference: "https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code"
Enabled: true
################## Layout #################################
Layout/BlockAlignment:
Description: "Align block ends correctly."
Enabled: true
Layout/ConditionPosition:
Description: >-
Checks for condition placed in a confusing position relative to
the keyword.
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#same-line-condition"
Enabled: true
Layout/DefEndAlignment:
Description: "Align ends corresponding to defs correctly."
Enabled: true
Layout/EndAlignment:
Description: "Align ends correctly."
Enabled: true
Layout/SpaceBeforeFirstArg:
Description: >-
Checks that exactly one space is used between a method name
and the first argument for method calls without parentheses.
Enabled: true