Releases: rubocop/rubocop
RuboCop 0.30.1
Enjoy all those bug-fixes!
Bugs fixed
- #1691: For assignments with line break after
=
, usekeyword
alignment inEndAlignment
regardless of configured style. (@jonas054) - #1769: Fix bug where
LiteralInInterpolation
registers an offense for interpolation of__LINE__
. (@rrosenblum) - #1773: Fix typo ('strptime' -> 'strftime') in
Rails/TimeZone
. (@palkan) - #1777: Fix offense message from Rails/TimeZone. (@mzp)
- #1784: Add an explicit error message when config contains an empty section. (@bankair)
- #1791: Fix autocorrection of
PercentLiteralDelimiters
with no content. (@cshaffer) - Fix handling of
while
anduntil
with assignment inIndentationWidth
. (@lumeet) - #1793: Fix bug in
TrailingComma
that caused,
in comment to count as a trailing comma. (@jonas054) - #1765: Update 1.9 hash to stop triggering when the symbol is not valid in the 1.9 hash syntax. (@crimsonknave)
- #1806: Require a newer version of
parser
and use its corrected solution for comment association inStyle/Documentation
. (@jonas054) - #1792: Fix bugs in
Sample
that did not account for array selectors with a range and passing random to shuffle. (@rrosenblum) - #1770: Add more acceptable methods to
Rails/TimeZone
(utc
,localtime
,to_i
,iso8601
etc). (@palkan) - #1795: Fix bug in
TrailingBlankLines
that caused a crash for files containing only newlines. (@renuo)
RuboCop 0.30.0
Nothing ground-breaking this time around, but the release is pretty exciting non-the-less.
It packs a whole new category of cops (Performance
) and a bunch of new Rails cops.
A lot of the existing cops got new customization options and we squashed a ton of bugs.
Thanks to everyone who contributed to this release!
New features
- #1600: Add
line_count_based
andsemantic
styles to theBlockDelimiters
(formerlyBlocks
) cop. (@clowder, @mudge) - #1712: Set
Offense#corrected?
totrue
,false
, ornil
when it was, wasn't, or can't be auto-corrected, respectively. (@vassilevsky) - #1669: Add command-line switch
--display-style-guide
. (@marxarelli) - #1405: Add Rails TimeZone and Date cops. (@palkan)
- #1641: Add ruby19_no_mixed_keys style to
HashStyle
cop. (@iainbeeston) - #1604: Add
IgnoreClassMethods
option toTrivialAccessors
cop. (@bbatsov) - #1651: The
Style/SpaceAroundOperators
cop now also detects extra spaces around operators. A list of operators that may be surrounded by multiple spaces is configurable. (@bquorning) - Add auto-correct to
Encoding
cop. (@rrosenblum) - #1621:
TrailingComma
has a new styleconsistent_comma
. (@tamird) - #1611: Add
empty
,nil
, andboth
SupportedStyles
toEmptyElse
cop. Default isboth
. (@rrosenblum) - #1611: Add new
MissingElse
cop. Default is to have this cop be disabled. (@rrosenblum) - #1602: Add support for
# :nodoc
inDocumentation
. (@lumeet) - #1437: Modify
HashSyntax
cop to allow the use of hash rockets for hashes that have symbol values when using ruby19 syntax. (@rrosenblum) - New cop
Style/SymbolLiteral
makes sure you're not using the string within symbol syntax unless it's needed. (@bbatsov) - #1657: Autocorrect can be turned off on a specific cop via the configuration. (@jdoconnor)
- New cop
Style/AutoResourceCleanup
suggests the use of block taking versions of methods that do resource cleanup. (@bbatsov) - #1275:
WhileUntilModifier
cop does auto-correction. (@lumeet) - New cop
Performance/ReverseEach
to convertreverse.each
toreverse_each
. (@rrosenblum) - #1281:
IfUnlessModifier
cop does auto-correction. (@lumeet) - New cop
Performance/Detect
to detect usage ofselect.first
,select.last
,find_all.first
, andfind_all.last
and convert them to usedetect
instead. (@palkan, @rrosenblum) - #1728: New cop
NonLocalExitFromIterator
checks for misusedreturn
in block. (@ypresto) - New cop
Performance/Size
to convert calls tocount
onArray
andHash
tosize
. (@rrosenblum) - New cop
Performance/Sample
to convert usages ofshuffle.first
,shuffle.last
, andshuffle[Fixnum]
tosample
. (@rrosenblum) - New cop
Performance/FlatMap
to convertEnumerable#map...Array#flatten
andEnumerable#collect...Array#flatten
toEnumerable#flat_map
. (@rrosenblum) - #1144: New cop
ClosingParenthesisIndentation
checks the indentation of hanging closing parentheses. (@jonas054) - New Rails cop
FindBy
identifies usages ofwhere.first
andwhere.take
. (@bbatsov) - New Rails cop
FindEach
identifies usages ofall.each
. (@bbatsov) - #1342:
IndentationConsistency
is now configurable with the stylesnormal
andrails
. (@jonas054)
Bugs fixed
- #1705: Fix crash when reporting offenses of
MissingElse
cop. (@gerry3) - #1659: Fix stack overflow with JRuby and Windows 8, during initial config validation. (@pimterry)
- #1694: Ignore methods with a
blockarg
inTrivialAccessors
. (@bbatsov) - #1617: Always read the html output template using utf-8. (@bbatsov)
- #1684: Ignore symbol keys like
:"string"
inHashSyntax
. (@bbatsov) - Handle explicit
begin
blocks inLint/Void
. (@bbatsov) - Handle symbols in
Lint/Void
. (@bbatsov) - #1695: Fix bug with
--auto-gen-config
andSpaceInsideBlockBraces
. (@meganemura) - Correct issues with whitespace around multi-line lambda arguments. (@zvkemp)
- #1579: Fix handling of similar-looking blocks in
BlockAlignment
. (@lumeet) - #1676: Fix auto-correct in
Lambda
when a new multi-line lambda is used as an argument. (@lumeet) - #1656: Fix bug that would include hidden directories implicitly. (@jonas054)
- #1728: Fix bug in
LiteralInInterpolation
andAssignmentInCondition
. (@ypresto) - #1735: Handle trailing space in
LineEndConcatenation
autocorrect. (@jonas054) - #1750: Escape offending code lines output by the HTML formatter in case they contain markup. (@jonas054)
- #1541: No inspection of text that follows
__END__
. (@jonas054) - Fix comment detection in
Style/Documentation
. (@lumeet) - #1637: Fix handling of
binding
calls inUnusedBlockArgument
andUnusedMethodArgument
. (@lumeet)
Changes
- #1397:
UnneededPercentX
renamed toCommandLiteral
. The cop can be configured to enforce using either%x
or backticks around command literals, or using%x
around multi-line commands and backticks around single-line commands. The cop ignores heredoc commands. (@bquorning) - #1020: Removed the
MaxSlashes
configuration option forRegexpLiteral
. Instead, the cop can be configured to enforce using either%r
or slashes around regular expressions, or using%r
around multi-line regexes and slashes around single-line regexes. (@bquorning) - #1734: The default exclusion of hidden directories has been optimized for speed. (@jonas054)
- #1673:
Style/TrivialAccessors
now requires matching names by default. (@bbatsov)
RuboCop 0.29.1
Bugs fixed
- #1638: Use Parser functionality rather than regular expressions for matching comments in
FirstParameterIndentation
. (@jonas054) - #1642: Raise the correct exception if the configuration file is malformed. (@bquorning)
- #1647: Skip
SpaceAroundBlockParameters
when lambda has no argument. (@eitoball) - #1649: Handle exception assignments in
UselessSetterCall
. (@bbatsov) - #1644: Don't search the entire file system when a folder is named
,
. (@bquorning)
RuboCop 0.29.0
New features
- #1430: Add
--except
option for disabling cops on the command line. (@jonas054) - #1506: Add auto-correct from
EvenOdd
cop. (@blainesch) - #1507:
Debugger
cop now checks for the Capybara debug methodssave_and_open_page
andsave_and_open_screenshot
. (@rrosenblum) - #1539: Implement autocorrection for Rails/ReadWriteAttribute cop. (@huerlisi)
- #1324: Add
AllCops/DisplayCopNames
configuration option for showing cop names in reports, like--display-cop-names
. (@jonas054) - #1271:
Lambda
cop does auto-correction. (@lumeet) - #1284: Support namespaces, e.g.
Lint
, in the arguments to--only
and--except
. (@jonas054) - #1276:
SelfAssignment
cop does auto-correction. (@lumeet) - Add autocorrect to
RedundantException
. (@mattjmcnaughton) - #1571: New cop
StructInheritance
checks for inheritance from Struct.new. (@mmozuras) - #1575: New cop
DuplicateMethods
points out duplicate method name in class and module. (@d4rk5eed) - #1144: New cop
FirstParameterIndentation
checks the indentation of the first parameter in a method call. (@jonas054) - #1627: New cop
SpaceAroundBlockParameters
checks the spacing inside and after block parameters pipes. (@jonas054)
Changes
- #1492: Abort when auto-correct causes an infinite loop. (@dblock)
- Options
-e
/--emacs
and-s
/--silent
are no longer recognized. Using them will now raise an error. (@bquorning) - #1565: Let
--fail-level A
cause exit with error if all offenses are auto-corrected. (@jonas054) - #1309: Add argument handling to
MultilineBlockLayout
. (@lumeet)
Bugs fixed
- #1634: Fix
PerlBackrefs
Cop Autocorrections to Not Raise. (@cshaffer) - #1553: Fix bug where
Style/EmptyLinesAroundAccessModifier
interfered withStyle/EmptyLinesAroundBlockBody
when there is and access modifier at the beginning of a block. (@volkert) - Handle element assignment in
Lint/AssignmentInCondition
. (@jonas054) - #1484: Fix
EmptyLinesAroundAccessModifier
incorrectly finding a violation inside method calls with names identical to an access modifier. (@dblock) - Fix bug concerning
Exclude
properties inherited from a higher directory level. (@jonas054) - #1500: Fix crashing
--auto-correct --only IndentationWidth
. (@jonas054) - #1512: Fix false negative for typical string formatting examples. (@kakutani, @jonas054)
- #1504: Fail with a meaningful error if the configuration file is malformed. (@bquorning)
- Fix bug where
auto_correct
Rake tasks does not take in the options specified in its parent task. (@rrosenblum) - #1054: Handle comments within concatenated strings in
LineEndConcatenation
. (@yujinakayama, @jonas054) - #1527: Make autocorrect
BracesAroundHashParameter
leave the correct number of spaces. (@mattjmcnaughton) - #1547: Don't print
[Corrected]
when auto-correction was avoided inStyle/Semicolon
. (@jonas054) - #1573: Fix assignment-related auto-correction for
BlockAlignment
. (@lumeet) - #1587: Exit with exit code 1 if there were errors ("crashing" cops). (@jonas054)
- #1574: Avoid auto-correcting
Hash.new
to{}
when braces would be interpreted as a block. (@jonas054) - #1591: Don't check parameters inside
[]
inMultilineOperationIndentation
. (@jonas054) - #1509: Ignore class methods in
Rails/Delegate
. (@bbatsov) - #1594: Fix
@example
warnings in Yard Doc documentation generation. (@mattjmcnaughton) - #1598: Fix bug in file inclusion when running from another directory. (@jonas054)
- #1580: Don't print
[Corrected]
when auto-correction was avoided inTrivialAccessors
. (@lumeet) - #1612: Allow
expand_path
oninherit_from
in.rubocop.yml
. (@mattjmcnaughton) - #1610: Check that class method names actually match the name of the containing class/module in
Style/ClassMethods
. (@bbatsov)
RuboCop 0.28
New features
- New cop
ExtraSpacing
points out unnecessary spacing in files. (@blainesch) - New cop
EmptyLinesAroundBlockBody
provides same functionality as the EmptyLinesAround(Class|Method|Module)Body but for blocks. (@jcarbo) - New cop
Style/EmptyElse
checks for emptyelse
-clauses. (@Koronen) - #1454: New
--only-guide-cops
andAllCops/StyleGuideCopsOnly
options that will only enforce cops that link to a style guide. (@marxarelli)
Changes
- #801: New style
context_dependent
forStyle/BracesAroundHashParameters
looks at preceding parameter to determine if braces should be used for final parameter. (@jonas054) - #1427: Excluding directories on the top level is now done earlier, so that these file trees are not searched, thus saving time when inspecting projects with many excluded files. (@jonas054)
- #1325: When running with
--auto-correct
, only offenses that can not be corrected will result in a non-zero exit code. (@jonas054) - #1445: Allow sprockets directive comments (starting with
#=
) inStyle/LeadingCommentSpace
. (@bbatsov)
Bugs fixed
- Fix
%W[]
auto corrected to%w(]
. (@toy) - Fix Style/ElseAlignment Cop to find the right parent on def/rescue/else/ensure/end. (@oneamtu)
- #1181: (fix again)
Style/StringLiterals
cop stays away from strings inside interpolated expressions. (@jonas054) - #1441: Correct the logic used by
Style/Blocks
and other cops to determine if an auto-correction would alter the meaning of the code. (@jonas054) - #1449: Handle the case in
MultilineOperationIndentation
where instances of both correct style and unrecognized (plain wrong) style are detected during an--auto-gen-config
run. (@jonas054) - #1456: Fix autocorrect in
SymbolProc
when there are multiple offenses on the same line. (@jcarbo) - #1459: Handle parenthesis around the condition in
--auto-correct
forNegatedWhile
. (@jonas054) - #1465: Fix autocorrect of code like
#$1
inPerlBackrefs
. (@bbatsov) - Fix autocorrect of code like
#$:
inSpecialGlobalVars
. (@bbatsov) - #1466: Allow leading underscore for unused parameters in
SingleLineBlockParams
. (@jonas054) - #1470: Handle
elsif
+else
inElseAlignment
. (@jonas054) - #1474: Multiline string with both
<<
and\
caught byStyle/LineEndConcatenation
cop. (@katieschilling) - #1485: Ignore procs in
SymbolProc
. (@bbatsov) - #1473:
Style/MultilineOperationIndentation
doesn't recognize assignment to array/hash element. (@jonas054)
RuboCop 0.27.1
Changes
- #1343: Remove auto-correct from
RescueException
cop. (@bbatsov) - #1425:
AllCops/Include
configuration parameters are only taken from the project.rubocop.yml
and files it inherits from, not from.rubocop.yml
files in subdirectories. (@jonas054)
Bugs fixed
- #1411: Handle lambda calls without a selector in
MultilineOperationIndentation
. (@bbatsov) - #1401: Files in hidden directories, i.e. ones beginning with dot, can now be selected through configuration, but are still not included by default. (@jonas054)
- #1415: String literals concatenated with backslashes are now handled correctly by
StringLiteralsInInterpolation
. (@jonas054) - #1416: Fix handling of
begin/rescue/else/end
inElseAlignment
. (@jonas054) - #1413: Support empty elsif branches in
MultilineIfThen
. (@janraasch, @jonas054) - #1406: Allow a newline in
SpaceInsideRangeLiteral
. (@bbatsov)
RuboCop 0.27.0
New features
- #1348: New cop
ElseAlignment
checks alignment ofelse
andelsif
keywords. (@jonas054) - #1321: New cop
MultilineOperationIndentation
checks indentation/alignment of binary operations if they span more than one line. (@jonas054) - #1077: New cop
Metrics/AbcSize
checks the ABC metric, based on assignments, branches, and conditions. (@jonas054, @jfelchner) - #1352:
WordArray
is now configurable with theWordRegex
option. (@bquorning) - #1181: New cop
Style/StringLiteralsInInterpolation
checks quotes inside interpolated expressions in strings. (@jonas054) - #872:
Style/IndentationWidth
is now configurable with theWidth
option. (@jonas054) - #1396: Include
.opal
files by default. (@bbatsov) - #771: Three new
Style
cops,EmptyLinesAroundMethodBody
,EmptyLinesAroundClassBody
, andEmptyLinesAroundModuleBody
replace theEmptyLinesAroundBody
cop. (@jonas054)
Changes
Bugs fixed
AlignHash
no longer skips multiline hashes that contain some elements on the same line. (@mvz)- #1349:
BracesAroundHashParameters
no longer cleans up whitespace in autocorrect, as these extra corrections are likely to interfere with other cops' corrections. (@jonas054) - #1350: Guard against
Blocks
cop introducing syntax errors in auto-correct. (@jonas054) - #1374: To eliminate interference, auto-correction is now done by one cop at a time, with saving and re-parsing inbetween. (@jonas054)
- #1388: Fix a false positive in
FormatString
. (@bbatsov) - #1389: Make
--out
to create parent directories. (@yous) - Refine HTML formatter. (@yujinakayama)
- #1410: Handle specially Java primitive type references in
ColonMethodCall
. (@bbatsov)
RuboCop 0.26.1
RuboCop 0.26.1 is a bugfix-only release. Below is a list of the bugs we've fixed since 0.26.0:
Bugs fixed
- #1326: Fix problem in
SpaceInsideParens
with detecting space inside parentheses used for grouping expressions. (@jonas054) - #1335: Restrict URI schemes permitted by
LineLength
whenAllowURI
is enabled. (@smangelsdorf) - #1339: Handle
eql?
andequal?
inOpMethod
. (@bbatsov) - #1340: Fix crash in
Style/SymbolProc
cop when the block calls a method with no explicit receiver. (@smangelsdorf)
RuboCop 0.26.0
Nothing particularly exciting this time around. The new release comes
with lots of bug fixes, more auto-corrections and several new cops.
Note that the Style/Encoding
cop is now disabled by default. See
#1304 for the rationale behind this change.
Below is the list of all the gory details. Enjoy!
New features
- New formatter
HTMLFormatter
generates a html file with a list of files with offences in them. (@SkuliOskarsson) - New cop
SpaceInsideRangeLiteral
checks for spaces around..
and...
in range literals. (@bbatsov) - New cop
InfiniteLoop
checks for places whereKernel#loop
should have been used. (@bbatsov) - New cop
SymbolProc
checks for places where a symbol can be used as proc instead of a block. (@bbatsov) UselessAssignment
cop now suggests a variable name for possible typos if there's a variable-ish identifier similar to the unused variable name in the same scope. (@yujinakayama)PredicateName
cop now has separate configurations for prefices that denote predicate method names and predicate prefices that should be removed. (@bbatsov)- #1272:
Tab
cop does auto-correction. (@yous) - #1274:
MultilineIfThen
cop does auto-correction. (@bbatsov) - #1279:
DotPosition
cop does auto-correction. (@yous) - #1277:
SpaceBeforeFirstArg
cop does auto-correction. (@yous) - #1310: Handle
module_function
inStyle/AccessModifierIndentation
andStyle/EmptyLinesAroundAccessModifier
. (@bbatsov)
Changes
- #1289: Use utf-8 as default encoding for inspected files. (@jonas054)
- #1304:
Style/Encoding
is no longer a no-op on Ruby 2.x. It's also disabled by default, as projects not supporting 1.9 don't need to run it. (@bbatsov)
Bugs fixed
- #1263: Do not report
%W
literals with special escaped characters inUnneededCapitalW
. (@jonas054) - #1286: Fix a false positive in
VariableName
. (@bbatsov) - #1211: Fix false negative in
UselessAssignment
when there's a reference for the variable in an exclusive branch. (@yujinakayama) - #1307: Fix auto-correction of
RedundantBegin
cop deletes new line. (@yous) - #1283: Fix auto-correction of indented expressions in
PercentLiteralDelimiters
. (@jonas054) - #1315:
BracesAroundHashParameters
auto-correction removes whitespace around content inside braces. (@jspanjers) - #1313: Fix a false positive in
AndOr
when enforced style isconditionals
. (@bbatsov) - Handle post-conditional
while
anduntil
inAndOr
when enforced style isconditionals
. (@yujinakayama) - #1319: Fix a false positive in
FormatString
. (@bbatsov) - #1287: Allow missing blank line for EmptyLinesAroundAccessModifier if next line closes a block. (@sch1zo)
RuboCop 0.25.0
This release comes with lots of bug fixes and several new cops (that will likely need bugfixes in the next release :-)).
The most notable change in 0.25 is the addition of the Metrics
namespace. Several Style
cops have been moved there
(e.g. ClassLength
, MethodLength
, etc).
This release also marks the end of us supporting Ruby 1.9.2 - now Ruby 1.9.3+ is required.
Below is the list of all the gory details. Enjoy!
New features
- #1259: Allow AndOr cop to autocorrect by adding method call parenthesis. (@vrthra)
- #1232: Add EnforcedStyle option to cop
AndOr
to restrict it to conditionals. (@vrthra) - #835: New cop
PercentQLiterals
checks if use of%Q
and%q
matches configuration. (@jonas054) - #835: New cop
BarePercentLiterals
checks if usage of%()
or%Q()
matches configuration. (@jonas054) - #1079: New cop
MultilineBlockLayout
checks if a multiline block has an extpression on the same line as the start of the block. (@barunio) - #1217:
Style::EmptyLinesAroundAccessModifier
cop does auto-correction. (@tamird) - #1220: New cop
PerceivedComplexity
is similar toCyclomaticComplexity
, but reports when methods have a high complexity for a human reader. (@jonas054) Debugger
cop now checks forbinding.pry_remote
. (@yous)- #1238: Add
MinBodyLength
option toNext
cop. (@bbatsov) - #1241:
TrailingComma
cop does auto-correction. (@yous) - #1078: New cop
BlockEndNewline
checks if the end statement of a multiline block is on its own line. (@barunio) - #1078:
BlockAlignment
cop does auto-correction. (@barunio)
Changes
- #1220: New namespace
Metrics
created and someStyle
cops moved there. (@jonas054) - Drop support for Ruby 1.9.2 in accordance with the end of the security maintenance extension. (@yujinakayama)
Bugs fixed
- #1251: Fix
PercentLiteralDelimiters
auto-correct indentation error. (@hannestyden) - #1197: Fix false positive for new lambda syntax in
SpaceInsideBlockBraces
. (@jonas054) - #1201: Fix error at anonymous keyword splat arguments in some variable cops. (@yujinakayama)
- Fix false positive in
UnneededPercentQ
for/%Q(something)/
. (@jonas054) - Fix
SpacesInsideBrackets
forHash#[]
calls with spaces after left bracket. (@mcls) - #1210: Fix false positive in
UnneededPercentQ
for%Q(\t")
. (@jonas054) - Fix false positive in
UnneededPercentQ
for heredoc strings with%q
/%Q
. (@jonas054) - #1214: Don't destroy code in
AlignHash
autocorrect. (@jonas054) - #1219: Don't report bad alignment for
end
or}
inBlockAlignment
if it doesn't begin its line. (@jonas054) - #1227: Don't permanently change yamler as it can affect other apps. (@jonas054)
- #1184: Fix a false positive in
Output
cop. (@bbatsov) - #1256: Ignore block-pass in
TrailingComma
. (@tamird) - #1255: Compare without context in
AutocorrectUnlessChangingAST
. (@jonas054) - #1262: Handle regexp and backtick literals in
VariableInterpolation
. (@bbatsov)