Commit c002a560 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'complexity/enable-multiple-rubocop-cops' into 'master'

Enable multiple Rubocop cops that can be enabled

See https://gitlab.com/gitlab-org/gitlab-ce/issues/17406

This enabled following cops:

```text
Lint/CircularArgumentReference:
  Description: Default values in optional keyword arguments and optional ordinal arguments
----------------
Lint/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
----------------
Lint/Debugger:
  Description: Check for debugger calls.
----------------
Lint/DefEndAlignment:
  Description: Align ends corresponding to defs correctly.
----------------
Lint/DuplicateMethods:
  Description: Check for duplicate method definitions.
----------------
Lint/DuplicatedKey:
  Description: Check for duplicate keys in hash literals.
----------------
Lint/EachWithObjectArgument:
  Description: Check for immutable argument given to each_with_object.
----------------
Lint/ElseLayout:
  Description: Check for odd code arrangement in an else block.
----------------
Lint/EmptyEnsure:
  Description: Checks for empty ensure block.
----------------
Lint/EmptyInterpolation:
  Description: Checks for empty string interpolation.
----------------
Lint/EndAlignment:
  Description: Align ends correctly.
----------------
Lint/EndInMethod:
  Description: END blocks should not be placed inside method definitions.
----------------
Lint/EnsureReturn:
  Description: Do not use return in an ensure block.
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-return-ensure
----------------
Lint/Eval:
  Description: The use of eval represents a serious security risk.
----------------
Lint/FloatOutOfRange:
  Description: Catches floating-point literals too large or small for Ruby to represent.
----------------
Lint/FormatParameterMismatch:
  Description: The number of parameters to format/sprint must match the fields.
----------------
Lint/ImplicitStringConcatenation:
  Description: Checks for adjacent string literals on the same line, which could better
    be represented as a single string literal.
----------------
Lint/InvalidCharacterLiteral:
  Description: Checks for invalid character literals with a non-escaped whitespace character.
----------------
Lint/LiteralInInterpolation:
  Description: Checks for literals used in interpolation.
----------------
Lint/NestedMethodDefinition:
  Description: Do not use nested method definitions.
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-methods
----------------
Lint/NextWithoutAccumulator:
  Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject`
    block.
----------------
Lint/RandOne:
  Description: Checks for `rand(1)` calls. Such calls always return `0` and most likely
    a mistake.
----------------
Lint/RequireParentheses:
  Description: Use parentheses in the method call to avoid confusion about precedence.
----------------
Lint/UnreachableCode:
  Description: Unreachable code.
----------------
Lint/UselessComparison:
  Description: Checks for comparison of something with itself.
----------------
Lint/UselessElseWithoutRescue:
  Description: Checks for useless `else` in `begin..end` without `rescue`.
----------------
Lint/UselessSetterCall:
  Description: Checks for useless setter call to a local variable.
----------------
Lint/Void:
  Description: Possible use of operator/literal/variable in void context.
----------------
Performance/DoubleStartEndWith:
  Description: Use `str.{start,end}_with?(x, ..., y, ...)` instead of `str.{start,end}_with?(x,
    ...) || str.{start,end}_with?(y, ...)`.
----------------
Performance/RedundantSortBy:
  Description: Use `sort` instead of `sort_by { |x| x }`.
----------------
Rails/FindBy:
  Description: Prefer find_by over where.first.
  Include:
  - app/models/**/*.rb
----------------
Rails/FindEach:
  Description: Prefer all.find_each over all.find.
  Include:
  - app/models/**/*.rb
----------------
Rails/PluralizationGrammar:
  Description: Checks for incorrect grammar when using methods like `3.day.ago`.
----------------
Rails/ScopeArgs:
  Description: Checks the arguments of ActiveRecord scopes.
  Include:
  - app/models/**/*.rb
