Skip to content

Commit

Permalink
Cut 1.63
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Apr 8, 2024
1 parent 752d351 commit 55df9e2
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:

```
$ [bundle exec] rubocop -V
1.62.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
1.63.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
- rubocop-performance 1.18.0
- rubocop-rspec 2.23.2
```
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

## master (unreleased)

## 1.63.0 (2024-04-08)

### New features

* [#11878](https://github.com/rubocop/rubocop/issues/11878): Add new `Style/MapIntoArray` cop. ([@ymap][])
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do so.

```console
$ rubocop -V
1.62.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
1.63.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
- rubocop-performance 1.18.0
- rubocop-rspec 2.23.2
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
in your `Gemfile`:

```rb
gem 'rubocop', '~> 1.62', require: false
gem 'rubocop', '~> 1.63', require: false
```

See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ Lint/Debugger:
Description: 'Check for debugger calls.'
Enabled: true
VersionAdded: '0.14'
VersionChanged: '<<next>>'
VersionChanged: '1.63'
DebuggerMethods:
# Groups are available so that a specific group can be disabled in
# a user's configuration, but are otherwise not significant.
Expand Down Expand Up @@ -4293,7 +4293,7 @@ Style/MapIntoArray:
Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
StyleGuide: '#functional-code'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.63'
Safe: false

Style/MapToHash:
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: rubocop
title: RuboCop
# We always provide version without patch here (e.g. 1.1),
# as patch versions should not appear in the docs.
version: ~
version: '1.63'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#stylelineendconcatenation[Style/LineEndConcatenation]
* xref:cops_style.adoc#stylemagiccommentformat[Style/MagicCommentFormat]
* xref:cops_style.adoc#stylemapcompactwithconditionalblock[Style/MapCompactWithConditionalBlock]
* xref:cops_style.adoc#stylemapintoarray[Style/MapIntoArray]
* xref:cops_style.adoc#stylemaptohash[Style/MapToHash]
* xref:cops_style.adoc#stylemaptoset[Style/MapToSet]
* xref:cops_style.adoc#stylemethodcallwithargsparentheses[Style/MethodCallWithArgsParentheses]
Expand Down
22 changes: 20 additions & 2 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ Login
| Yes
| No
| 0.14
| 1.46
| 1.63
|===
Checks for debug calls (such as `debugger` or `binding.pry`) that should
Expand Down Expand Up @@ -854,6 +854,11 @@ Lint/Debugger:
MyDebugger.debug_this
----
Some gems also ship files that will start a debugging session when required,
for example `require 'debug/start'` from `ruby/debug`. These requires can
be configured through `DebuggerRequires`. It has the same structure as
`DebuggerMethods`, which you can read about above.
=== Examples
[source,ruby]
Expand Down Expand Up @@ -898,13 +903,26 @@ def some_method
end
----
==== DebuggerRequires: [my_debugger/start]
[source,ruby]
----
# bad (ok during development)
require 'my_debugger/start'
----
=== Configurable attributes
|===
| Name | Default value | Configurable values
| DebuggerMethods
| `{"Kernel"=>["binding.irb", "Kernel.binding.irb"], "Byebug"=>["byebug", "remote_byebug", "Kernel.byebug", "Kernel.remote_byebug"], "Capybara"=>["save_and_open_page", "save_and_open_screenshot"], "debug.rb"=>["binding.b", "binding.break", "Kernel.binding.b", "Kernel.binding.break"], "Pry"=>["binding.pry", "binding.remote_pry", "binding.pry_remote", "Kernel.binding.pry", "Kernel.binding.remote_pry", "Kernel.binding.pry_remote", "Pry.rescue", "pry"], "Rails"=>["debugger", "Kernel.debugger"], "RubyJard"=>["jard"], "WebConsole"=>["binding.console"]}`
| `{"Kernel"=>["binding.irb", "Kernel.binding.irb"], "Byebug"=>["byebug", "remote_byebug", "Kernel.byebug", "Kernel.remote_byebug"], "Capybara"=>["page.save_and_open_page", "page.save_and_open_screenshot", "page.save_page", "page.save_screenshot", "save_and_open_page", "save_and_open_screenshot", "save_page", "save_screenshot"], "debug.rb"=>["binding.b", "binding.break", "Kernel.binding.b", "Kernel.binding.break"], "Pry"=>["binding.pry", "binding.remote_pry", "binding.pry_remote", "Kernel.binding.pry", "Kernel.binding.remote_pry", "Kernel.binding.pry_remote", "Pry.rescue", "pry"], "Rails"=>["debugger", "Kernel.debugger"], "RubyJard"=>["jard"], "WebConsole"=>["binding.console"]}`
|
| DebuggerRequires
| `{"debug.rb"=>["debug/open", "debug/open_nonstop", "debug/start"]}`
|
|===
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_naming.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ anything/using_snake_case.rake
| Name | Default value | Configurable values
| Exclude
| `[]`
| `Rakefile.rb`
| Array
| ExpectMatchingDefinition
Expand Down
86 changes: 75 additions & 11 deletions docs/modules/ROOT/pages/cops_style.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1862,9 +1862,7 @@ when the receiver is a hash object.
----
# bad
array.reject(&:nil?)
array.delete_if(&:nil?)
array.reject { |e| e.nil? }
array.delete_if { |e| e.nil? }
array.select { |e| !e.nil? }
array.grep_v(nil)
array.grep_v(NilClass)
Expand All @@ -1874,7 +1872,9 @@ array.compact
# bad
hash.reject!(&:nil?)
array.delete_if(&:nil?)
hash.reject! { |k, v| v.nil? }
array.delete_if { |e| e.nil? }
hash.select! { |k, v| !v.nil? }
# good
Expand Down Expand Up @@ -4897,35 +4897,35 @@ format('%s', [1, 2, 3]) #=> '[1, 2, 3]'
[source,ruby]
----
# bad
puts sprintf('%10s', 'hoge')
puts '%10s' % 'hoge'
puts sprintf('%10s', 'foo')
puts '%10s' % 'foo'
# good
puts format('%10s', 'hoge')
puts format('%10s', 'foo')
----
==== EnforcedStyle: sprintf
[source,ruby]
----
# bad
puts format('%10s', 'hoge')
puts '%10s' % 'hoge'
puts format('%10s', 'foo')
puts '%10s' % 'foo'
# good
puts sprintf('%10s', 'hoge')
puts sprintf('%10s', 'foo')
----
==== EnforcedStyle: percent
[source,ruby]
----
# bad
puts format('%10s', 'hoge')
puts sprintf('%10s', 'hoge')
puts format('%10s', 'foo')
puts sprintf('%10s', 'foo')
# good
puts '%10s' % 'hoge'
puts '%10s' % 'foo'
----
=== Configurable attributes
Expand Down Expand Up @@ -7216,6 +7216,70 @@ array.select { |e| some_condition? }
array.reject { |e| some_condition? }
----
== Style/MapIntoArray
|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
| Pending
| No
| Always (Unsafe)
| 1.63
| -
|===
Checks for usages of `each` with `<<`, `push`, or `append` which
can be replaced by `map`.
If `PreferredMethods` is configured for `map` in `Style/CollectionMethods`,
this cop uses the specified method for replacement.
NOTE: The return value of `Enumerable#each` is `self`, whereas the
return value of `Enumerable#map` is an `Array`. They are not autocorrected
when a return value could be used because these types differ.
NOTE: It only detects when the mapping destination is a local variable
initialized as an empty array and referred to only by the pushing operation.
This is because, if not, it's challenging to statically guarantee that the
mapping destination variable remains an empty array:
[source,ruby]
----
src.each { |e| @dest << e * 2 } # `src` method may mutate `@dest`
dest = []
src.each { |e| dest << transform(e, dest) } # `transform` method may mutate `dest`
----
=== Safety
This cop is unsafe because not all objects that have an `each`
method also have a `map` method (e.g. `ENV`). Additionally, for calls
with a block, not all objects that have a `map` method return an array
(e.g. `Enumerator::Lazy`).
=== Examples
[source,ruby]
----
# bad
dest = []
src.each { |e| dest << e * 2 }
dest
# good
dest = src.map { |e| e * 2 }
# good - contains another operation
dest = []
src.each { |e| dest << e * 2; puts e }
dest
----
=== References
* https://rubystyle.guide#functional-code
== Style/MapToHash
NOTE: Required Ruby version: 2.6
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in your `Gemfile`:

[source,rb]
----
gem 'rubocop', '~> 1.62', require: false
gem 'rubocop', '~> 1.63', require: false
----

.A Modular RuboCop
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RuboCop
# This module holds the RuboCop version information.
module Version
STRING = '1.62.1'
STRING = '1.63.0'

MSG = '%<version>s (using %<parser_version>s, ' \
'rubocop-ast %<rubocop_ast_version>s, ' \
Expand Down
45 changes: 45 additions & 0 deletions relnotes/v1.63.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### New features

* [#11878](https://github.com/rubocop/rubocop/issues/11878): Add new `Style/MapIntoArray` cop. ([@ymap][])
* [#12186](https://github.com/rubocop/rubocop/pull/12186): Add new `requires_gem` API for declaring which gems a Cop needs. ([@amomchilov][])

### Bug fixes

* [#12769](https://github.com/rubocop/rubocop/issues/12769): Fix a false positive for `Lint/RedundantWithIndex` when calling `with_index` with receiver and a block. ([@koic][])
* [#12547](https://github.com/rubocop/rubocop/issues/12547): Added a comment recommending upgrading to the latest version of Rubocop in the error text when an Infinite loop detected error occurs. ([@Hiroto-Iizuka][])
* [#12782](https://github.com/rubocop/rubocop/pull/12782): Fix an error for `Style/Alias` with `EnforcedStyle: prefer_alias` when calling `alias_method` with fewer than 2 arguments. ([@earlopain][])
* [#12781](https://github.com/rubocop/rubocop/pull/12781): Fix an error for `Style/ExactRegexpMatch` when calling `match` without a receiver. ([@earlopain][])
* [#12780](https://github.com/rubocop/rubocop/issues/12780): Fix an error for `Style/RedundantEach` when using `reverse_each.each` without a block. ([@earlopain][])
* [#12731](https://github.com/rubocop/rubocop/pull/12731): Treat `&.` the same way as `.` for setter methods in `Lint/AssignmentInCondition`. ([@jonas054][])
* [#12793](https://github.com/rubocop/rubocop/issues/12793): Fix false positives for `Style/RedundantLineContinuation` when using line continuation with modifier. ([@koic][])
* [#12807](https://github.com/rubocop/rubocop/issues/12807): Fix false positives for `Naming/BlockForwarding` when using explicit block forwarding in block method and others. ([@koic][])
* [#12796](https://github.com/rubocop/rubocop/pull/12796): Fix false positives for `Style/EvalWithLocation` when using `eval` with a line number from a method call or a variable. ([@koic][])
* [#12794](https://github.com/rubocop/rubocop/issues/12794): Fix false positives for `Style/RedundantArgument` when when single-quoted strings for cntrl character. ([@koic][])
* [#12797](https://github.com/rubocop/rubocop/issues/12797): Fix false positives for `Style/RedundantLineContinuation` when using line continuations with `&&` or `||` operator in assignment. ([@koic][])
* [#12793](https://github.com/rubocop/rubocop/issues/12793): Fix false positives for `Style/RedundantLineContinuation` when multi-line continuations with operators. ([@koic][])
* [#12801](https://github.com/rubocop/rubocop/issues/12801): Fix incorrect autocorrect for `Style/CollectionCompact` when using `delete_if`. ([@koic][])
* [#12789](https://github.com/rubocop/rubocop/pull/12789): Make `Style/RedundantPercentQ` safe on multiline strings. ([@boardfish][])
* [#12802](https://github.com/rubocop/rubocop/pull/12802): Return global offenses for `Naming/FileName` and `Naming/InclusiveLanguage` for empty files. ([@earlopain][])
* [#12804](https://github.com/rubocop/rubocop/pull/12804): Return global offenses for `Style/Copyright` when the file is empty. ([@earlopain][])

### Changes

* [#12813](https://github.com/rubocop/rubocop/pull/12813): Add rubocop-rspec_rails to suggested extensions and extension doc. ([@ydah][])
* [#12820](https://github.com/rubocop/rubocop/pull/12820): Add support more Capybara debugger entry points for `Lint/Debugger`. ([@ydah][])
* [#12676](https://github.com/rubocop/rubocop/issues/12676): Adjust offending range in LSP. ([@koic][])
* [#12815](https://github.com/rubocop/rubocop/issues/12815): Ignore `Rakefile.rb` in `Naming/FileName` in the default config. ([@artur-intech][])
* [#12800](https://github.com/rubocop/rubocop/pull/12800): Handle empty obsoletion config. ([@sambostock][])
* [#12721](https://github.com/rubocop/rubocop/issues/12721): Make `Lint/Debugger` aware of `ruby/debug` requires. ([@earlopain][])
* [#12817](https://github.com/rubocop/rubocop/pull/12817): Make `rubocop -V` display rubocop-rspec_rails version when using it. ([@ydah][])
* [#12180](https://github.com/rubocop/rubocop/pull/12180): Replace regex with `Bundler::LockfileParser`. ([@amomchilov][])

[@ymap]: https://github.com/ymap
[@amomchilov]: https://github.com/amomchilov
[@koic]: https://github.com/koic
[@Hiroto-Iizuka]: https://github.com/Hiroto-Iizuka
[@earlopain]: https://github.com/earlopain
[@jonas054]: https://github.com/jonas054
[@boardfish]: https://github.com/boardfish
[@ydah]: https://github.com/ydah
[@artur-intech]: https://github.com/artur-intech
[@sambostock]: https://github.com/sambostock

0 comments on commit 55df9e2

Please sign in to comment.