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)