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 loop error for
Lint/AssignmentInConditionwhen an assignment is insidedefined?. (@Starlexxx) - #15665: Fix an infinite loop between
Style/EmptyMethodandStyle/SingleLineMethodswithAllowIfMethodIsEmpty: false. (@Starlexxx) - #15644: Fix an infinite loop error for
Style/EndlessMethodwhen an indented method definition would exceedLayout/LineLengthonce made endless. (@viralpraxis) - #15651: Fix an infinite loop error for
Style/EndlessMethodwhen a method body is a block spread over several lines. (@viralpraxis) - #15618: Fix an infinite loop between
Style/ParenthesesAroundConditionwithAllowSafeAssignment: falseandLint/AssignmentInCondition. (@Starlexxx) - #15662: Fix an infinite loop between
Layout/SpaceAroundBlockParametersandLayout/SpaceInsideParenswhen the two cops enforce conflicting styles for a lambda's parameter parentheses. (@viralpraxis) - #15670: Fix an infinite loop for
Style/NumericLiteralPrefixwith signed literals. (@dylanpulver) - #15636: Fix
Lint/CopDirectiveSyntaxfalsely reporting multiple directives when valid reason text mentions another directive. (@RedZapdos123) - #15679: Fix false positives in
Lint/DuplicateMethodsfor singleton methods in separate anonymous classes. (@rafaelfranca) - #15347: Fix incorrect autocorrects for
Style/NilComparisonwith precedence-sensitive operands. (@bbatsov) - #15611: Fix
Lint/ArgumentMismatchregistering false positives forFoo.newcalls, which are documented as out of scope but were checked against whichevernewthe project index could reach. (@HoneyryderChuck) - #15610: Fix
Lint/ArgumentMismatchregistering false positives for calls that resolve to a private method onObject, such as a baredefwritten at the top level of a DSL file. (@HoneyryderChuck) - #15600: Make
rubocop:push+Coparguments enable cops that are disabled in the configuration. (@bbatsov) - #9325: Merge
Excludewith the default configuration and with inherited files underPreview. (@bbatsov) - #15626: Fix
RemoteConfigfailing to follow relative HTTP redirects for remote configuration files. (@RedZapdos123) - #15661: Fix the result cache reading and processing non-regular files. (@viralpraxis)
- #15621: Fix incorrect analysis results when the result cache cannot compute a file checksum, which could serve one file's cached results for another file. (@koic)
- #11696: Fix
Style/DataInheritanceto not register an offense when the class body defines constants, nested classes, or nested modules. (@MatheusRich) - #15655: Fix
Style/StructInheritanceto not register an offense when the class body defines constants, nested classes, or nested modules. (@MatheusRich)
Changes
- #15363: Disable
Metrics/MethodLength,Metrics/AbcSize,Metrics/ClassLength,Metrics/ModuleLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/BlockLength,Metrics/ParameterListsandMetrics/BlockNestingunderPreview, ahead of them being disabled by default in RuboCop 2.0. (@bbatsov) - #15363: Disable
Style/IfUnlessModifier,Style/GuardClause,Style/Next,Style/ClassAndModuleChildren,Style/DoubleNegation,Style/NumericPredicate,Style/SpecialGlobalVars,Style/PerlBackrefs,Style/FrozenStringLiteralComment,Style/FormatStringToken,Style/FormatString,Style/RegexpLiteral,Style/SignalException,Style/Lambda,Style/ParallelAssignment,Style/RaiseArgs,Style/ModuleFunction,Style/BlockDelimiters,Style/NumericLiterals,Style/NegatedIf,Naming/VariableNumber,Naming/HeredocDelimiterNaming,Layout/EmptyLineAfterGuardClauseandBundler/OrderedGemsunderPreview, ahead of them being disabled by default in RuboCop 2.0. (@bbatsov) - #15363: Set
AllCops: FailLeveltowarningunderPreview, so that style offenses are reported without failing the build, ahead of it becoming the default in RuboCop 2.0. (@bbatsov) - #15363: Set the community-preferred
EnforcedStyleofStyle/StringLiterals,Style/StringLiteralsInInterpolation,Layout/CaseIndentation,Layout/EndAlignment,Layout/MultilineMethodCallIndentation,Layout/MultilineOperationIndentation,Layout/FirstHashElementIndentation,Layout/FirstArrayElementIndentation,Layout/ParameterAlignment,Layout/ArgumentAlignment,Style/EmptyMethod,Style/Alias,Style/RescueStandardErrorandStyle/TernaryParenthesesunderPreview, ahead of them becoming the defaults in RuboCop 2.0. (@bbatsov) - #15363: Set the
EnforcedStyleofStyle/SymbolArrayandStyle/WordArraytobracketsunderPreview, ahead of it becoming the default in RuboCop 2.0. (@bbatsov) - #15686: Derive a cop's default severity from its department:
Securitycops now report aswarningandMetricscops asrefactor. (@bbatsov) - #15363: Disable
Style/DocumentationunderPreview, ahead of it being disabled by default in RuboCop 2.0. (@bbatsov) - #15616: Enable
Lint/CopDirectiveSyntaxby default, so directives that silently disable nothing are reported. (@bbatsov) - #15601: Make
Style/DirectiveScopeconvert single-statement signedpush/popscopes andenable/disablepairs to thenext,enable-nextanddisable-nextforms. (@bbatsov) - #15650: Make
AllowedCopsandDisallowedCopsofStyle/DisableCopsWithinSourceCodeDirectivematch department names as well as cop names. (@bbatsov) - #15616: Remove
Style/DoubleCopDisableDirective, superseded byLint/CopDirectiveSyntax, which now reports and corrects more than one directive on a line. (@bbatsov) - #15607: Recognize
warn_indentas a magic comment. This fixes a false positive forLayout/EmptyLineAfterMagicCommentand makesLint/OrderedMagicCommentsandStyle/MagicCommentFormataware of it. (@koic) - #15650: Rename the
AllowTrailingCommentoption ofStyle/DisableCopsWithinSourceCodeDirectivetoAllowWithReason. (@bbatsov)