Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rubocop #337

Merged
merged 3 commits into from
Feb 4, 2021
Merged

Update rubocop #337

merged 3 commits into from
Feb 4, 2021

Conversation

difernandez
Copy link
Contributor

@difernandez difernandez commented Feb 2, 2021

Changes

  • Updates rubocop and rubocop-rspec to latest versions (rubocop-rspec < 2.0 is incompatible with rubocop 1.x)
  • Use same version for potassium and generated projects

Rules

The following rules are new and enabled by default with this change:

New rules
Style/SlicingWithRange:
  Description: 'Checks array slicing is done with endless ranges when suitable.'
Layout/EmptyLinesAroundAttributeAccessor:
  Description: "Keep blank lines around attribute accessors."
Lint/DeprecatedOpenSSLConstant:
  Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
Style/RedundantRegexpCharacterClass:
  Description: 'Checks for unnecessary single-element Regexp character classes.'
Style/RedundantRegexpEscape:
  Description: 'Checks for redundant escapes in Regexps.'
Lint/MixedRegexpCaptureTypes:
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
Style/RedundantFetchBlock:
  Description: >-
                  Use `fetch(key, value)` instead of `fetch(key) { value }`
                  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
Style/AccessorGrouping:
  Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
Style/BisectedAttrAccessor:
  Description: >-
                Checks for places where `attr_reader` and `attr_writer`
                for the same method can be combined into single `attr_accessor`.
Style/RedundantAssignment:
  Description: 'Checks for redundant assignment before returning.'
Lint/DuplicateElsifCondition:
  Description: 'Do not repeat conditions used in if `elsif`.'
Style/CaseLikeIf:
  Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
Style/HashAsLastArrayItem:
  Description: >-
                Checks for presence or absence of braces around hash literal as a last
                array item depending on configuration.
Style/HashLikeCase:
  Description: >-
                  Checks for places where `case-when` represents a simple 1:1
                  mapping and can be replaced with a hash lookup.
Style/RedundantFileExtensionInRequire:
  Description: >-
                  Checks for the presence of superfluous `.rb` extension in
                  the filename provided to `require` and `require_relative`.
Lint/DuplicateRescueException:
  Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
Lint/EmptyConditionalBody:
  Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.'
Lint/FloatComparison:
  Description: 'Checks for the presence of precise comparison of floating point numbers.'
Lint/MissingSuper:
  Description: >-
                  This cop checks for the presence of constructors and lifecycle callbacks
                  without calls to `super`'.
Lint/OutOfRangeRegexpRef:
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
Lint/SelfAssignment:
  Description: 'Checks for self-assignments.'
Lint/TopLevelReturnWithArgument:
  Description: 'This cop detects top level return statements with argument.'
Lint/UnreachableLoop:
  Description: 'This cop checks for loops that will have at most one iteration.'
Style/ExplicitBlockArgument:
  Description: >-
                  Consider using explicit block argument to avoid writing block literal
                  that just passes its arguments to another block.
Style/GlobalStdStream:
  Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
Style/OptionalBooleanParameter:
  Description: 'Use keyword arguments when defining method with boolean argument.'
Style/SingleArgumentDig:
  Description: 'Avoid using single argument dig method.'
Style/SoleNestedConditional:
  Description: >-
                  Finds sole nested conditional nodes
                  which can be merged into outer conditional node.
Style/StringConcatenation:
  Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
Lint/DuplicateRequire:
  Description: 'Check for duplicate `require`s and `require_relative`s.'
Lint/EmptyFile:
  Description: 'Enforces that Ruby source files are not empty.'
Lint/TrailingCommaInAttributeDeclaration:
  Description: 'This cop checks for trailing commas in attribute declarations.'
Lint/UselessMethodDefinition:
  Description: 'Checks for useless method definitions.'
Style/CombinableLoops:
  Description: >-
                  Checks for places where multiple consecutive loops over the same data
                  can be combined into a single loop.
Style/KeywordParametersOrder:
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
Style/RedundantSelfAssignment:
  Description: 'Checks for places where redundant assignments are made for in place modification methods.'
Layout/BeginEndAlignment:
  Description: 'Align ends corresponding to begins correctly.'
Lint/ConstantDefinitionInBlock:
  Description: 'Do not define constants within a block.'
Lint/IdentityComparison:
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
Lint/UselessTimes:
  Description: 'Checks for useless `Integer#times` calls.'
Lint/HashCompareByIdentity:
  Description: 'Prefer using `Hash#compare_by_identity` than using `object_id` for keys.'
Lint/RedundantSafeNavigation:
  Description: 'Checks for redundant safe navigation calls.'
Style/ClassEqualityComparison:
  Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'

Looking at them, in general it seems to me that they wouldn't affect the way we work much. I think we could leave them enabled, but I would appreciate other opinions on this. There are a couple rules in particular I have doubts and I would like to know what you think:

Closes #336

Base automatically changed from migrate-to-reviewdog to master February 3, 2021 13:16
@ldlsegovia
Copy link
Collaborator

  • Style/CaseLikeIf like this, It is clearer to read.
  • Style/RedundantFileExtensionInRequire not important as you say.
  • Lint/MissingSuper Like the first case. I don't understand the last one.
  • Style/OptionalBooleanParameter mmm I don't know why just with boolean values.
  • Style/CombinableLoops. Like
  • Lint/HashCompareByIdentity. I think it's about this. Like it
    image

@difernandez difernandez merged commit 5ed6c15 into master Feb 4, 2021
@difernandez difernandez deleted the update-rubocop branch February 4, 2021 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Update rubocop
2 participants