Repository navigation
Releases
Releases · rubocop/rubocop
RuboCop v1.92.2
Bug fixes
- #16147: Fix a false negative for
Lint/RedundantCopDisableDirectivewhen autocorrection shifts lines. (@koic) - #16104: Fix a false negative for
Style/FloatDivisionwith a trailing comment. (@a-lavis) - #16146: Fix a false positive for
Lint/RedundantCopDisableDirectivewith a repeated disable. (@koic) - #16176: Fix a false positive for
Style/RaiseArgswithEnforcedStyle: compactand constructor arguments. (@bbatsov) - #16183: Fix an error for
Layout/RescueEnsureAlignmentwith index or-assignment. (@koic) - #16158: Fix an error for
Style/NumericPredicatewith a predicate nested in the receiver of another. (@Starlexxx) - #16125: Fix an error for
Style/RedundantConditionwith a nested modifierif. (@koic) - #16175: Fix an incorrect autocorrect for
Layout/HashAlignmentwith multiple styles and pairs on one line. (@bbatsov) - #16139: Fix an incorrect autocorrect for
Layout/LineLengthwith code after a heredoc opener. (@koic) - #16160: Fix an incorrect autocorrect for
Layout/SingleLineBlockChainwithStyle/MapToSet. (@koic) - #16002: Fix an incorrect autocorrect for
Layout/SpaceBeforeBlockBraceswith a brace after a line continuation. (@Starlexxx) - #16175: Fix an incorrect autocorrect for
Layout/SpaceBeforeBlockBraceswith a brace after a heredoc body. (@bbatsov) - #16180: Fix an incorrect autocorrect for
Lint/InterpolationCheckin a split string. (@Starlexxx) - #16143: Fix an incorrect autocorrect for
Lint/ParenthesesAsGroupedExpressionwith a command call operand. (@koic) - #16170: Fix an incorrect autocorrect for
Lint/RedundantSplatExpansionwithArray.newas a method argument. (@wleeaf) - #16178: Fix an incorrect autocorrect for
Style/AndOrwith a binary operator method operand. (@bbatsov) - #16150: Fix an incorrect autocorrect for
Style/AndOrwith a command call that takes adoblock. (@Starlexxx) - #16178: Fix an incorrect autocorrect for
Style/AndOrwith a method chained onto a command call's do block. (@bbatsov) - #16178: Fix an incorrect autocorrect for
Style/AndOrwith a negated command call that takes a do block. (@bbatsov) - #16178: Fix an incorrect autocorrect for
Style/AndOrwith a pattern matching, ternary, range ordefined?operand. (@bbatsov) - #16178: Fix an incorrect autocorrect for
Style/AndOrwithsupercalled with arguments. (@bbatsov) - #16171: Fix an incorrect autocorrect for
Style/CaseEqualitywith a non-numeric range. (@wleeaf) - #16127: Fix an incorrect autocorrect for
Style/ClassAndModuleChildrenwithStyle/DataInheritance. (@koic) - #16154: Fix an incorrect autocorrect for
Style/EndlessMethodwith modifier cops. (@koic) - #16167: Fix an incorrect autocorrect for
Style/HashAsLastArrayItemwithLayout/MultilineArrayBraceLayout. (@Starlexxx) - #16126: Fix an incorrect autocorrect for
Style/HashLookupMethodwith forwarded or splatted arguments. (@koic) - #16163: Fix an incorrect autocorrect for
Style/MethodCallWithArgsParentheseswithLayout/HeredocArgumentClosingParenthesis. (@koic) - #16124: Fix an incorrect autocorrect for
Style/MethodDefParentheseswith a line continuation. (@koic) - #16159: Fix an incorrect autocorrect for
Style/ParenthesesAroundConditionwith a command call assignment. (@koic) - #16137: Fix an incorrect autocorrect for
Style/QuotedSymbolswith a trailing backslash. (@koic) - #16176: Fix an incorrect autocorrect for
Style/RaiseArgscompact style withe.classas the exception. (@bbatsov) - #16169: Fix an incorrect autocorrect for
Style/RaiseArgswith a heredoc message. (@Starlexxx) - #16132: Fix an incorrect autocorrect for
Style/RaiseArgswith a parenthesizedraise. (@koic) - #16136: Fix an incorrect autocorrect for
Style/ReduceToHashwith a heredoc. (@koic) - #16162: Fix an incorrect autocorrect for
Style/RedundantBeginwith a ternary branch. (@koic) - #16176: Fix an incorrect autocorrect for
Style/RedundantExceptionwith a heredoc in a multiline call. (@bbatsov) - #16177: Fix an incorrect autocorrect for
Style/SingleLineMethodswith code after the method'send. (@bbatsov) - #16157: Fix an incorrect autocorrect for
Style/StringConcatenationwhen joining parts forms an interpolation. (@Starlexxx) - #16161: Fix an incorrect autocorrect for
Style/TrailingCommaInArgumentswith argument forwarding. (@koic) - #16182: Fix an infinite loop for
Layout/EmptyLinesAfterModuleInclusionwith a logical operator. (@Starlexxx) - #16138: Fix an infinite loop for
Layout/EmptyLinesAroundClassBodywithLayout/IndentationWidth. (@koic) - #16142: Fix an infinite loop for
Layout/EndAlignmentwith a class or module assigned to a constant. (@Starlexxx) - #16128: Fix an infinite loop for
Layout/ExtraSpacingwithLayout/LineLength. (@koic) - #16148: Fix an infinite loop for
Layout/SpaceAroundOperatorswithLayout/LineContinuationSpacing. (@Starlexxx) - #16123: Fix an infinite loop for
Layout/SpaceAroundOperatorswith hash rockets aligned on non-adjacent lines. (@koic) - #16144: Fix an infinite loop for
Layout/SpaceInsideBlockBraceswithLayout/BlockAlignment. (@koic) - #16145: Fix an infinite loop for
Layout/SpaceInsideRangeLiteralwith a nested endless range. (@koic) - #15609: Fix an infinite loop and an incorrect autocorrect for
Style/EndlessMethodwhen the method definition itself has a modifierif/unless/while/untilor is followed byand/or/&&/||. (@Starlexxx) - #16153: Fix an infinite loop for
Style/RedundantBeginandStyle/IfUnlessModifierwithLayout/SpaceInsideParens. (@koic) - #16168: Fix false positives for
Lint/NestedPercentLiteralwhen a percent literal contains format sequences such as%-5sor%.2f. (@Vitalini) - #16149: Fix false positives in
Style/RedundantSelfwith a splat in multiple assignment. (@koic) - #16134: Fix
Layout/HashAlignmentdeleting a double splat before a pair on the same line. (@Starlexxx) - #14045: Warn about any obsolete configuration shipped by a plugin, naming the plugin and its file, instead of reporting a renamed cop against the user's
.rubocop.yml. (@ihamzatarar)
Changes
RuboCop v1.92.1
Bug fixes
- #16063: Fix an error for
Layout/HashAlignmentwith a key spanning multiple lines. ([@koic][]) - #15776: Fix an error in server mode when the configuration file is missing or empty. ([@MIbtehajNasar][])
- #15939: Fix an error for
Style/ClassAndModuleChildrenwhen compacting a namespace that contains another compactable one. ([@Starlexxx][]) - #16047: Fix an error for
Style/ClassMethodsDefinitionswith a nestedclass << self. ([@Starlexxx][]) - #16041: Fix an error for
Style/EmptyStringInsideInterpolationwith nested conditionals. ([@koic][]) - #16067: Fix an error for
Style/RedundantInterpolationUnfreezewith an unfrozen string interpolated into another one. ([@Starlexxx][]) - #16055: Fix an error for
Style/RescueModifierwith a rescue modifier in the rescue body of another one. ([@Starlexxx][]) - #15968: Fix an error when the target Ruby version lookup cannot list a directory for a gemspec or read a version file or lockfile, and stop the gemspec search at the project root. ([@koic][])
- #16073: Fix an incorrect autocorrect for
Layout/ClassStructurewith code after a heredoc. ([@koic][]) - #16026: Fix an incorrect autocorrect for
Layout/DotPositionwith a dot removed by another cop. ([@koic][]) - #16107: Fix an incorrect autocorrect for
Layout/HeredocArgumentClosingParenthesiswithLayout/MultilineMethodCallBraceLayout. ([@koic][]) - #16117: Fix an incorrect autocorrect for
Layout/LineLengthwith an unparenthesized method definition. ([@koic][]) - #16061: Fix an incorrect autocorrect for
Layout/MultilineHashBraceLayoutwith a nested literal. ([@koic][]) - #16033: Fix an incorrect autocorrect for
Layout/MultilineMethodCallIndentationwith a single-line block. ([@koic][]) - #16077: Fix an incorrect autocorrect for
Layout/SingleLineBlockChainwithStyle/RedundantSort. ([@koic][]) - #16098: Fix an incorrect autocorrect for
Lint/AmbiguousRegexpLiteralwith a regexp hash key. ([@koic][]) - #16086: Fix an incorrect autocorrect for
Lint/SymbolConversionwith hash value omission. ([@koic][]) - #16099: Fix an incorrect autocorrect for
Naming/RescuedExceptionsVariableNamewithStyle/HashSyntax. ([@koic][]) - #16023: Fix an incorrect autocorrect for
Style/AccessModifierDeclarationswithStyle/EndlessMethod. ([@Starlexxx][]) - #16024: Fix an incorrect autocorrect for
Style/AccessModifierDeclarationswith an endless method command body. ([@Starlexxx][]) - #16111: Fix an incorrect autocorrect for
Style/AccessModifierDeclarationswith an endless method with ado...endblock body. ([@koic][]) - #16056: Fix an incorrect autocorrect for
Style/AndOrwith a safe navigation command call. ([@Starlexxx][]) - #16043: Fix an incorrect autocorrect for
Style/AndOrwithStyle/ReturnNil. ([@koic][]) - #16020: Fix an incorrect autocorrect for
Style/ArgumentsForwardingwhen another call forwards anonymous arguments without the block. ([@Starlexxx][]) - #16038: Fix an incorrect autocorrect for
Style/ArgumentsForwardingwith index assignment and setter methods. ([@koic][]) - #15067: Fix an incorrect autocorrect for
Style/CollectionQueryingwhencountis used without a block. ([@Starlexxx][], [@wwenrr][]) - #16032: Fix an incorrect autocorrect for
Style/CombinableLoopswithLayout/BlockEndNewline. ([@Starlexxx][]) - #16072: Fix an incorrect autocorrect for
Style/CombinableLoopswithLayout/RedundantLineBreak. ([@koic][]) - #16036: Fix an incorrect autocorrect for
Style/ConcatArrayLiteralswith a multiline call without parentheses. ([@koic][]) - #16100: Fix an incorrect autocorrect for
Style/EmptyStringInsideInterpolationwith a command call. ([@koic][]) - #16023: Fix an incorrect autocorrect for
Style/EndlessMethodwith a command body in a method definition passed as an argument. ([@Starlexxx][]) - #16110: Fix an incorrect autocorrect for
Style/EndlessMethodwith ado...endblock body in a method definition passed as an argument. ([@koic][]) - #16042: Fix an incorrect autocorrect for
Style/EndlessMethodwith a negated command call. ([@koic][]) - #16029: Fix an incorrect autocorrect for
Style/EndlessMethodwithStyle/GuardClause. ([@koic][]) - #16058: Fix an incorrect autocorrect for
Style/EndlessMethodwithStyle/RaiseArgs. ([@Starlexxx][]) - #16045: Fix an incorrect autocorrect for
Style/Forwith a numbered oritblock. ([@koic][]) - #16046: Fix an incorrect autocorrect for
Style/Forwith block parameters invalid as loop variables. ([@koic][]) - #16044: Fix an incorrect autocorrect for
Style/ForwithStyle/ItBlockParameter. ([@koic][]) - #16031: Fix an incorrect autocorrect for
Style/GuardClausewith a heredoc in a multiline guard clause. ([@Starlexxx][]) - #16031: Fix an incorrect autocorrect for
Style/GuardClausewith a heredoc in the kept branch. ([@Starlexxx][]) - #16021: Fix an incorrect autocorrect for
Style/HashAsLastArrayItemwithStyle/TrailingCommaInArrayLiteral. ([@Starlexxx][]) - #16027: Fix an incorrect autocorrect for
Style/IfUnlessModifierwith a heredoc in the condition. ([@koic][]) - #16025: Fix an incorrect autocorrect for
Style/Lambdawith extra spacing before the block. ([@koic][]) - #16054: Fix an incorrect autocorrect for
Style/MethodCallWithArgsParentheseswith a trailing comma. ([@koic][]) - #16080: Fix an incorrect autocorrect for
Style/MethodCallWithArgsParentheseswith a parenthesized argument. ([@koic][]) - #16074: Fix an incorrect autocorrect for
Style/MethodCallWithArgsParentheseswith an assignment used as an argument. ([@koic][]) - #16118: Fix an incorrect autocorrect for
Style/MethodDefParentheseswithLayout/LineLength. ([@koic][]) - #16039: Fix an incorrect autocorrect for
Style/MixinGroupingwith parenthesized arguments. ([@koic][]) - #16085: Fix an incorrect autocorrect for
Style/MutableConstantwith an omitted hash value. ([@koic][]) - #16075: Fix an incorrect autocorrect for
Style/MutableConstantwithRecursive: trueandStyle/HashAsLastArrayItem. ([@koic][]) - #16030: Fix an incorrect autocorrect for
Style/RaiseArgsdropping required parentheses. ([@Starlexxx][]) - #16101: Fix an incorrect autocorrect for
Style/RedundantInterpolationUnfreezewithLayout/MultilineMethodCallBraceLayout. ([@koic][]) - #16108: Fix an incorrect autocorrect for
Style/RedundantInterpolationUnfreezewith a comment. ([@koic][]) - #16040: Fix an incorrect autocorrect for
Style/RedundantSelfAssignmentBranchwith assignment used as value. ([@koic][]) - #16076: Fix an incorrect autocorrect for
Style/RedundantSortwith a line break before the accessor. ([@koic][]) - #16102: Fix an incorrect autocorrect for
Style/RequireOrderwithout a trailing newline. ([@koic][]) - #16037: Fix an incorrect autocorrect for
Style/SendWithLiteralMethodNamewithLayout/MultilineMethodArgumentLineBreaks. ([@koic][]) - #16062: Fix an incorrect autocorrect for
Style/StructInheritancewithStyle/MethodCallWithArgsParentheses. ([@koic][]) - #16103: Fix an incorrect autocorrect for
Style/SymbolProcwithStyle/TrailingCommaInArguments. ([@koic]...
RuboCop v1.92.0
New features
- #15895: Add an MCP tool that explains what cops do. (@bbatsov)
- #15700: Add
--explain COPto describe what a cop does, how it is configured, and the examples from its documentation. (@bbatsov) - #15699: Add
--max-offenses-per-copto cap how many offenses a single cop reports. (@bbatsov) - #15948: Let MCP autocorrection apply the corrections of
AutoCorrect: contextualcops when asked to. (@bbatsov) - #15945: Let MCP autocorrection preview its changes as a diff. (@bbatsov)
- #15915: Let MCP inspection cap how many offenses each cop reports. (@bbatsov)
- #15930: Let MCP tools choose which cops run and which files they check. (@bbatsov)
- #14666: Make
Lint/UselessAssignmentregister an offense for a block-captured variable that is never referenced. (@IslamElsayed) - #15695: Report autocorrection edits in the JSON formatter. (@bbatsov)
- #15940: Report cop errors and warnings per file in
--format json. (@bbatsov) - #15945: Report the offenses MCP autocorrection leaves behind. (@bbatsov)
Bug fixes
- #15780: Fix an error for
Lint/MissingCopEnableDirectivewhen anenable-nextornext +Copdirective suspends an openrubocop:disable, and a false positive fornext -Copscopes larger thanMaxRangeSize. (@bbatsov) - #16005: Fix a false negative for
Security/JSONLoadwithcreate_additionsas the second argument. (@bbatsov) - #15994: Fix a false positive for
Layout/LineEndStringConcatenationIndentationwith an already aligned part. (@bbatsov) - #15842: Fix a false positive for
Style/ExplicitBlockArgumentwhen the method uses argument forwarding (...). (@bbatsov) - #15843: Fix a false positive for
Style/NegativeArrayIndexwith a different length receiver. (@bbatsov) - #15841: Fix a false positive for
Style/RedundantFreezewith an arithmetic operation on a non-numeric receiver. (@bbatsov) - #15843: Fix a false positive for
Style/Samplewith an endless range, which was corrected to asamplecall of the wrong size. (@bbatsov) - #15842: Fix a false positive for
Style/SuperArgumentswhen the method has a destructuring parameter. (@bbatsov) - #15740: Fix an error for
Layout/EmptyLinesAroundMethodBodywhen a method's arguments span multiple lines and the method ends on the last argument's line. (@viralpraxis) - #15860: Fix an error for
Layout/HeredocIndentationwith a heredoc nested in another heredoc. (@Starlexxx) - #15876: Fix an error for
Lint/EmptyConditionalBodywithelseon the condition line. (@koic) - #16008: Fix an error for
Lint/UnescapedBracketInRegexpwhen using regexp_parser 2.11.2 and earlier. (@bbatsov) - #15897: Fix an error for
Metrics/ClassLengthwith a long singleton class in LSP mode. (@bbatsov) - #15749: Fix an error for
Style/ClassAndModuleChildrenwhen a compact class or module definition appears in an expression, such as an assignment value or a method argument. (@viralpraxis) - #15750: Fix an error for
Style/ClassAndModuleChildrenwhen usingEnforcedStyle: compactand the nested body is indented less thanLayout/IndentationWidth'sWidth. (@viralpraxis) - #15764: Fix an error for
Style/ClassAndModuleChildrenwhenEnforcedStyle: compactcompacts an irregularly indented definition andLayout/IndentationStyleenforces tabs. (@viralpraxis) - #15946: Fix an error for
Style/ExplicitBlockArgumentwith the shorthand call syntax. (@Starlexxx) - #15861: Fix an error for
Style/FormatStringwithformatnested informat. (@Starlexxx) - #15694: Fix an error for
Style/HashSyntaxwhen ano_mixed_keysstyle forces hash rockets on a hash whose value repeats its key. (@viralpraxis) - #16007: Fix an error for
Style/IfInsideElsewhen the nestedifshares a line with other code. (@bbatsov) - #15867: Fix an error for
Style/MapIntoArraywhen pushing into a numbered oritblock parameter. (@Starlexxx) - #15949: Fix an error for
Style/Nextwith a modifier condition wrapping a block that has its own offense. (@Starlexxx) - #15797: Fix an error for
Style/RedundantConditionwhen autocorrecting a redundant condition nested in theelsebranch of another one. (@koic) - #15928: Fix an error for
Style/Semicolonwhen a semicolon follows an unparenthesized keyword parameter or hash pattern. (@viralpraxis) - #15714: Fix an error for
Style/YodaConditionwhen one operand of a comparison contains another comparison the cop also corrects. (@viralpraxis) - #16011: Fix an error for the
pacmanformatter, which crashed withundefined method 'winsize'whether or not the output was a terminal. (@bbatsov) - #15731: Fix an error when caching offenses whose correction or justification cannot be represented as UTF-8. (@viralpraxis)
- #16015: Fix an error when cleaning up a result cache that can't be written. (@bbatsov)
- #15702: Fix an error when interrupting RuboCop with
Ctrl-C. (@viralpraxis) - #16015: Fix an error when the cache directory or config can't be accessed under a sandbox. (@bbatsov)
- #16015: Fix an error when the result cache directory exists but can't be written. (@bbatsov)
- #15817: Fix an incorrect autocorrect for
Gemspec/OrderedDependencieswhen the same dependency declaration appears more than once in the gemspec. (@viralpraxis) - #15903: Fix an incorrect autocorrect for
Layout/ClassStructurewith blank line cops. (@koic) - #15984: Fix an incorrect autocorrect for
Layout/ClassStructurewithLayout/EmptyLinesAroundAccessModifier. (@koic) - #15997: Fix an incorrect autocorrect for
Layout/ClassStructurewith a heredoc constant. (@bbatsov) - #15697: Fix an incorrect autocorrect for
Layout/EmptyLinesAroundBlockBodywhen usingEnforcedStyle: empty_linesand the empty line would precede a leading dot method call. (@viralpraxis) - #15953: Fix an incorrect autocorrect for
Layout/EmptyLinesAroundBlockBodywithdoon its own line. (@koic) - #15818: Fix an incorrect autocorrect for
Layout/ExtraSpacingcop withForceEqualSignAlignment: truewhenStyle/SelfAssignmentrewrites the same assignment. (@Starlexxx) - [#15997](https://github.com/rubocop/ruboco...
RuboCop v1.91.0
New features
- #15631: Add a preview channel for unstable behavior. (@bbatsov)
- #15627: Add a SARIF formatter. (@bbatsov)
- #15686: Add
AllCops: FailLevel, the configuration equivalent of--fail-level. (@bbatsov) - #15650: Add
AllowedDirectivesoption toStyle/DisableCopsWithinSourceCodeDirective, exempting directive kinds such as generatedrubocop:todocomments. (@bbatsov) - #15629: Add
--changedto inspect only the files git says changed. (@bbatsov) - #15628: Add
--diffto preview autocorrection without writing files. (@bbatsov) - #15615: Add new
Lint/MisplacedMagicCommentcop to flag magic comments in positions where Ruby ignores them. (@bbatsov) - #15600: Add the
rubocop:enable-nextdirective to re-enable cops for the next statement only. (@bbatsov) - #15600: Add the
rubocop:nextdirective, combiningpush-style+/-arguments withdisable-next's statement scope. (@bbatsov) - #15363: Let a cop's entry in the default configuration carry a
Previewsection with the defaults it is expected to adopt in the next major release, applied underPreview. (@bbatsov)
Bug fixes
- #15349: Fix a false positive for
Style/RedundantRegexpCharacterClasswith\8/\9. (@bbatsov) - #15646: Fix an error for
Layout/ElseAlignmentwhenelseis used withrescuein aclass,module, or singleton class body. (@viralpraxis) - #15613: Fix an error for
Layout/HashAlignmentwhen a hash value starts on the line below its key. (@viralpraxis) - #15623: Fix an error for
Layout/HashAlignmentwhen the first pair of a hash omits its value, and an incorrect autocorrection when a later pair does. (@viralpraxis) - #15602: Fix an error for
Layout/IndentationWidthon under-indented code with tab indentation. (@Starlexxx) - #15672: Fix an error for
Lint/RedundantCopDisableDirectivewhen a file contains more than onerubocop:push/rubocop:poppair. (@koic) - #15625: Fix an error for
Style/AccessModifierDeclarationswhen a body repeats the same access modifier. (@viralpraxis) - #15603: Fix an error for
Style/AccessModifierDeclarationswithEnforcedStyle: inlinewhen an access modifier is the body of anifwithout anelsebranch. (@viralpraxis) - #15604: Fix an error for
Style/ConstantVisibilitywhen a visibility declaration splats anything other than an array literal, e.g.private_constant(*constants(false)). (@viralpraxis) - #15647: Fix an error for
Style/DocumentationMethodwhen an inlinemodule_function/ruby2_keywordsdefis preceded by another argument. (@viralpraxis) - #15680: Fix an error for
Style/EndlessMethodwhen a method definition is nested inside another method definition. (@viralpraxis) - #15674: Fix an error for
Style/FloatDivisionwhen usingEnforcedStyle: fdivand one operand of a float division is itself a parenthesized float division. (@viralpraxis) - #15624: Fix an error for
Style/HashLookupMethodwhen the looked-up key is itself a hash lookup. (@viralpraxis) - #15642: Fix an error for
Style/HashSyntaxwhen hash rockets are enforced and a hash value repeats its key. (@viralpraxis) - #15634: Fix an incorrect autocorrect for
Lint/LiteralAsConditionwhen the other operand is a parenthesizedreturn. (@Starlexxx) - #15648: Fix an incorrect autocorrect for
Lint/ParenthesesAsGroupedExpressionwhen the parentheses containand,or,not, or a modifier expression. (@Starlexxx) - #15612: Fix an incorrect autocorrect for
Naming/BlockForwardingwithStyle/MethodDefParentheses. (@Starlexxx) - #15680: Fix an incorrect autocorrect for
Style/EndlessMethodwhen usingEnforcedStyle: require_alwaysand the method body has arescueorensureclause. (@viralpraxis) - #15669: Fix an incorrect autocorrect for
Style/FloatDivisionwhen usingEnforcedStyle: fdivand the divisor is a method call with parenthesized arguments. (@viralpraxis) - #15678: Fix an incorrect autocorrect for
Style/Forwhen usingEnforcedStyle: forand the block body has arescueorensureclause. (@viralpraxis) - #15645: Fix an incorrect autocorrect for
Style/GuardClausewithStyle/MissingElse. (@Starlexxx) - #15668: Fix an incorrect autocorrect for
Style/MethodCallWithArgsParentheseswhenEnforcedStyle: omit_parenthesesis used together withStyle/TrailingCommaInArguments. (@viralpraxis) - #15347: Fix an incorrect autocorrect for
Style/NestedModifier. (@bbatsov) - #15347: Fix an incorrect autocorrect for
Style/NonNilCheck. (@bbatsov) - #15347: Fix an incorrect autocorrect for
Style/Notwith a flip-flop or assignment. (@bbatsov) - #15349: Fix an incorrect autocorrect for
Style/RedundantDoubleSplatHashBraceswith a bracedmergeargument. (@bbatsov) - #15349: Fix an incorrect autocorrect for
Style/RedundantParenthesesaroundand/or. (@bbatsov) - #15349: Fix an incorrect autocorrect for
Style/RedundantRegexpConstructorwith%r{}delimiters. (@bbatsov) - #15614: Fix an infinite loop between
Layout/ArgumentAlignmentandLayout/HashAlignmentwith separator style. (@Starlexxx) - #15599: Fix an infinite loop error for
Layout/CommentIndentationwhen many comment blocks with the same indentation are separated by empty lines. (@Starlexxx) - #15597: Fix an infinite loop error for
Layout/EmptyLinesAfterModuleInclusionwhen a module inclusion is directly beforerescue. (@Starlexxx) - #15617: Fix an infinite loop between
Layout/ExtraSpacingwithForceEqualSignAlignmentandLayout/SpaceAroundOperators. (@Starlexxx) - #15638: Fix an infinite loop error for
Layout/FirstArrayElementIndentationwithLayout/ArrayAlignmentwhenEnforcedStyle: with_fixed_indentationis configured. (@RedZapdos123) - #15639: Fix an infinite loop error for
Layout/FirstParameterIndentationwithLayout/ParameterAlignmentwhenEnforcedStyle: with_fixed_indentationis configured. (@RedZapdos123) - #15619: Fix an infinite loop for
Layout/LineLengthwithSplitStrings: truewhen the split point lands on a trailing space. (@Starlexxx) - #15675: Fix an infinite loop between
Layout/SpaceAroundOperatorsandLayout/ExtraSpacingwithForceEqualSignAlignment: truefor aligned operator assignments. (@Starlexxx) - #15598: Fix an infinite ...
RuboCop v1.90.0
New features
- #15073: Add
AllowTrailingCommentoption toStyle/DisableCopsWithinSourceCodeDirective. (@bbatsov) - #9505: Add
disable-nextdirectives scoped to the following statement. (@bbatsov) - #15550: Add
--display-suppressedoption to also report offenses suppressed by directive comments, including their--justification in the JSON formatter. (@bbatsov) - #15523: Add new
Lint/ArgumentMismatchcop. (@bbatsov) - #15594: Add new
Lint/SuperArgumentMismatchcop. (@bbatsov) - #15581: Add new
Style/TimeNowcop. (@Starlexxx) - #15111: Add
NumberOfEmptyLinesoption toLayout/EmptyLineAfterMagicCommentto configure the minimum number of empty lines required after magic comments. (@alejofraga) - #13037: Add
--report-unused-todo-entriesto catch rotting todo files. (@bbatsov) - #15559: Add new
Style/DirectiveScopecop to flagdisable/enablepairs and disable-onlypush/popscopes that wrap a single statement and can usedisable-nextinstead. (@bbatsov) - #15547: Make
Lint/RedundantCopEnableDirectiveflag# rubocop:popdirectives without a matching# rubocop:push. (@bbatsov)
Bug fixes
- #15584: Fix a crash in
Lint/NameTypoandLint/UnusedPrivateMethodon string literals with invalid encoding. (@bbatsov) - #15541: Fix a false negative for
Lint/OutOfRangeRegexpRefwhen a preceding element access with a non-string literal argument (e.g.hash[:key]) discarded the tracked capture count. (@koic) - #7958: Add todo comments for skipped unsafe corrections with
--disable-uncorrectable. (@bbatsov) - #15569: Fix an error for the built-in language server when a
workspace/executeCommandrequest has no document URI in its arguments. (@koic) - #15410: Fix an incorrect autocorrect for
Naming/BinaryOperatorParameterName. (@bbatsov) - #15576: Fix an incorrect autocorrect for
Style/Samplewhenshuffleis given arandom:argument; the offense is still reported but no longer autocorrected, sinceshuffleandsampleconsume a seeded generator differently and would select different elements. (@koic) - #15590: Fix an infinite loop error for
Layout/FirstArgumentIndentationwhenEnforcedStyle: with_fixed_indentationis specified forLayout/ArgumentAlignmentandLayout/FirstMethodArgumentLineBreakis enabled withAllowMultilineFinalElement: true. (@Starlexxx) - #15588: Fix
RuboCop::Cop::IgnoredMethodsandRuboCop::Cop::IgnoredPatternbeing unreachable afterrequire 'rubocop'. (@SeanLF) - #8349: Don't autocorrect away directives for unknown cops. (@bbatsov)
- #7894: Don't flag disables of pending cops as redundant. (@bbatsov)
- #9963: Fix false negatives for
Layout/ExtraSpacing. (@Starlexxx) - #15525: Fix false negatives in
Layout/LineLengthwhen a constant path likeHttp::UploadedFilematchesURISchemescase-insensitively. (@koic) - #13941: Fix false positives for
Lint/UselessConstantScopingwhen assigning withClass.new,Module.new,Struct.new, orData.defineafterprivate. (@pdobb) - #15526: Fix false positives in
Layout/MultilineMethodCallIndentationwhen a line has multiple single-line blocks before a multiline block. (@koic) - #15538: Fix false positives in
Lint/ConstantReassignmentwhen a constant is assigned in compact-style namespaces (e.g.module A::B). (@alex-tan) - #15517: Fix false positives in
Lint/RedundantSafeNavigationwhenInferNonNilReceiveris enabled and the receiver name is rebound by a nested block (itor a shadowed block parameter). (@koic) - #15572: Fix
RuboCop::Cop::Registry#freezeto freeze its internal collections, so that registering a lazily loaded cop after the freeze fails fast at the registration site instead of corrupting the registry. (@koic) - #15585: Make
Lint/DuplicateMethodshonorsilence_redefinition_of_methodandredefine_methodas intentional redefinitions. (@bbatsov) - #15558: Fix
--display-suppressedreporting aniljustificationwhen the offense is loaded from the result cache. (@corsonknowles) - #10449: Fix
Layout/ClassStructureautocorrection producing a wrong order when an element cannot be moved, and make offenses report the category that actually blocks the expected order. (@koic) - #15568: Fix
Lint/NameTyporegistering false positives for names provided by a gem whose namespace the project reopens, and for constants read from a namespace with an unresolved ancestor. (@HoneyryderChuck) - #15556: Fix
Lint/UnusedPrivateMethodretaining every pastproject_indexobject it has seen (and the index graph reachable from each), rather than only the most recent one. This caused unbounded memory growth in long-lived processes such asrubocop --server. (@bquorning) - #10046: Fix
Lint/UselessMethodDefinitionfalse positive for methods with**kwargs. (@bbatsov) - #15589: Fix
--lspand--mcpbeing silently ignored when the RuboCop server is running: they now start the protocol server in the current process instead of being forwarded to the server as a lint request. (@koic) - #11148: Merge department and cop-level
Excludesettings. (@bbatsov) - #15531: Fix a regression in RuboCop 1.89 where the modifier cops could produce lines longer than
Layout/LineLengthMaxwhen exemptions likeAllowedPatternsmatched the result. (@bbatsov) - #15574: Fix an incorrect warning such as
AllCops does not support TargetRailsVersion parameterwhen a plugin declares a customAllCopskey with a nil value and another plugin is loaded after it. (@koic) - #9543: Preserve escape notation in
Style/StringConcatenationautocorrect. (@bbatsov) - #11119: Preserve persistent cop instances across files. (@Eljees)
- #13022: Fix
rubocop .(and other relative directory arguments) needlessly traversing directories excluded by the configuration, which made it much slower thanrubocopin projects with large ignored trees. (@bbatsov) - #15561: Fix
Lint/RedundantCopDisableDirectiveandLint/RedundantCopEnableDirectiveleaving a directive's--reason behind when removing the directive. (@corsonknowles) - #15593: Fix false positives for
Lint/UnusedPrivateMethodfor private definitions of Ruby runtime hooks likeinheritedandconst_missing. (@bbatsov) - #15547: Make
Lint/MissingCopEnableDirectivesuggest# rubocop:popinstead of# rubocop:enablefor an unclosed# rubocop:push. (@bbatsov) - #14379: Suppress multi-line offenses with a directive on any of their lines. (@bbatsov)
- [#15593](https://github.com/rubocop/ru...
RuboCop v1.89.0
New features
- #15492: Add AllCops/ProjectIndexIncludesGems for bundle-wide indexing. (@bbatsov)
- #15498: Add
DelegatingMethodsoption toLint/DuplicateMethodsto register customdelegate-shaped methods. (@bbatsov) - #15042: Add
DisallowedCopsconfiguration option toStyle/DisableCopsWithinSourceCodeDirective. (@hammadxcm) - #15441: Add new
AllowYARDCommentBlockSeparatoroption toLayout/LeadingCommentSpace. (@koic) - #15466: Add new
Lint/DeprecatedReferencecop to detect references to methods and constants documented as@deprecated, powered by the project index. (@bbatsov) - #15491: Add new
Lint/NameTypocop. (@bbatsov) - #15468: Add new
Lint/UnusedPrivateMethodcop for project-wide dead-code detection via the project index (disabled by default). (@bbatsov) - #14598: Make
Style/DisableCopsWithinSourceCodeDirectiveimpossible to disable via directive comments when explicitly enabled withEnabled: true. (@rafaelfranca) - #15511: Support
textDocument/codeActionrequests in the built-in language server, so LSP clients that request code actions (Eglot, Helix, Flycheck, ...) can apply RuboCop's autocorrects, not only clients that read them off the published diagnostic. (@bbatsov) - #8565: Support
NewCopsin department configuration to enable pending cops per department, including cops added up to a specific version (e.g.Style: NewCops: '1.19'). (@koic) - #9373: Support autocorrection for tab indentation in
Layout/IndentationWidthandStyle/ClassAndModuleChildren. (@ioquatix, @koic)
Bug fixes
- #15257: Fix a false negative for
Lint/ToEnumArgumentswhen explicit extra keyword arguments are passed (e.g.def m(x:); to_enum(:m, x: x, y: 1); end), which raisesArgumentErrorwhen the enumerator is used. (@RedZapdos123) - #15452: Fix a false positive for
Layout/HashAlignmentwhen usingEnforcedHashRocketStyle: tableand a hash key spans multiple lines. (@dduugg) - #12269: Fix a false positive for
Lint/UselessAssignmentwith modifier conditions. (@bbatsov) - #13786: Fix a false positive for
Lint/Voidwith setter methods. (@bbatsov) - #15507: Fix a false positive for
Naming/VariableNumberwhen using an empty symbol hash key. (@koic) - #15284: Fix a false positive for
Style/MutableConstantwithData.define. (@bbatsov) - #15483: Fix a false positive for
Style/MissingRespondToMissingwhenrespond_to_missing?is defined in a reopening of the class andUseProjectIndexis enabled. (@bbatsov) - #15500: Fix an error for
Lint/LiteralAsConditionwhen a literal condition has an empty branch. (@koic) - #15499: Fix an error for
Lint/UselessRuby2Keywordswhenruby2_keywordsis used with a symbol but no method definition is found. (@koic) - #15453: Fix an error for
Metrics/MethodLengthwhen a method contains a heredoc and__ENCODING__. (@koic) - #15442: Fix an error for
Style/ArrayIntersectcop when the block-based check callsmember?/include?without an explicit receiver. (@dduugg) - #15434: Fix an error for
Style/NegativeArrayIndexcop. (@viralpraxis) - #15469: Fix an error for
Style/RedundantFormatwhen a format string uses a positional argument number beyond the 64-bit range. (@koic) - #15454: Fix an error for
Style/RedundantFormatwhen the argument for a positional variable width is missing. (@koic) - #15298: Fix an incorrect autocorrect for
Lint/LiteralInInterpolation. (@bbatsov) - #15515: Fix an incorrect autocorrect for
Style/ArrayIntersectwhen using safe navigationnone?with a block. (@koic) - #15364: Fix an incorrect autocorrect for
Style/MultipleComparisonthat dropped an allowed method comparison appearing between the compared values. (@bbatsov) - #15367: Fix an incorrect autocorrect for
Style/RedundantFileExtensionInRequirethat produced invalid Ruby when a backslash preceded the.rbextension. (@bbatsov) - #12017: Fix
Lint/Voidto no longer autocorrect a constant used in a void context, since removing it can change behavior through constant autoloading side effects. (@bbatsov) - #14797: Avoid cache writes during server checks. (@sjh9714)
- #15484: Fix false negatives for
Lint/InheritExceptionwhenExceptionis inherited indirectly through a project class (UseProjectIndex). (@bbatsov) - #15357: Fix a false negative for
Lint/AmbiguousAssignmentwhen using attribute or index assignment. (@sngsmz) - #9571: Fix false negatives in
Layout/ClassStructurewhen class body elements are wrapped inbeginblocks. (@koic) - #9570: Fix false negatives in
Layout/ClassStructurewhen usingprivate_class_methodorpublic_class_methoddef modifiers. (@koic) - #15438: Fix false positives in
Style/ArrayIntersectwhen the receiver ofinclude?in a block is not an array literal. (@koic) - #15445: Fix false positives in
Style/MultilineIfThenwhen using the Prism parser engine and anelsifwithoutthenfollows a branch usingthenwith a body on the same line. (@koic) - #15058: Fix false positives in
Lint/DuplicateMethodsfor anonymous classes (Class.new) passed as arguments to the same named-receiver method call (e.g.T.cast). EachClass.newblock is an independent class, so methods defined in different blocks should not be treated as duplicates. (@rafaelfranca) - #15486: Fix false negatives for
Style/RedundantConstantBaseinside namespaces when the constant provably resolves identically without::(UseProjectIndex). (@bbatsov) - #15505: Fix incompatible autocorrect between
Style/LambdaandStyle/SymbolProcproducing a syntax error like->(x)(&:method)when both cops run onlambda { |x| x.method }. (@koic) - #15481: Fix cross-file offenses depending on which files are inspected: the project index now always covers the whole project (
UseProjectIndex). (@bbatsov) - #13794: Fix
Layout/LineLengthautocorrection for endless methods with block bodies. (@hervetatche) - #15462: Fix an error for
Lint/ConstantReassignmentwhen a built-in constant name is assigned andUseProjectIndexis enabled. (@bbatsov) - #15321: Fix
Style/ClassAndModuleChildrenignoringEnforcedStyleForClassesandEnforcedStyleForModules, and skip autocorrection when mixed per-type styles make the result ambiguous. (@bbatsov) - #15122: Fix false positive in
Layout/MultilineMethodCallIndentationwhen a line has multiple chained calls before a single-line block. (@hammadxcm)...
RuboCop v1.88.2
Bug fixes
- #15417: Fix a false negative for
Lint/ToJSON, which did not flag singletondef self.to_jsondefinitions. (@bbatsov) - #15418: Fix a false negative for
Lint/UnreachableCode, which only flagged the first statement after a flow-of-control statement instead of every unreachable statement that followed it. (@bbatsov) - #15416: Fix a false negative for
Lint/UselessNumericOperation, which only flagged bare method-call receivers and ignored local variables, instance/class/global variables, and constants (e.g.@x + 0,CONST * 1). (@bbatsov) - #15419: Fix a false negative for
Lint/Voidwhere safe-navigation calls to nonmutating methods (e.g.x&.sort) were not flagged whenCheckForMethodsWithNoSideEffectsis enabled. (@bbatsov) - #15421: Fix a false negative for
Style/ArrayIntersectwith the block form usinginclude?(e.g.array1.any? { |e| array2.include?(e) }), which was only detected formember?. (@bbatsov) - #15420: Fix a false negative for
Style/CollectionCompact, which did not flaggrep_v(nil)/grep_v(NilClass)on a safe-navigation call (e.g.array&.grep_v(nil)). (@bbatsov) - #15422: Fix a false negative for
Style/DefWithParentheseswith a single-line definition whose body follows a semicolon (e.g.def foo(); end), where the parentheses can be safely omitted. (@bbatsov) - #15388: Fix a false negative for
Style/MixinUsagewhen including multiple modules in one statement. (@bbatsov) - #15388: Fix a false negative for
Style/ModuleFunctionwhen the module body is a single statement. (@bbatsov) - #15388: Fix a false negative for
Style/RedundantCurrentDirectoryInPathwith double-quoted strings containing interpolation. (@bbatsov) - #15395: Fix a false negative for
Style/RedundantHeredocDelimiterQuoteswith double-quoted delimiters whose body contains interpolation or escapes. (@bbatsov) - #15409: Fix a false positive for
Gemspec/DuplicatedAssignmentwith multiple specifications. (@bbatsov) - #15403: Fix a false positive for
Layout/CommentIndentationwith a comment above an inline access modifier (e.g.private def foo) whenLayout/AccessModifierIndentationis configured withEnforcedStyle: outdent. (@grk) - #15372: Fix a false positive for
Style/InvertibleUnlessConditionwith a multi-statement begin condition. (@bbatsov) - #15360: Fix an incorrect autocorrect for
Style/ArgumentsForwardingandStyle/MethodDefParentheseswhen autocorrection conflicts while adding parentheses to method definition arguments. (@koic) - #15417: Fix an incorrect autocorrect for
Lint/ToJSONthat produced invalid Ruby (def to_json(*_args)()) when the method had explicit empty parentheses. (@bbatsov) - #15426: Fix an incorrect autocorrect for
Style/MethodCallWithoutArgsParentheseswhen empty parentheses span multiple lines and the method call has a block. (@koic) - #15328: Fix a false positive for
Style/HashConversionwith a splat argument, which previously produced an invalid hash literal. (@bbatsov) - #15338: Fix a false positive for
Style/HashLookupMethodwith safe navigation, where the suggested bracket form would be the unreadablehash&.[](key). (@bbatsov) - #15397: Fix an incorrect autocorrect for
Style/IdenticalConditionalBranchesthat hoisted the moved expression to column zero instead of matching the surrounding indentation. (@bbatsov) - #15372: Fix an incorrect autocorrect for
Style/InvertibleUnlessConditionwith mixed&&/||conditions, which lost the required parentheses when inverting. (@bbatsov) - #15428: Fix an incorrect autocorrect for
Style/TrivialAccessorswhenAllowPredicates: falseis set and a trivial reader is defined as a predicate class method. (@koic) - #15402: Fix an infinite loop and file corruption for
Layout/LineLengthwithSplitStringswhen an over-long string is indented under a multi-line parent. (@bbatsov) - #15384: Fix a false positive and a false negative for
Style/MissingRespondToMissingwhenmethod_missingis defined at the top level or alongside sibling classes. (@bbatsov) - #15432: Fix false positives in
Layout/ElseAlignmentwhen usingelsewithin a block that is part of a larger expression. (@koic) - #15423: Fix false positives in
Layout/MultilineMethodCallIndentationwhen a method chain is nested inside a parenthesized argument list or a grouped expression within a hash pair value. (@koic) - #15424: Fix
Style/StructInheritanceautocorrect dropping leading indentation when class is inside a module or namespace. (@amckinnie) - #15325: Fix
Style/DocumentationMethodignoringAllowedMethodsfor inline modifier defs. (@bbatsov) - #15369: Fix a false positive for
Style/LambdaCallwhen the argument list contains a comment, which the autocorrect would have dropped. (@bbatsov)
Changes
- #15430: Improve performance of offense reporting by not allocating a new source range per offense outside of embedded sources. (@bbatsov)
- #15430: Improve investigation performance by dispatching
on_new_investigation,on_investigation_end, andon_other_fileonly to cops that refine them, and by skippingafter_*dispatch when no cop needs it. (@bbatsov) - #15430: Improve performance of the per-file cop relevancy check by skipping gem requirement evaluation for cops without gem requirements. (@bbatsov)
- #15430: Improve
Lint/Debuggerperformance on code without debugger calls. (@bbatsov) - #15430: Improve autocorrection performance by keeping corrections in memory across inspection iterations and writing each corrected file only once. (@bbatsov)
- #15415: Mark
Lint/NumericOperationWithConstantResultautocorrect as unsafe because it drops the operands, discarding their side effects and silencing cases where the result is not actually constant (e.g.x / xraises whenxis0). (@bbatsov) - #15430: Improve performance of cops using
AllowedPatterns,ForbiddenPatterns, andAllowedMethodsby compiling the configured patterns only once. (@bbatsov) - #15430: Improve performance of
Style/IfUnlessModifierand other modifier cops on files with many comments or conditionals. (@bbatsov)
RuboCop v1.88.1
Bug fixes
- #15408: Fix a crash for
Bundler/GemCommentwith a non-literal gem option key. (@bbatsov) - #9571: Fix a crash for
Layout/ClassStructurewhen a class body is a single safe-navigation call (e.g.test&.private_methods(def foo; end)). (@bbatsov) - #15413: Fix a crash for
Gemspec/DevelopmentDependencieswhenAllowedGemsis nil. (@bbatsov) - #15404: Fix a crash for
Metrics/MethodLengthwith an anonymousdefine_method. (@bbatsov) - #15414: Fix a crash for
Naming/InclusiveLanguagewith nil or emptyFlaggedTerms. (@bbatsov) - #15405: Fix a crash for
Security/IoMethodswith a non-string-literal argument. (@bbatsov) - #15330: Fix a crash for
Style/EmptyStringInsideInterpolationwith a modifier conditional. (@bbatsov) - #15351: Fix a crash for
Style/OpenStructUsewith a bareOpenStructroot node. (@bbatsov) - #15379: Fix a crash for
Style/TrailingUnderscoreVariablewhen a nested destructuring group consists only of underscore variables. (@bbatsov) - #15412: Fix a false negative for
Security/MarshalLoadwith a proc argument. (@bbatsov) - #15386: Fix a false negative for
Style/MethodDefParentheseswith named rest arguments underEnforcedStyle: require_no_parentheses. (@bbatsov) - #15396: Fix a false negative for
Style/MultilineMethodSignaturewhere a signature that fits on one line was skipped because the multi-line source length was measured instead of the collapsed width. (@bbatsov) - #15386: Fix a false negative for
Style/OptionalArgumentswith singleton methods. (@bbatsov) - #15383: Fix a false negative for
Style/RedundantFilterChainwith numbered-parameter blocks. (@bbatsov) - #15290: Fix a false negative for
Lint/ToEnumArgumentswhen a braced hash is passed to keyword parameters (e.g.to_enum(:m, { required: required })), which raisesArgumentErrorwhen the enumerator is used. (@RedZapdos123) - #11956: Fix a false positive for
Naming/FileNamewhen a class or module name contains multiple consecutiveAllowedAcronyms. (@camallen) - #15324: Fix a false positive for
Style/DirEmptywith a block. (@bbatsov) - #15326: Fix a false positive for
Style/EmptyLiteralwith numbered anditblock parameters. (@bbatsov) - #15335: Fix a false positive for
Style/EnvHome. (@bbatsov) - #15345: Fix a false positive for
Style/InlineCommentwithrubocop:tododirectives. (@bbatsov) - #15348: Fix a false positive for
Style/MultilineIfThen. (@bbatsov) - #15383: Fix a false positive for
Style/NumericPredicatewhen an allowed method encloses a numbered-parameter oritblock. (@bbatsov) - #15389: Fix a false positive for
Style/OptionHashwhen the options hash is forwarded with an explicitsuper. (@bbatsov) - #15350: Fix a false positive for
Style/RedundantFormatwith a lone format sequence. (@bbatsov) - #15374: Fix a false positive for
Style/RedundantSelfwith a rescue exception variable. (@bbatsov) - #15376: Fix a false positive for
Style/Semicolonwith a semicolon inside a string literal. (@bbatsov) - #15398: Fix an incorrect autocorrect for
Layout/ConditionPositionthat dropped a body statement sharing the condition's line via a semicolon. (@bbatsov) - #15399: Fix an incorrect autocorrect for
Layout/EmptyCommentthat deleted a heredoc when removing an empty comment trailing its opener. (@bbatsov) - #15400: Fix an incorrect autocorrect for
Layout/EmptyLineBetweenDefsthat inserted a blank line inside a heredoc body when an endless method's body was a heredoc. (@bbatsov) - #15401: Fix an incorrect autocorrect for
Layout/SpaceAroundOperatorsthat turned**=and/=compound assignments into**//, dropping the assignment. (@bbatsov) - #15406: Fix an incorrect autocorrect for
Naming/MemoizedInstanceVariableName. (@bbatsov) - #15411: Fix an incorrect autocorrect for
Naming/RescuedExceptionsVariableName. (@bbatsov) - #15319: Fix an incorrect autocorrect for
Style/DataInheritancewith a brace block. (@bbatsov) - #15323: Fix an incorrect autocorrect for
Style/EmptyCaseConditionas ayield/superargument. (@bbatsov) - #15323: Fix an incorrect autocorrect for
Style/EmptyCaseConditionwith low-precedencewhenvalues. (@bbatsov) - #15322: Fix an incorrect autocorrect for
Style/EmptyClassDefinitionwith a namespaced constant. (@bbatsov) - #15336: Fix an incorrect autocorrect for
Style/EmptyHeredoc. (@bbatsov) - #15332: Fix an incorrect autocorrect for
Style/EvenOdd. (@bbatsov) - #15329: Fix an incorrect autocorrect for
Style/ExactRegexpMatchwith a single quote. (@bbatsov) - #15333: Fix an incorrect autocorrect for
Style/FileNull. (@bbatsov) - #15334: Fix an incorrect autocorrect for
Style/For. (@bbatsov) - #15331: Fix an incorrect autocorrect for
Style/FormatStringwith a low-precedence argument. (@bbatsov) - #15331: Fix an incorrect autocorrect for
Style/FormatStringwith a splat argument. (@bbatsov) - #15337: Fix an incorrect autocorrect for
Style/HashSlice. (@bbatsov) - #15327: Fix an incorrect autocorrect for
Style/HashSyntaxwith a multi-pair bracelessreturn. (@bbatsov) - #15368: Fix an incorrect autocorrect for
Style/IfWithSemicolonthat changed semantics when the condition was an assignment, by parenthesizing it in the resulting ternary. (@bbatsov) - #15340: Fix an incorrect autocorrect for
Style/KeywordArgumentsMergingwith a block-pass argument. (@bbatsov) - #15387: Fix an incorrect autocorrect for
Style/KeywordParametersOrderthat inserted a spurious blank line when a keyword optional parameter already trailed the parameters list. (@bbatsov) - #15341: Fix an incorrect autocorrect for
Style/MapIntoArraywith a block-pass argument. (@bbatsov) - #15342: Fix an incorrect autocorrect for
Style/MethodCallWithoutArgsParentheseswithit()in a numbered block. (@bbatsov) - #15343: Fix an incorrect autocorrect for
Style/MinMaxComparisonwithunless. (@bbatsov) - #15348: Fix an incor...
RuboCop v1.88.0
New features
- #15166: Add a new
Recursiveoption toStyle/MutableConstant. When enabled, the cop checks and freezes mutable literals nested inside arrays and hashes. The option is disabled by default to preserve existing behavior. (@paracycle)
Bug fixes
- #15220: Fix a bad autocorrect for
Lint/RedundantSplatExpansionwhen splatting an empty literal (e.g.when *[]orrescue *[]), which expanded to invalid or semantically different code. (@bbatsov) - #15221: Fix a bad autocorrect for
Lint/RegexpAsConditionwhen the regexp literal is negated (e.g.if !/foo/), which inverted the condition. (@bbatsov) - #15242: Fix a bad autocorrect for
Lint/SymbolConversionwhen the receiver is an interpolated string containing an embedded double quote (e.g."foo#{bar}\"qux".to_sym), which produced a syntax error. (@bbatsov) - #15270: Fix a crash for
Style/CombinableLoopswhen aforloop has an empty body, and stop autocorrecting consecutiveforloops whose iteration variables differ (which produced code referencing an undefined variable). (@bbatsov) - #15272: Fix a crash for
Style/ConstantVisibilitywhen a visibility declaration has a numeric literal argument (e.g.private_constant 42). (@bbatsov) - #15215: Fix a false negative for
Lint/OrderedMagicCommentswhen anencodingmagic comment is preceded by a magic comment other thanfrozen_string_literal(e.g.shareable_constant_value). (@bbatsov) - #15228: Fix a false negative for
Lint/RedundantWithIndexwhen the block takes no arguments (e.g.ary.each_with_index { do_something }). (@bbatsov) - #15230: Fix a false negative for
Lint/RequireRelativeSelfPathwhen requiring the current file by name with its extension (e.g.require_relative 'foo.rb') and the file path is absolute. (@bbatsov) - #15229: Fix a false negative for
Lint/SafeNavigationChainwhen an ordinary method is chained after a parenthesized safe navigation call (e.g.(x&.foo).bar). (@bbatsov) - #15225: Fix a false negative for
Lint/SafeNavigationWithEmptywhen the receiver of&.empty?is a local variable, instance variable, constant, or other non-method-call expression. (@bbatsov) - #15231: Fix a false negative for
Lint/SendWithMixinArgumentwhensend/public_send/__send__is called with no explicit receiver or with aselfreceiver (e.g.send(:include, Bar)). (@bbatsov) - #15248: Fix a false negative for
Lint/ToEnumArgumentswhen more positional arguments are passed than the method accepts (e.g.def m(x); to_enum(:m, x, extra); end), which raisesArgumentErrorwhen the enumerator is used. (@bbatsov) - #15249: Fix a false negative for
Lint/UnescapedBracketInRegexpwhen an unescaped]is preceded by an escaped backslash (e.g./abc\\]123/). (@bbatsov) - #15267: Fix a false positive for
Style/ArrayIntersectWithSingleElementwith a splat argument (e.g.array.intersect?([*foo])), which is not a single element and was incorrectly rewritten toarray.include?(*foo). (@bbatsov) - #15272: Fix a false positive for
Style/ColonMethodCallwith chained JRuby interop calls (e.g.Java::com::something_method). (@bbatsov) - #15271: Fix a false positive for
Style/ConditionalAssignmentwithEnforcedStyle: assign_inside_conditionwhen assigning anunlesswithout anelsebranch (e.g.x = unless cond; 1; end), which was rewritten to move the assignment inside theunlessand changed behavior when the condition was true. (@bbatsov) - #14401: Fix a false positive for
Layout/BlockAlignmentwithEnforcedStyleAlignWith: start_of_linewhen a block is passed as a method argument. (@augustocbx) - #15216: Fix a false positive for
Lint/RaiseExceptionwhenraise Exceptionis used inside a module nested within an allowed implicit namespace (e.g.Gem). (@bbatsov) - #15219: Fix a false positive for
Lint/RedundantDirGlobSortwhensortis given a comparator block or a block-pass argument, which is not redundant with the default sorting. (@bbatsov) - #15224: Fix a false positive for
Lint/ShadowingOuterLocalVariablewhen a block argument has the same name as a pattern variable from a differentinbranch of the samecase. (@bbatsov) - #15239: Fix a false positive for
Lint/SuppressedExceptionInNumberConversionwhen the numeric constructor already passesexception: false(e.g.Integer(arg, exception: false) rescue nil), which also produced an autocorrect with a duplicateexception: falsekeyword. (@bbatsov) - #15243: Fix a false positive for
Lint/TopLevelReturnWithArgumentwhen areturnwith an argument is inside a numbered-parameter block or anitblock. (@bbatsov) - #15245: Fix a false positive for
Lint/UselessRuby2Keywordswhenruby2_keywordsin a nested class or module refers to a method of the same name defined in an outer scope. (@bbatsov) - #15246: Fix a false positive for
Lint/UselessSetterCallwhen a multiple assignment uses nested destructuring (e.g.(a, b), c = arg, other_arg), which misaligned variables with the right-hand side values. (@bbatsov) - #15125: Fix a false positive for
Style/ZeroLengthPredicatewhenFile::Stat.new(...).size.zero?is used. (@augustocbx) - #15196: Fix
--start-serverto wait until the server is running before returning, which fixes a flaky--restart-serverspec and a race for commands run right after starting the server. (@koic) - #15272: Fix
Style/Aliasnot detecting block scope for numbered-parameter anditblocks, which caused a false positive foralias_methodand a false negative foraliasinside such blocks. (@bbatsov) - #15281: Fix an incorrect autocorrect when
Style/IfUnlessModifierandStyle/Nextcorrect the same conditional. (@fynsta) - #15260: Fix an error for
Style/FileWritewhen a literal or variable is passed towritein the block form. (@koic) - #15276: Fix an error for
Style/RedundantFormatwhen the format string is a heredoc with format arguments. (@fynsta) - #15270: Fix an incorrect autocorrect for
Style/AndOrwhen an operand isnext,break, oryieldwith an argument (e.g.foo and next 1), which produced invalid Ruby likefoo && next 1. (@bbatsov) - #15267: Fix an incorrect autocorrect for
Style/ArrayFirstLastwhenarr[0]/arr[-1]is the target of a compound assignment (e.g.arr[0] += 1), which producedarr.first += 1and raisedNoMethodError. (@bbatsov) - #15267: Fix an incorrect autocorrect for
Style/ArrayIntersectwhere a negated predicate on a safe-navigation chain (e.g.a&.intersection(b)&.none?) was rewritten to!a&.intersect?(b), flipping the result when the receiver isnil. (@bbatsov) - #15273: Fix an incorrect autocorrect for
Style/BlockDelimitersthat converted a single-linedo...endblock containing a block-levelrescueorensureto{...}, producing invalid Ruby. (@bbatsov) - #15268: Fix an incorrect autocorrect for
Style/CaseEqualitywhen the argument is an operator or unary expression (e.g.Array === a + b), which produced mis-parsed code likea + b.is_a?(Array). (@bbatsov) - #15268: Fix an incorrect autocorrect for `Style/ClassEqualit...
RuboCop v1.87.0
New features
- #15167: Add
--enable-all-copsand--disable-all-copscommand line options that overrideAllCops/EnabledByDefaultandAllCops/DisabledByDefaultin configuration files. (@koic) - #15185: Make
Layout/EmptyLineAfterGuardClauseaccept the new# simplecov:disableand# simplecov:enabledirective comments. (@koic) - #15173: Add optional Rubydex integration via
AllCops/UseProjectIndexto enable cross-file detection inLint/ConstantReassignment(experimental). (@koic)
Bug fixes
- #15168: Fix false positives in
Lint/ParenthesesAsGroupedExpressionwhen the first argument is a call-like expression with its own parentheses, such asyield(...). (@koic) - #15188: Fix false positives in
Style/YodaConditionwhen one side is an array or hash literal containing non-literal elements. (@koic) - #15182: Fix incorrect autocorrect for
Style/Aliascausing a syntax error when the return value ofalias_methodis used, such as an argument topublic,private,protected, ormodule_function, or the right-hand side of an assignment. (@koic) - #15174: Fix incorrect autocorrect for
Style/ClassAndModuleChildrencausing a syntax error when the namespace contains a method call (e.g.,class self.class::Foo; end). (@koic) - #15180: Fix incorrect autocorrect for
Style/FileWritecausing a syntax error when the written heredoc is chained with another method call. (@koic) - #15186: Fix incorrect autocorrect for
Style/HashConversioncausing a syntax error whenHash[...]is passed an anonymous splat (*). (@koic) - #15192: Fix incorrect autocorrect for
Style/StructInheritancecausing a syntax error when the inheritedStruct.newis called without parentheses. (@koic) - #15170: Fix an infinite loop for
Layout/RedundantLineBreakwhen a single-line block is chained with a safe navigation method call. (@koic) - #15175: Fix
Layout/IndentationWidthto indent block bodies relative to the method selector for trailing-dot multi-line method chains whenEnforcedStyleAlignWithisrelative_to_receiver. (@ddbrendan) - #15135: Fix incorrect autocorrect for
Style/RedundantParenthesesthat swallowed chained method calls into a trailing inline comment on the line above the closing parenthesis. (@hammadxcm) - #15184: Fix various typos and grammar mistakes in documentation and cop descriptions. (@bbatsov)