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: Fix false positives for
Lint/UnusedPrivateMethodwhen a method name is composed with an interpolated symbol or string prefix. (@bbatsov)
Changes
- #15585: Add
AllowedCrossFilePathsoption toLint/DuplicateMethodsto skip cross-file duplicates in configured paths. (@bbatsov) - #15593: Add
AllowedNamesandAllowedPatternsoptions toLint/UnusedPrivateMethod. (@bbatsov) - #15587: Backfill missing
StyleGuidemetadata for 21 cops and fix four broken style guide links. (@bbatsov) - #15530: Improve
Lint/DeprecatedReferenceperformance by short-circuitingdeprecated?. (@connorshea) - #15529: Improve
Lint/NameTypoperformance by deferring the literal-name scan. (@connorshea) - #15554: Change
AllowForAlignmentto no longer treat a same-indentation line beyond the enclosing block as an alignment anchor forLayout/ExtraSpacing,Layout/SpaceAroundOperators, andLayout/SpaceBeforeFirstArg. (@koic) - #15582: Make JUnit formatter output
<testcase>elements only for cops enabled for each inspected file, instead of all cops. (@koic) - #15562: Make
Layout/SpaceAroundOperatorsaware of endless method definitions. (@koic) - #14673: Make
Lint/CopDirectiveSyntaxcatch keyword typos and unknown cop names. (@bbatsov) - #12219: Stop honoring wrongly-namespaced disable directives. (@bbatsov)