Back to Rubocop

V0.37.0

relnotes/v0.37.0.md

1.86.112.2 KB
Original Source

New features

  • #2620: New cop Style/ZeroLengthPredicate checks for object.size == 0 and variants, and suggests replacing them with an appropriate empty? predicate. (@drenmi)
  • #2657: Floating headers in HTML output. (@mattparlane)
  • Add new Style/SpaceAroundKeyword cop. (@lumeet)
  • #2745: New cop Style/MultilineHashBraceLayout checks that the closing brace in a hash literal is symmetrical with respect to the opening brace and the hash elements. (@panthomakos)
  • #2761: New cop Style/MultilineMethodDefinitionBraceLayout checks that the closing brace in a method definition is symmetrical with respect to the opening brace and the method parameters. (@panthomakos)
  • #2699: Performance/Casecmp can register offenses when str.downcase or str.upcase are passed to an equality method. (@rrosenblum)
  • #2766: New cop Style/MultilineMethodCallBraceLayout checks that the closing brace in a method call is symmetrical with respect to the opening brace and the method arguments. (@panthomakos)

Bug fixes

  • #2723: Fix NoMethodError in Style/GuardClause. (@drenmi)
  • #2674: Also check for Hash#update alias in Performance/RedundantMerge. (@drenmi)
  • #2630: Take frozen string literals into account in Style/MutableConstant. (@segiddins)
  • #2642: Support assignment via ||= in Style/MutableConstant. (@segiddins)
  • #2646: Fix auto-correcting assignment to a constant in Style/ConditionalAssignment. (@segiddins)
  • #2614: Check for zero return value from casecmp in Performance/casecmp. (@segiddins)
  • #2647: Allow xstr interpolations in Lint/LiteralInInterpolation. (@segiddins)
  • Report a violation when freeze is called on a frozen string literal in Style/RedundantFreeze. (@segiddins)
  • #2641: Fix crashing on empty methods with block args in Performance/RedundantBlockCall. (@segiddins)
  • Lint/DuplicateMethods doesn't crash when class_eval is used with an implicit receiver. (@lumeet)
  • #2654: Fix handling of unary operations in Style/RedundantParentheses. (@lumeet)
  • #2661: Style/Next doesn't crash when auto-correcting modifier if/unless. (@lumeet)
  • #2665: Make specs pass when running on Windows. (@jonas054)
  • #2691: Do not register an offense in Performance/TimesMap for calling map or collect on a variable named times. (@rrosenblum)
  • #2689: Change Performance/RedundantBlockCall to respect parentheses usage. (@rrosenblum)
  • #2694: Fix caching when using a different JSON gem such as Oj. (@stormbreakerbg)
  • #2707: Change Lint/NestedMethodDefinition to respect Class.new and Module.new. (@owst)
  • #2701: Do not consider assignments to the same variable as useless if later assignments are within a loop. (@owst)
  • #2696: Style/NestedModifier adds parentheses around a condition when needed. (@lumeet)
  • #2666: Fix bug when auto-correcting symbol literals in Lint/LiteralInInterpolation. (@lumeet)
  • #2664: Performance/Casecmp can auto-correct case comparison to variables and method calls without error. (@rrosenblum)
  • #2729: Fix handling of hash literal as the first argument in Style/RedundantParentheses. (@lumeet)
  • #2703: Handle byte order mark in Style/IndentationWidth, Style/ElseAlignment, Lint/EndAlignment, and Lint/DefEndAlignment. (@jonas054)
  • #2710: Fix handling of fullwidth characters in some cops. (@seikichi)
  • #2690: Fix alignment of operands that are part of an assignment in Style/MultilineOperationIndentation. (@jonas054)
  • #2228: Use the config of a related cop whether it's enabled or not. (@madwort)
  • #2721: Do not register an offense for constants wrapped in parentheses passed to rescue in Style/RedundantParentheses. (@rrosenblum)
  • #2742: Fix Style/TrailingCommaInArguments & Style/TrailingCommaInLiteral for inline single element arrays. (@annih)
  • #2768: Allow parentheses after keyword not in Style/MethodCallParentheses. (@lumeet)
  • #2758: Allow leading underscores in camel case variable names. (@mmcguinn)

Changes

  • Remove Style/SpaceAfterControlKeyword and Style/SpaceBeforeModifierKeyword as the more generic Style/SpaceAroundKeyword handles the same cases. (@lumeet)
  • Handle comparisons with != in Performance/casecmp. (@segiddins)
  • #2684: Do not base Style/FrozenStringLiteralComment on the version of Ruby that is running. (@rrosenblum)
  • #2732: Change the default style of Style/SignalException to only_raise. (@bbatsov)