```

See merge request !4261
parents 18ac02a3 da5943fc
...@@ -772,19 +772,19 @@ Lint/BlockAlignment: ...@@ -772,19 +772,19 @@ Lint/BlockAlignment:
# Default values in optional keyword arguments and optional ordinal arguments # Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument. # should not refer back to the name of the argument.
Lint/CircularArgumentReference: Lint/CircularArgumentReference:
Enabled: false Enabled: true
# Checks for condition placed in a confusing position relative to the keyword. # Checks for condition placed in a confusing position relative to the keyword.
Lint/ConditionPosition: Lint/ConditionPosition:
Enabled: false Enabled: true
# Check for debugger calls. # Check for debugger calls.
Lint/Debugger: Lint/Debugger:
Enabled: false Enabled: true
# Align ends corresponding to defs correctly. # Align ends corresponding to defs correctly.
Lint/DefEndAlignment: Lint/DefEndAlignment:
Enabled: false Enabled: true
# Check for deprecated class method calls. # Check for deprecated class method calls.
Lint/DeprecatedClassMethods: Lint/DeprecatedClassMethods:
...@@ -800,15 +800,15 @@ Lint/DuplicatedKey: ...@@ -800,15 +800,15 @@ Lint/DuplicatedKey:
# Check for immutable argument given to each_with_object. # Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument: Lint/EachWithObjectArgument:
Enabled: false Enabled: true
# Check for odd code arrangement in an else block. # Check for odd code arrangement in an else block.
Lint/ElseLayout: Lint/ElseLayout:
Enabled: false Enabled: true
# Checks for empty ensure block. # Checks for empty ensure block.
Lint/EmptyEnsure: Lint/EmptyEnsure:
Enabled: false Enabled: true
# Checks for empty string interpolation. # Checks for empty string interpolation.
Lint/EmptyInterpolation: Lint/EmptyInterpolation:
...@@ -816,37 +816,36 @@ Lint/EmptyInterpolation: ...@@ -816,37 +816,36 @@ Lint/EmptyInterpolation:
# Align ends correctly. # Align ends correctly.
Lint/EndAlignment: Lint/EndAlignment:
Enabled: false Enabled: true
# END blocks should not be placed inside method definitions. # END blocks should not be placed inside method definitions.
Lint/EndInMethod: Lint/EndInMethod:
Enabled: false Enabled: true
# Do not use return in an ensure block. # Do not use return in an ensure block.
Lint/EnsureReturn: Lint/EnsureReturn:
Enabled: false Enabled: true
# The use of eval represents a serious security risk. # The use of eval represents a serious security risk.
Lint/Eval: Lint/Eval:
Enabled: false Enabled: true
# Catches floating-point literals too large or small for Ruby to represent. # Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange: Lint/FloatOutOfRange:
Enabled: false Enabled: true
# The number of parameters to format/sprint must match the fields. # The number of parameters to format/sprint must match the fields.
Lint/FormatParameterMismatch: Lint/FormatParameterMismatch:
Enabled: false Enabled: true
# Don't suppress exception. # Don't suppress exception.
Lint/HandleExceptions: Lint/HandleExceptions:
Enabled: false Enabled: false
# TODO: Enable ImplicitStringConcatenation Cop.
# Checks for adjacent string literals on the same line, which could better be # Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal. # represented as a single string literal.
Lint/ImplicitStringConcatenation: Lint/ImplicitStringConcatenation:
Enabled: false Enabled: true
# TODO: Enable IneffectiveAccessModifier Cop. # TODO: Enable IneffectiveAccessModifier Cop.
# Checks for attempts to use `private` or `protected` to set the visibility # Checks for attempts to use `private` or `protected` to set the visibility
...@@ -857,7 +856,7 @@ Lint/IneffectiveAccessModifier: ...@@ -857,7 +856,7 @@ Lint/IneffectiveAccessModifier:
# Checks for invalid character literals with a non-escaped whitespace # Checks for invalid character literals with a non-escaped whitespace
# character. # character.
Lint/InvalidCharacterLiteral: Lint/InvalidCharacterLiteral:
Enabled: false Enabled: true
# Checks of literals used in conditions. # Checks of literals used in conditions.
Lint/LiteralInCondition: Lint/LiteralInCondition:
...@@ -865,7 +864,7 @@ Lint/LiteralInCondition: ...@@ -865,7 +864,7 @@ Lint/LiteralInCondition:
# Checks for literals used in interpolation. # Checks for literals used in interpolation.
Lint/LiteralInInterpolation: Lint/LiteralInInterpolation:
Enabled: false Enabled: true
# Use Kernel#loop with break rather than begin/end/until or begin/end/while # Use Kernel#loop with break rather than begin/end/until or begin/end/while
# for post-loop tests. # for post-loop tests.
...@@ -874,11 +873,11 @@ Lint/Loop: ...@@ -874,11 +873,11 @@ Lint/Loop:
# Do not use nested method definitions. # Do not use nested method definitions.
Lint/NestedMethodDefinition: Lint/NestedMethodDefinition:
Enabled: false Enabled: true
# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block. # Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator: Lint/NextWithoutAccumulator:
Enabled: false Enabled: true
# Checks for method calls with a space before the opening parenthesis. # Checks for method calls with a space before the opening parenthesis.
Lint/ParenthesesAsGroupedExpression: Lint/ParenthesesAsGroupedExpression:
...@@ -887,11 +886,11 @@ Lint/ParenthesesAsGroupedExpression: ...@@ -887,11 +886,11 @@ Lint/ParenthesesAsGroupedExpression:
# Checks for `rand(1)` calls. Such calls always return `0` and most likely # Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake. # a mistake.
Lint/RandOne: Lint/RandOne:
Enabled: false Enabled: true
# Use parentheses in the method call to avoid confusion about precedence. # Use parentheses in the method call to avoid confusion about precedence.
Lint/RequireParentheses: Lint/RequireParentheses:
Enabled: false Enabled: true
# Avoid rescuing the Exception class. # Avoid rescuing the Exception class.
Lint/RescueException: Lint/RescueException:
...@@ -926,7 +925,7 @@ Lint/UnusedMethodArgument: ...@@ -926,7 +925,7 @@ Lint/UnusedMethodArgument:
# Unreachable code. # Unreachable code.
Lint/UnreachableCode: Lint/UnreachableCode:
Enabled: false Enabled: true
# Checks for useless access modifiers. # Checks for useless access modifiers.
Lint/UselessAccessModifier: Lint/UselessAccessModifier:
...@@ -938,19 +937,19 @@ Lint/UselessAssignment: ...@@ -938,19 +937,19 @@ Lint/UselessAssignment:
# Checks for comparison of something with itself. # Checks for comparison of something with itself.
Lint/UselessComparison: Lint/UselessComparison:
Enabled: false Enabled: true
# Checks for useless `else` in `begin..end` without `rescue`. # Checks for useless `else` in `begin..end` without `rescue`.
Lint/UselessElseWithoutRescue: Lint/UselessElseWithoutRescue:
Enabled: false Enabled: true
# Checks for useless setter call to a local variable. # Checks for useless setter call to a local variable.
Lint/UselessSetterCall: Lint/UselessSetterCall:
Enabled: false Enabled: true
# Possible use of operator/literal/variable in void context. # Possible use of operator/literal/variable in void context.
Lint/Void: Lint/Void:
Enabled: false Enabled: true
##################### Performance ############################ ##################### Performance ############################
...@@ -959,11 +958,10 @@ Lint/Void: ...@@ -959,11 +958,10 @@ Lint/Void:
Performance/Casecmp: Performance/Casecmp:
Enabled: true Enabled: true
# TODO: Enable DoubleStartEndWith Cop.
# Use `str.{start,end}_with?(x, ..., y, ...)` instead of # Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`. # `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith: Performance/DoubleStartEndWith:
Enabled: false Enabled: true
# TODO: Enable EndWith Cop. # TODO: Enable EndWith Cop.
# Use `end_with?` instead of a regex match anchored to the end of a string. # Use `end_with?` instead of a regex match anchored to the end of a string.
...@@ -996,10 +994,9 @@ Performance/RedundantMerge: ...@@ -996,10 +994,9 @@ Performance/RedundantMerge:
MaxKeyValuePairs: 2 MaxKeyValuePairs: 2
Enabled: false Enabled: false
# TODO: Enable RedundantSortBy Cop.
# Use `sort` instead of `sort_by { |x| x }`. # Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy: Performance/RedundantSortBy:
Enabled: false Enabled: true
# Use `start_with?` instead of a regex match anchored to the beginning of a # Use `start_with?` instead of a regex match anchored to the beginning of a
# string. # string.
...@@ -1040,11 +1037,11 @@ Rails/Delegate: ...@@ -1040,11 +1037,11 @@ Rails/Delegate:
# Prefer `find_by` over `where.first`. # Prefer `find_by` over `where.first`.
Rails/FindBy: Rails/FindBy:
Enabled: false Enabled: true
# Prefer `all.find_each` over `all.find`. # Prefer `all.find_each` over `all.find`.
Rails/FindEach: Rails/FindEach:
Enabled: false Enabled: true
# Prefer has_many :through to has_and_belongs_to_many. # Prefer has_many :through to has_and_belongs_to_many.
Rails/HasAndBelongsToMany: Rails/HasAndBelongsToMany:
...@@ -1056,7 +1053,7 @@ Rails/Output: ...@@ -1056,7 +1053,7 @@ Rails/Output:
# Checks for incorrect grammar when using methods like `3.day.ago`. # Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar: Rails/PluralizationGrammar:
Enabled: false Enabled: true
# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`. # Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
Rails/ReadWriteAttribute: Rails/ReadWriteAttribute:
...@@ -1064,7 +1061,7 @@ Rails/ReadWriteAttribute: ...@@ -1064,7 +1061,7 @@ Rails/ReadWriteAttribute:
# Checks the arguments of ActiveRecord scopes. # Checks the arguments of ActiveRecord scopes.
Rails/ScopeArgs: Rails/ScopeArgs:
Enabled: false Enabled: true
# Checks the correct usage of time zone aware methods. # Checks the correct usage of time zone aware methods.
# http://danilenko.org/2012/7/6/rails_timezones # http://danilenko.org/2012/7/6/rails_timezones
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment