New features
Style/UnlessElse
cop can auto-correct. (@lumeet)- #2629: Add a new public API method,
highlighted_area
to offense. This method returns the range of the highlighted portion of an offense. (@rrosenblum) Style/OneLineConditional
cop can auto-correct. (@lumeet)- #2905:
Style/ZeroLengthConditional
flags code likearray.length < 1
,1 > array.length
, and so on. (@alexdowad) - #2892:
Lint/BlockAlignment
cop can be configured to be stricter. (@ptarjan) Style/Not
is able to autocorrect in cases where parentheses must be added to preserve the meaning of an expression. (@alexdowad)Style/Not
auto-corrects comparison expressions by removingnot
and using the opposite comparison. (@alexdowad)
Bug fixes
- Add
require 'time'
toremote_config.rb
to avoid "undefined method `rfc2822'". (@necojackarc) - Replace
Rake::TaskManager#last_comment
withRake::TaskManager#last_description
for Rake 11 compatibility. (@tbrisker) - Fix false positive in
Style/TrailingCommaInArguments
&Style/TrailingCommaInLiteral
cops with consistent_comma style. (@meganemura) - #2861: Fix false positive in
Style/SpaceAroundKeyword
forrescue(...
. (@rrosenblum) - #2832:
Style/MultilineOperationIndentation
treats operations inside blocks inside other operations correctly. (@jonas054) - #2865: Change
require:
in config to be relative to the.rubocop.yml
file itself. (@ptarjan) - #2845: Handle heredocs in
Style/MultilineLiteralBraceLayout
auto-correct. (@jonas054) - #2848: Handle comments inside arrays in
Style/MultilineArrayBraceLayout
auto-correct. (@jonas054) Style/TrivialAccessors
allows predicate methods by default. (@alexdowad)- #2869: Offenses which occur in the body of a
when
clause with multiple arguments will not be missed. (@alexdowad) Lint/UselessAccessModifier
recognizes method defs inside abegin
block. (@alexdowad)- #2870:
Lint/UselessAccessModifier
recognizes method definitions which are passed as an argument to a method call. (@alexdowad) - #2859:
Style/RedundantParentheses
doesn't consider the parentheses in(!receiver.method arg)
to be redundant, since they might change the meaning of an expression, depending on precedence. (@alexdowad) - #2852:
Performance/Casecmp
doesn't flag uses ofdowncase
/upcase
which are not redundant. (@alexdowad) - #2850:
Style/FileName
doesn't choke on empty files with spaces in their names. (@alexdowad) - #2834: When configured as
ConsistentQuotesInMultiline: true
,Style/StringLiterals
doesn't error out when inspecting a heredoc with differing indentation across multiple lines. (@alexdowad) - #2876:
Style/ConditionalAssignment
behaves correctly when assignment statement uses a character which has a special meaning in a regex. (@alexdowad) - #2877:
Style/SpaceAroundKeyword
doesn't flag!super.method
,!yield.method
, and so on. (@alexdowad) - #2631:
Style/Encoding
can remove unneeded encoding comment when autocorrecting withwhen_needed
style. (@alexdowad) - #2860: Fix false positive in
Rails/Date
whento_time
is chained with safe method. (@palkan) - #2898:
Lint/NestedMethodDefinition
allows methods defined insideClass.new(S)
blocks. (@segiddins) - #2894: Fix auto-correct an unless with a comparison operator. (@jweir)
- #2911:
Style/ClassAndModuleChildren
doesn't flag nested class definitions, where the outer class has an explicit superclass (because such definitions can't be converted tocompact
style). (@alexdowad) - #2871: Don't crash when offense messages are read back from cache with
ASCII-8BIT
encoding and output as HTML or JSON. (@jonas054) - #2901: Don't crash when
ENV['HOME']
is undefined. (@mikegee) - #2627:
Style/BlockDelimiters
does not flag blocks delimited by{}
when a block call is the final value in a hash with implicit braces (one which is the last argument to an outer method call). (@alexdowad)
Changes
- Update Rake to version 11. (@tbrisker)
- #2629: Change the offense range for metrics cops to default to
expression
instead ofkeyword
(the offense now spans the entire method, class, or module). (@rrosenblum) - #2891: Change the caching of remote configs to live alongside the parent file. (@Fryguy)
- #2662: When setting options for Rake task, nested arrays can be used in the
options
,formatters
, andrequires
arrays. (@alexdowad) - #2925: Bump unicode-display_width dependency to >= 1.0.1. (@jspanjers)
- #2875:
Style/SignalException
does not flag calls tofail
if a custom method namedfail
is defined in the same file. (@alexdowad) - #2923:
Style/FileName
considers file names which contain a ? or ! character to still be "snake case". (@alexdowad) - #2879: When autocorrecting,
Lint/UnusedMethodArgument
removes unused block arguments rather than simply prefixing them with an underscore. (@alexdowad)