Releases: rubocop/rubocop
Releases · rubocop/rubocop
RuboCop 0.47
New features
- #3822: Add
Rails/FilePath
cop. (@iguchi1124) - #3821: Add
Security/YAMLLoad
cop. (@cyberdelia) - #3816: Add
Security/MarshalLoad
cop. (@cyberdelia) - #3757: Add Auto-Correct for
Bundler/OrderedGems
cop. (@pocke) Style/FrozenStringLiteralComment
now supports the stylenever
that will remove thefrozen_string_literal
comment. (@rrosenblum)- #3795: Add
Lint/MultipleCompare
cop. (@pocke) - #3772: Allow exclusion of certain methods for
Metrics/BlockLength
. (@NobodysNightmare) - #3804: Add new
Lint/SafeNavigationChain
cop. (@pocke) - #3670: Add
CountBlocks
boolean option toMetrics/BlockNesting
. It allows blocks to be counted towards the nesting limit. (@georgyangelov) - #2992: Add a configuration to
Style/ConditionalAssignment
to toggle offenses for ternary expressions. (@rrosenblum) - #3824: Add new
Perfomance/RegexpMatch
cop. (@pocke) - #3825: Add new
Rails/SkipsModelValidations
cop. (@rahulcs) - #3737: Add new
Style/MethodCallWithArgsParentheses
cop. (@dominh) - Renamed
MethodCallParentheses
toMethodCallWithoutArgsParentheses
. (@dominh) - #3854: Add new
Rails/ReversibleMigration
cop. (@sue445) - #3872: Detect
String#%
with hash literal. (@backus) - #2731: Allow configuration of method calls that create methods for
Lint/UselessAccessModifier
. (@pat)
Changes
- #3820: Rename
Lint/Eval
toSecurity/Eval
. (@cyberdelia) - #3725: Disable
Style/SingleLineBlockParams
by default. (@tejasbubane) - #3765: Add a validation for supported styles other than EnforcedStyle.
AlignWith
,IndentWhenRelativeTo
andEnforcedMode
configurations are renamed. (@pocke) - #3782: Add check for
add_reference
method byRails/NotNullColumn
cop. (@pocke) - #3761: Update
Style/RedundantFreeze
message fromFreezing immutable objects is pointless.
toDo not freeze immutable objects, as freezing them has no effect.
. (@lucasuyezu) - #3753: Change error message of
Bundler/OrderedGems
to mentionAlphabetize Gems
. (@tejasbubane) - #3802: Ignore case when checking Gemfile order. (@breckenedge)
- Add missing examples in
Lint
cops documentation. (@enriikke) - Make
Style/EmptyMethod
cop aware of class methods. (@drenmi) - #3871: Add check for void
defined?
andself
byLint/Void
cop. (@pocke)
Bug fixes
- #3751: Avoid crash in
Rails/EnumUniqueness
cop. (@pocke) - #3766: Avoid crash in
Style/ConditionalAssignment
cop with masgn. (@pocke) - #3770:
Style/RedundantParentheses
Don't flag raised to a power negative numeric literals, since removing the parentheses would change the meaning of the expressions. (@amogil) - #3750: Register an offense in
Style/ConditionalAssignment
when the assignment spans multiple lines. (@rrosenblum) - #3775: Avoid crash in
Style/HashSyntax
cop with an empty hash. (@pocke) - #3783: Maintain parentheses in
Rails/HttpPositionalArguments
when methods are defined with them. (@kevindew) - #3786: Avoid crash
Style/ConditionalAssignment
cop with mass assign method. (@pocke) - #3749: Detect corner case of
Style/NumericLitterals
. (@kamaradclimber) - #3788: Prevent bad auto-correct in
Style/Next
when block has nested conditionals. (@drenmi) - #3807: Prevent
Style/Documentation
andStyle/DocumentationMethod
from mistaking RuboCop directives for class documentation. (@drenmi) - #3815: Fix false positive in
Style/IdenticalConditionalBranches
cop when branches have same line at leading. (@pocke) - Fix false negative in
Rails/HttpPositionalArguments
where offense would go undetected if one of the request parameter names matched one of the special keyword arguments. (@deivid-rodriguez) - Fix false negative in
Rails/HttpPositionalArguments
where offense would go undetected if the:format
keyword was used with other non-special keywords. (@deivid-rodriguez) - #3406: Enable cops if Enabled is not explicitly set to false. (@metcalf)
- Fix
Lint/FormatParameterMismatch
for splatted last argument. (@zverok) - #3853: Fix false positive in
RedundantParentheses
cop with multiple expression. (@pocke) - #3870: Avoid crash in
Rails/HttpPositionalArguments
. (@pocke) - #3869: Prevent
Lint/FormatParameterMismatch
from breaking when#%
is passed an empty array. (@drenmi) - #3879: Properly handle Emacs and Vim magic comments for
FrozenStringLiteralComment
. (@backus) - #3736: Fix to remove accumulator return value by auto-correction in
Style/EachWithObject
. (@pocke)
RuboCop 0.46
New features
- #3600: Add new
Bundler/DuplicatedGem
cop. (@jmks) - #3624: Add new configuration option
empty_lines_special
toStyle/EmptyLinesAroundClassBody
andStyle/EmptyLinesAroundModuleBody
. (@legendetm) - Add new
Style/EmptyMethod
cop. (@drenmi) Style/EmptyLiteral
will now auto-correctHash.new
when it is the first argument being passed to a method. The arguments will be wrapped with parenthesis. (@rrosenblum)- #3713: Respect
DisabledByDefault
in parent configs. (@aroben) - New cop
Rails/EnumUniqueness
checks for duplicate values defined in enum config. (@olliebennett) - New cop
Rails/EnumUniqueness
checks for duplicate values defined in enum config hash. (@olliebennett) - #3451: Add new
require_parentheses_when_complex
style toStyle/TernaryParentheses
cop. (@swcraig) - #3600: Add new
Bundler/OrderedGems
cop. (@tdeo) - #3479: Add new configuration option
IgnoredPatterns
toMetrics/LineLength
. (@jonas054)
Changes
- The offense range for
Performance/FlatMap
now includes any parameters that are passed toflatten
. (@rrosenblum) - #1747: Update
Style/SpecialGlobalVars
messages with a reminder torequire 'English'
. (@ivanovaleksey) - Checks
binding.irb
call byLint/Debugger
cop. (@pocke) - #3742: Checks
min
andmax
call byPerfomance/CompareWithBlock
cop. (@pocke)
Bug fixes
- #3662: Fix the auto-correction of
Lint/UnneededSplatExpansion
when the splat expansion is inside of another array. (@rrosenblum) - #3699: Fix false positive in
Style/VariableNumber
on variable names ending with an underscore. (@bquorning) - #3687: Fix the fact that
Style/TernaryParentheses
cop claims to correct uncorrected offenses. (@Ana06) - #3568: Fix
--auto-gen-config
behavior forStyle/VariableNumber
. (@jonas054) - Add
format
as an acceptable keyword argument forRails/HttpPositionalArguments
. (@aesthetikx) - #3598: In
Style/NumericPredicate
, don't reportx != 0
orx.nonzero?
as the expressions have different values. (@jonas054) - #3690: Do not register an offense for multiline braces with content in
Style/SpaceInsideBlockBraces
. (@rrosenblum) - #3746:
Lint/NonLocalExitFromIterator
does not warn aboutreturn
in a block which is passed toObject#define_singleton_method
. (@AlexWayfer)
RuboCop 0.45 (The Halloween Release)
New features
- #3615: Add autocorrection for
Lint/EmptyInterpolation
. (@pocke) - Make
PercentLiteralDelimiters
enforce delimiters around%I()
too. (@bronson) - #3408: Add check for repeated values in case conditionals. (@swcraig)
- #3646: Add new
Lint/EmptyWhen
cop. (@drenmi) - #3246: Add list of all cops to the manual (generated automatically from a rake task). (@sihu)
- #3647: Add
--force-default-config
option. (@jawshooah) - #3570: Add new
MultilineIfModifier
cop to avoid usage of if/unless-modifiers on multiline statements. (@tessi) - #3631: Add new
Style/SpaceInLambdaLiteral
cop to check for spaces in lambda literals. (@swcraig) - Add new
Lint/EmptyExpression
cop. (@drenmi)
Bug fixes
- #3553: Make
Style/RedundantSelf
cop to not register an offence forself.()
. (@iGEL) - #3474: Make the
Rails/TimeZone
only analyze functions which have "Time" in the receiver. (@b-t-g) - #3607: Fix
Style/RedundantReturn
cop for empty if body. (@pocke) - #3291: Improve detection of
raw
andhtml_safe
methods inRails/OutputSafety
. (@lumeet) - Redundant return style now properly handles empty
when
blocks. (@albus522) - #3622: Fix false positive for
Metrics/MethodLength
andMetrics/BlockLength
. (@meganemura) - #3625: Fix some cops errors when condition is empty brace. (@pocke)
- #3468: Fix bug regarding alignment inside
begin
..end
block inStyle/MultilineMethodCallIndentation
. (@jonas054) - #3644: Fix generation incorrect documentation. (@pocke)
- #3637: Fix Style/NonNilCheck crashing for ternary condition. (@tejasbubane)
- #3654: Add missing keywords for
Rails/HttpPositionalArguments
. (@eitoball) - #3652: Avoid crash Rails/HttpPositionalArguments for lvar params when auto-correct. (@pocke)
- Fix bug in
Style/SafeNavigation
where there is a check for an object in an elsif statement with a method call on that object in the branch. (@rrosenblum) - #3660: Fix false positive for Rails/SafeNavigation when without receiver. (@pocke)
- #3650: Fix
Style/VariableNumber
registering an offense for variables with double digit numbers. (@rrosenblum) - #3494: Check
rails
style indentation also inside blocks inStyle/IndentationWidth
. (@jonas054) - #3676: Ignore raw and html_safe invocations when wrapped inside a safe_join. (@b-t-g)
Changes
- #3601: Change default args for
Style/SingleLineBlockParams
. This cop checks thatreduce
andinject
use the variable namesa
ande
for block arguments. These defaults are uncommunicative variable names and thus conflict with the "Uncommunicative Variable Name" check in Reek. Default args changed toacc
andelem
.(@jessieay) - #3645: Fix bug with empty case when nodes in
Style/RedundantReturn
. (@tiagocasanovapt) - #3263: Fix auto-correct of if statements inside of unless else statements in
Style/ConditionalAssignment
. (@rrosenblum) - Bump default Ruby version to 2.1. (@drenmi)
RuboCop 0.44 (The Birthday Release)
New features
- #3560: Add a configuration option
empty_lines_except_namespace
toStyle/EmptyLinesAroundClassBody
andStyle/EmptyLinesAroundModuleBody
. (@legendetm) - #3370: Add new
Rails/HttpPositionalArguments
cop to check your Rails 5 test code for existence of positional args usage. (@logicminds) - #3510: Add a configuration option,
ConvertCodeThatCanStartToReturnNil
, toStyle/SafeNavigation
to check for code that could start returningnil
if safe navigation is used. (@rrosenblum) - Add a new
AllCops/StyleGuideBaseURL
setting that allows the use of relative paths and/or fragments within each cop'sStyleGuide
setting, to make forking of custom style guides easier. (@scottmatthewman) - #3566: Add new
Metric/BlockLength
cop to ensure blocks don't get too long. (@savef) - #3428: Add support for configuring
Style/PreferredHashMethods
with eithershort
orverbose
style method names. (@abrom) - #3455: Add new
Rails/DynamicFindBy
cop. (@pocke) - #3542: Add a configuration option,
IgnoreCopDirectives
, toMetrics/LineLength
to stop cop directives (# rubocop:disable Metrics/AbcSize
) from being counted when considering line length. (@jmks) - Add new
Rails/DelegateAllowBlank
cop. (@connorjacobsen) - Add new
Style/MultilineMemoization
cop. (@drenmi)
Bug fixes
- #3103: Make
Style/ExtraSpacing
cop register an offense for extra spaces present in single-line hash literals. (@tcdowney) - #3513: Fix false positive in
Style/TernaryParentheses
for a ternary with ranges. (@dreyks) - #3520: Fix regression causing
Lint/AssignmentInCondition
false positive. (@savef) - #3514: Make
Style/VariableNumber
cop not register an offense when valid normal case variable names have an integer after the first_
. (@b-t-g) - #3516: Make
Style/VariableNumber
cop not register an offense when valid normal case variable names have an integer in the middle. (@b-t-g) - #3436: Make
Rails/SaveBang
cop not register an offense when return value of a non-bang method is returned by the parent method. (@coorasse) - #3540: Fix
Style/GuardClause
to register offense for instance and singleton methods. (@tejasbubane) - #3311: Detect incompatibilities with the external encoding to prevent bad autocorrections in
Style/StringLiterals
. (@deivid-rodriguez) - #3499: Ensure
Lint/UnusedBlockArgument
doesn't make recommendations that would change arity for methods defined using#define_method
. (@drenmi) - #3430: Fix exception in
Performance/RedundantMerge
when inspecting a#merge!
with implicit receiver. (@drenmi) - #3411: Avoid auto-correction crash for single
when
inPerformance/CaseWhenSplat
. (@jonas054) - #3286: Allow
self.a, self.b = b, a
inStyle/ParallelAssignment
. (@jonas054) - #3419: Report offense for
unless x.nil?
inStyle/NonNilCheck
ifIncludeSemanticChanges
istrue
. (@jonas054) - #3382: Avoid auto-correction crash for multiple elsifs in
Style/EmptyElse
. (@lumeet) - #3334: Do not register an offense for a literal space (
\s
) inStyle/UnneededCapitalW
. (@rrosenblum) - #3390: Fix SaveBang cop for multiple conditional. (@tejasbubane)
- #3577: Fix
Style/RaiseArgs
not allowing compact raise with splatted args. (@savef) - #3578: Fix safe navigation method call counting in
Metrics/AbcSize
. (@savef) - #3592: Fix
Style/RedundantParentheses
for indexing with literals. (@thegedge) - #3597: Fix the autocorrect of
Performance/CaseWhenSplat
when trying to rearange splat expanded variables to the end of a when condition. (@rrosenblum)
Changes
- #3512: Change error message of
Lint/UnneededSplatExpansion
for array in method parameters. (@tejasbubane) - #3510: Fix some issues with
Style/SafeNavigation
. Fix auto-correct of multiline if expressions, and do not register an offense for scenarios using||
and ternary expression. (@rrosenblum) - #3503: Change misleading message of
Style/EmptyLinesAroundAccessModifier
. (@bquorning) - #3407: Turn off autocorrect for unsafe rules by default. (@ptarjan)
- #3521: Turn off autocorrect for
Security/JSONLoad
by default. (@savef) - #2903:
Style/RedundantReturn
looks for redundantreturn
inside conditional branches. (@lumeet)
RuboCop 0.43
New features
- #3379: Add table of contents at the beginning of HTML formatted output. (@hedgesky)
- #2968: Add new
Style/DocumentationMethod
cop. (@sooyang) - #3360: Add
RequireForNonPublicMethods
configuration option toStyle/DocumentationMethod
cop. (@drenmi) - Add new
Rails/SafeNavigation
cop to converttry!
to&.
. (@rrosenblum) - #3415: Add new
Rails/NotNullColumn
cop. (@pocke) - #3167: Add new
Style/VariableNumber
cop. (@sooyang) - Add new style
no_mixed_keys
toStyle/HashSyntax
to only check for hashes with mixed keys. (@daviddavis) - Allow including multiple configuration files from a single gem. (@tjwallace)
- Add check for
persisted?
method call when using a create method inRails/SaveBang
. (@QuinnHarris) - Add new
Style/SafeNavigation
cop to convert method calls safeguarded by a nonnil
check for the object to&.
. (@rrosenblum) - Add new
Performance/SortWithBlock
cop to usesort_by(&:foo)
instead ofsort_by { |a, b| a.foo <=> b.foo }
. (@koic) - #3492: Add new
UnifiedInteger
cop. (@pocke)
Bug fixes
- #3383: Fix the local variable reset issue with
Style/RedundantSelf
cop. (@bankair) - #3445: Fix bad autocorrect for
Style/AndOr
cop. (@mikezter) - #3349: Fix bad autocorrect for
Style/Lambda
cop. (@metcalf) - #3351: Fix bad auto-correct for
Performance/RedundantMatch
cop. (@annaswims) - #3347: Prevent infinite loop in
Style/TernaryParentheses
cop when used together withStyle/RedundantParentheses
. (@drenmi) - #3209: Remove faulty line length check from
Style/GuardClause
cop. (@drenmi) - #3366: Make
Style/MutableConstant
cop aware of splat assignments. (@drenmi) - #3372: Fix RuboCop crash with empty brackets in
Style/Next
cop. (@pocke) - #3358: Make
Style/MethodMissing
cop aware of class scope. (@drenmi) - #3342: Fix error in
Lint/ShadowedException
cop if last rescue does not have parameter. (@soutaro) - #3380: Fix false positive in
Style/TrailingUnderscoreVariable
cop. (@drenmi) - #3388: Fix bug where
Lint/ShadowedException
would register an offense when rescuing different numbers of custom exceptions in multiple rescue groups. (@rrosenblum) - #3386: Make
VariableForce
understand an empty RegExp literal as LHS to=~
. (@drenmi) - #3421: Fix clobbering
inherit_from
additions when not using Namespaces in the configs. (@nicklamuro) - #3425: Fix bug for invalid bytes in UTF-8 in
Lint/PercentStringArray
cop. (@pocke) - #3374: Make
SpaceInsideBlockBraces
andSpaceBeforeBlockBraces
not depend onBlockDelimiters
configuration. (@jonas054) - Fix error in
Lint/ShadowedException
cop for higher number of rescue groups. (@groddeck) - #3456: Don't crash on a multiline empty brace in
Style/MultilineMethodCallBraceLayout
. (@pocke) - #3423: Checks if .rubocop is a file before parsing. (@joejuzl)
- #3439: Fix variable assignment check not working properly when a block is used in
Rails/SaveBang
. (@QuinnHarris) - #3401: Read file contents in binary mode so
Style/EndOfLine
works on Windows. (@jonas054) - #3450: Prevent
Style/TernaryParentheses
cop from making unsafe corrections. (@drenmi) - #3460: Fix false positives in
Style/InlineComment
cop. (@drenmi) - #3485: Make OneLineConditional cop not register offense for empty else. (@tejasbubane)
- #3508: Fix false negatives in
Rails/NotNullColumn
. (@pocke) - #3462: Don't create MultilineMethodCallBraceLayout offenses for single-line method calls when receiver spans multiple lines. (@maxjacobson)
Changes
- #3341: Exclude RSpec tests from inspection by
Style/NumericPredicate
cop. (@drenmi) - Rename
Lint/UselessArraySplat
toLint/UnneededSplatExpansion
, and add functionality to check for unnecessary expansion of other literals. (@rrosenblum) - No longer register an offense for splat expansion of an array literal in
Performance/CaseWhenSplat
.Lint/UnneededSplatExpansion
now handles this behavior. (@rrosenblum) Lint/InheritException
restricts inheriting from standard library subclasses ofException
. (@metcalf)- No longer register an offense if the first line of code starts with
#\
inStyle/LeadingCommentSpace
.config.ru
files consider such lines as options. (@scottohara) - #3292: Remove
Performance/PushSplat
as it can produce code that is slower or even cause failure. (@jonas054)
RuboCop 0.42.0
New features
- #3306: Add autocorrection for
Style/EachWithObject
. (@owst) - Add new
Style/TernaryParentheses
cop. (@drenmi) - #3136: Add config for
UselessAccessModifier
so it can be made aware of ActiveSupport'sconcerning
andclass_methods
methods. (@maxjacobson) - #3128: Add new
Rails/SaveBang
cop. (@QuinnHarris)
Bug fixes
- #3271: Fix bad auto-correct for
Style/EachForSimpleLoop
cop. (@drenmi) - #3288: Fix auto-correct of word and symbol arrays in
Style/ParallelAssignment
cop. (@jonas054) - #3307: Fix exception when inspecting an operator assignment with
Style/MethodCallParentheses
cop. (@drenmi) - #3316: Fix error for blocks without arguments in
Style/SingleLineBlockParams
cop. (@owst) - #3320: Make
Style/OpMethod
aware of the backtick method. (@drenmi) - Do not register an offense in
Lint/ShadowedException
when rescuing an exception built into Ruby before a custom exception. (@rrosenblum)
Changes
- #2645:
Style/EmptyLiteral
no longer generates an offense forString.new
when using frozen string literals. (@drenmi) - #3308: Make
Lint/NextWithoutAccumulator
aware of nested enumeration. (@drenmi) - Extend
Style/MethodMissing
cop to check for the conditions in the style guide. (@drenmi) - #3325: Drop support for MRI 1.9.3. (@drenmi)
- Add support for MRI 2.4. (@dvandersluis)
- #3256: Highlight the closing brace in
Style/Multiline...BraceLayout
cops. (@jonas054) - Always register an offense when rescuing
Exception
before or along with any other exception inLint/ShadowedException
. (@rrosenblum)
RuboCop 0.41.2
Bug fixes
- #3248: Support 'ruby-' prefix in
.ruby-version
. (@tjwp) - #3250: Make regexp for cop names less restrictive in CommentConfig lines. (@tjwp)
- #3261: Prefer
TargetRubyVersion
to.ruby-version
. (@tjwp) - #3249: Account for
rescue nil
inStyle/ShadowedException
. (@rrosenblum) - Modify the highlighting in
Style/ShadowedException
to be more useful. Highlight justrescue
area. (@rrosenblum) - #3129: Fix
Style/MethodCallParentheses
to work with multiple assignments. (@tejasbubane) - #3247: Ensure whitespace after beginning of block in
Style/BlockDelimiters
. (@tjwp) - #2941: Make sure
Lint/UnneededDisable
can do auto-correction. (@jonas054) - #3269: Fix
Lint/ShadowedException
to block arbitrary code execution. (@pocke) - #3266: Handle empty parentheses in
Performance/RedundantBlockCall
auto-correct. (@jonas054) - #3272: Add escape character missing to LITERAL_REGEX. (@pocke)
- #3255: Fix auto-correct for
Style/RaiseArgs
when constructing exception without arguments. (@drenmi) - #3294: Allow to use
Time.zone_default
. (@Tei)
Changes
RuboCop 0.41
New features
- #2956: Prefer
.ruby-version
toTargetRubyVersion
. (@pclalv) - #3095: Add
IndentationWidth
configuration parameter forStyle/AlignParameters
cop. (@alexdowad) - #3066: Add new
Style/ImplicitRuntimeError
cop which advises the use of an explicit exception class when raising an error. (@alexdowad) - #3018: Add new
Style/EachForSimpleLoop
cop which advises the use ofInteger#times
for simple loops which iterate a fixed number of times. (@alexdowad) - #2595: New
compact
style forStyle/SpaceInsideLiteralHashBraces
. (@alexdowad) - #2927: Add autocorrect for
Rails/Validation
cop. (@neodelf) - #3135: Add new
Rails/OutputSafety
cop. (@josh) - #3164: Add Fastlane's Fastfile to the default Includes. (@jules2689)
- #3173: Make
Style/ModuleFunction
configurable withmodule_function
andextend_self
styles. (@tjwp) - #3105: Add new
Rails/RequestReferer
cop. (@giannileggio) - #3200: Add autocorrect for
Style/EachForSimpleLoop
cop. (@tejasbubane) - #3058: Add new
Style/SpaceInsideArrayPercentLiteral
cop. (@owst) - #3058: Add new
Style/SpaceInsidePercentLiteralDelimiters
cop. (@owst) - #3179: Expose files to support testings Cops using RSpec. (@tjwp)
- #3191: Allow arbitrary comments after cop names in CommentConfig lines (e.g. rubocop:enable). (@owst)
- #3165: Add new
Lint/PercentStringArray
cop. (@owst) - #3165: Add new
Lint/PercentSymbolArray
cop. (@owst) - #3177: Add new
Style/NumericLiteralPrefix
cop. (@tejasbubane) - #1646: Add configuration style
indented_relative_to_receiver
forStyle/MultilineMethodCallIndentation
. (@jonas054) - New cop
Lint/ShadowedException
checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception. (@rrosenblum) - #3127: New cop
Lint/InheritException
checks for error classes inheriting fromException
, and instead suggestsRuntimeError
orStandardError
. (@drenmi) - Add new
Performance/PushSplat
cop. (@segiddins) - #3089: Add new
Rails/Exit
cop. (@sgringwe)
Bug fixes
- #3005: Symlink protection prevents use of caching in CI context. (@urbanautomaton)
- #3037:
Style/StringLiterals
understands that a bare '#', not '#@variable' or '#{interpolation}', does not require double quotes. (@alexdowad) - #2722:
Style/ExtraSpacing
does not attempt to align an equals sign in an argument list with one in an assignment statement. (@alexdowad) - #3133:
Style/MultilineMethodCallBraceLayout
does not register offenses for single-line calls. (@alexdowad) - #3170:
Style/MutableConstant
does not infinite-loop when correcting an array with no brackets. (@alexdowad) - #3150: Fix auto-correct for Style/MultilineArrayBraceLayout. (@jspanjers)
- #3192: Fix
Lint/UnusedBlockArgument
'sIgnoreEmptyBlocks
parameter from being removed from configuration. (@jfelchner) - #3114: Fix alignment
end
when auto-correctingStyle/EmptyElse
. (@rrosenblum) - #3120: Fix
Lint/UselessAccessModifier
reporting useless access modifiers inside {Class,Module,Struct}.new blocks. (@owst) - #3125: Fix
Rails/UniqBeforePluck
to ignoreuniq
with block. (@tejasbubane) - #3116:
Style/SpaceAroundKeyword
allows&.
method calls aftersuper
andyield
. (@segiddins) - #3131: Fix
Style/ZeroLengthPredicate
to ignoresize
andlength
variables. (@tejasbubane) - #3146: Fix
NegatedIf
andNegatedWhile
to ignore double negations. (@natalzia-paperless) - #3140:
Style/FrozenStringLiteralComment
works with file doesn't have any tokens. (@pocke) - #3154: Fix handling of
()
inStyle/RedundantParentheses
. (@lumeet) - #3155: Fix
Style/SpaceAfterNot
reporting on thenot
keyword. (@NobodysNightmare) - #3160:
Style/Lambda
fix whitespacing when auto-correcting unparenthesized arguments. (@palkan) - #2944: Don't crash on strings that span multiple lines but only have one pair of delimiters in
Style/StringLiterals
. (@jonas054) - #3157: Don't let
LineEndConcatenation
andUnneededInterpolation
make changes to the same string during auto-correct. (@jonas054) - #3187: Let
Style/BlockDelimiters
ignore blocks in all method arguments. (@jonas054) - Modify
Style/ParallelAssignment
to use implicit begins when parallel assignment uses arescue
modifier and is the only thing in the method. (@rrosenblum) - #3217: Fix output of ellipses for multi-line offense ranges in HTML formatter. (@jonas054)
- #3207: Auto-correct modifier
while
/until
andbegin
..end
+while
/until
inStyle/InfiniteLoop
. (@jonas054) - #3202: Fix
Style/EmptyElse
registering wrong offenses and thus making RuboCop crash. (@deivid-rodriguez) - #3183: Ensure
Style/SpaceInsideBlockBraces
reports offenses for multi-line blocks. (@owst) - #3017: Fix
Style/StringLiterals
to register offenses on non-ascii strings. (@deivid-rodriguez) - #3056: Fix
Style/StringLiterals
to register offenses on non-ascii strings. (@deivid-rodriguez) - #2986: Fix
RedundantBlockCall
to not report calls that pass block arguments, or where the block has been overridden. (@owst) - #3223: Return can take many arguments. (@ptarjan)
- #3239: Fix bug with --auto-gen-config and a file that does not exist. (@meganemura)
- #3138: Fix RuboCop crashing when config file contains utf-8 characters and external encoding is not utf-8. (@deivid-rodriguez)
- #3175: Generate 'Exclude' list for the cops with configurable enforced style to
.rubocop_todo.yml
if different styles are used. (@flexoid) - #3231: Make
Rails/UniqBeforePluck
more conservative. (@tjwp)
Changes
RuboCop 0.40
New features
- #2997:
Performance/CaseWhenSplat
can now identify multiple offenses in the same branch and offenses that do not occur as the first argument. (@rrosenblum) - #2928:
Style/NestedParenthesizedCalls
cop can auto-correct. (@drenmi) Style/RaiseArgs
cop can auto-correct. (@drenmi)- #2993:
Style/SpaceAfterColon
now checks optional keyword arguments. (@owst) - #3003: Read command line options from
.rubocop
file andRUBOCOP_OPTS
environment variable. (@bolshakov) - #2857:
Style/MultilineArrayBraceLayout
enforced style is configurable and supportssymmetrical
andnew_line
options. (@panthomakos) - #2857:
Style/MultilineHashBraceLayout
enforced style is configurable and supportssymmetrical
andnew_line
options. (@panthomakos) - #2857:
Style/MultilineMethodCallBraceLayout
enforced style is configurable and supportssymmetrical
andnew_line
options. (@panthomakos) - #2857:
Style/MultilineMethodDefinitionBraceLayout
enforced style is configurable and supportssymmetrical
andnew_line
options. (@panthomakos) - #3052:
Style/MultilineArrayBraceLayout
enforced style supportssame_line
option. (@panthomakos) - #3052:
Style/MultilineHashBraceLayout
enforced style supportssame_line
option. (@panthomakos) - #3052:
Style/MultilineMethodCallBraceLayout
enforced style supportssame_line
option. (@panthomakos) - #3052:
Style/MultilineMethodDefinitionBraceLayout
enforced style supportssame_line
option. (@panthomakos) - #3019: Add new
Style/EmptyCaseCondition
cop. (@owst, @rrosenblum) - #3072: Add new
Lint/UselessArraySplat
cop. (@owst) - #3022:
Style/Lambda
enforced style supportsliteral
option. (@drenmi) - #2909:
Style/Lambda
enforced style supportslambda
option. (@drenmi) - #3092: Allow
Style/Encoding
to enforce using no encoding comments. (@NobodysNightmare) - New cop
Rails/UniqBeforePluck
checks thatuniq
is used beforepluck
. (@tjwp)
Bug fixes
- #3112: Fix
Style/ClassAndModuleChildren
for nested classes with explicit superclass. (@jspanjers) - #3032: Fix autocorrecting parentheses for predicate methods without space before args. (@graemeboy)
- #3000: Fix encoding crash on HTML output. (@gerrywastaken)
- #2983:
Style/AlignParameters
message was clarified forwith_fixed_indentation
style. (@dylanahsmith) - #2314: Ignore
UnusedBlockArgument
for keyword arguments. (@volkert) - #2975: Make comment indentation before
)
consistent with comment indentation before}
or]
. (@jonas054) - #3010: Fix double reporting/correction of spaces after ternary operator colons (now only reported by
Style/SpaceAroundOperators
, and notStyle/SpaceAfterColon
too). (@owst) - #3006: Register an offense for calling
merge!
on a method on a variable insideeach_with_object
inPerformance/RedundantMerge
. (@lumeet, @rrosenblum) - #2886: Custom cop changes now bust the cache. (@ptarjan)
- #3043:
Style/SpaceAfterNot
will now register an offense for a receiver that is wrapped in parentheses. (@rrosenblum) - #3039: Accept
match
without a receiver inPerformance/EndWith
. (@lumeet) - #3039: Accept
match
without a receiver inPerformance/StartWith
. (@lumeet) - #3048:
Lint/NestedMethodDefinition
shouldn't flag methods defined on Structs. (@owst) - #2912: Check whether a line is aligned with the following line if the preceding line is not an assignment. (@akihiro17)
- #3036: Don't let
Lint/UnneededDisable
inspect files that are excluded for the cop. (@jonas054) - #2874: Fix bug when the closing parenthesis is preceded by a newline in array and hash literals in
Style/RedundantParentheses
. (@lumeet) - #3049: Make
Lint/UselessAccessModifier
detect conditionally defined methods and correctly handle dynamically defined methods and singleton class methods. (@owst) - #3004: Don't add
Style/Alias
offenses for use ofalias
ininstance_eval
blocks, since object instances don't respond toalias_method
. (@magni-) - #3061: Custom cops now show up in --show-cops. (@ptarjan)
- #3088: Ignore offenses that involve conflicting HEREDOCs in the
Style/Multiline*BraceLayout
cops. (@panthomakos) - #3083: Do not register an offense for splat block args in
Style/SymbolProc
. (@rrosenblum) - #3063: Don't auto-correct
a + \
intoa + \\
inStyle/LineEndConcatenation
. (@jonas054) - #3034: Report offenses for
RuntimeError.new(msg)
inStyle/RedundantException
. (@jonas054) - #3016:
Style/SpaceAfterComma
now usesStyle/SpaceInsideHashLiteralBraces
's setting. (@ptarjan)
Changes
- #2995: Removed deprecated path matching syntax. (@gerrywastaken)
- #3025: Removed deprecation warnings for
rubocop-todo.yml
. (@ptarjan) - #3028: Add
define_method
to the default list ofIgnoredMethods
ofStyle/SymbolProc
. (@jastkand) - #3064:
Style/SpaceAfterNot
highlights the entire expression instead of just the exlamation mark. (@rrosenblum) - #3085: Enable
Style/MultilineArrayBraceLayout
andStyle/MultilineHashBraceLayout
with thesymmetrical
style by default. (@panthomakos) - #3091: Enable
Style/MultilineMethodCallBraceLayout
andStyle/MultilineMethodDefinitionBraceLayout
with thesymmetrical
style by default. (@panthomakos) - #1830:
Style/PredicateName
now ignores thespec/
directory, since there is a strong convention for usinghave_*
andbe_*
helper methods in RSpec. (@gylaz)
RuboCop 0.39
New features
Performance/TimesMap
cop can auto-correct. (@lumeet)Style/ZeroLengthPredicate
cop can auto-correct. (@lumeet)- #2828:
Style/ConditionalAssignment
is now configurable to enforce assignment inside of conditions or to enforce assignment to conditions. (@rrosenblum) - #2862:
Performance/Detect
andPerformance/Count
have a new configurationSafeMode
that is defaulted totrue
. These cops have known issues withRails
and other ORM frameworks. With this default configuration, these cops will not run if theRails
cops are enabled. (@rrosenblum) Style/IfUnlessModifierOfIfUnless
cop added. (@amuino)
Bug fixes
- #2948:
Style/SpaceAroundKeyword
should allow yield[n] and super[n]. (@laurelfan) - #2950: Fix auto-correcting cases in which precedence has changed in
Style/OneLineConditional
. (@lumeet) - #2947: Fix auto-correcting
if-then
inStyle/Next
. (@lumeet) - #2904:
Style/RedundantParentheses
doesn't flag-(1.method)
or+(1.method)
, since removing the parentheses would change the meaning of these expressions. (@alexdowad) - #2958:
Style/MultilineMethodCallIndentation
doesn't fail when inspecting unary ops which span multiple lines. (@alexdowad) - #2959:
Lint/LiteralInInterpolation
doesn't report offenses for iranges and eranges with non-literal endpoints. (@alexdowad) - #2960:
Lint/AssignmentInCondition
catches method assignments (likeobj.attr = val
) in a condition. (@alexdowad) - #2871: Second solution for possible encoding incompatibility when outputting an HTML report. (@jonas054)
- #2967: Fix auto-correcting of
===
,<=
, and>=
inStyle/ConditionalAssignment
. (@rrosenblum) - #2977: Fix auto-correcting of
"#{$!}"
inStyle/SpecialGlobalVars
. (@lumeet) - #2935: Make configuration loading work if
SafeYAML.load
is private. (@jonas054)
Changes
require:
only does relative includes when it starts with a.
. (@ptarjan)Style/IfUnlessModifier
does not trigger if the body is another conditional. (@amuino)- #2963:
Performance/RedundantMerge
will now register an offense inside ofeach_with_object
. (@rrosenblum)