Skip to content

Commit 55df9e2

Browse files
committed
Cut 1.63
1 parent 752d351 commit 55df9e2

File tree

13 files changed

+152
-22
lines changed

13 files changed

+152
-22
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:
3838

3939
```
4040
$ [bundle exec] rubocop -V
41-
1.62.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
41+
1.63.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
4242
- rubocop-performance 1.18.0
4343
- rubocop-rspec 2.23.2
4444
```

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
## master (unreleased)
1313

14+
## 1.63.0 (2024-04-08)
15+
1416
### New features
1517

1618
* [#11878](https://github.com/rubocop/rubocop/issues/11878): Add new `Style/MapIntoArray` cop. ([@ymap][])

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ do so.
1717

1818
```console
1919
$ rubocop -V
20-
1.62.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
20+
1.63.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux]
2121
- rubocop-performance 1.18.0
2222
- rubocop-rspec 2.23.2
2323
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
5353
in your `Gemfile`:
5454

5555
```rb
56-
gem 'rubocop', '~> 1.62', require: false
56+
gem 'rubocop', '~> 1.63', require: false
5757
```
5858

5959
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.

config/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ Lint/Debugger:
16581658
Description: 'Check for debugger calls.'
16591659
Enabled: true
16601660
VersionAdded: '0.14'
1661-
VersionChanged: '<<next>>'
1661+
VersionChanged: '1.63'
16621662
DebuggerMethods:
16631663
# Groups are available so that a specific group can be disabled in
16641664
# a user's configuration, but are otherwise not significant.
@@ -4293,7 +4293,7 @@ Style/MapIntoArray:
42934293
Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
42944294
StyleGuide: '#functional-code'
42954295
Enabled: pending
4296-
VersionAdded: '<<next>>'
4296+
VersionAdded: '1.63'
42974297
Safe: false
42984298

42994299
Style/MapToHash:

docs/antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name: rubocop
22
title: RuboCop
33
# We always provide version without patch here (e.g. 1.1),
44
# as patch versions should not appear in the docs.
5-
version: ~
5+
version: '1.63'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ In the following section you find all available cops:
495495
* xref:cops_style.adoc#stylelineendconcatenation[Style/LineEndConcatenation]
496496
* xref:cops_style.adoc#stylemagiccommentformat[Style/MagicCommentFormat]
497497
* xref:cops_style.adoc#stylemapcompactwithconditionalblock[Style/MapCompactWithConditionalBlock]
498+
* xref:cops_style.adoc#stylemapintoarray[Style/MapIntoArray]
498499
* xref:cops_style.adoc#stylemaptohash[Style/MapToHash]
499500
* xref:cops_style.adoc#stylemaptoset[Style/MapToSet]
500501
* xref:cops_style.adoc#stylemethodcallwithargsparentheses[Style/MethodCallWithArgsParentheses]

docs/modules/ROOT/pages/cops_lint.adoc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Login
825825
| Yes
826826
| No
827827
| 0.14
828-
| 1.46
828+
| 1.63
829829
|===
830830
831831
Checks for debug calls (such as `debugger` or `binding.pry`) that should
@@ -854,6 +854,11 @@ Lint/Debugger:
854854
MyDebugger.debug_this
855855
----
856856
857+
Some gems also ship files that will start a debugging session when required,
858+
for example `require 'debug/start'` from `ruby/debug`. These requires can
859+
be configured through `DebuggerRequires`. It has the same structure as
860+
`DebuggerMethods`, which you can read about above.
861+
857862
=== Examples
858863
859864
[source,ruby]
@@ -898,13 +903,26 @@ def some_method
898903
end
899904
----
900905
906+
==== DebuggerRequires: [my_debugger/start]
907+
908+
[source,ruby]
909+
----
910+
# bad (ok during development)
911+
912+
require 'my_debugger/start'
913+
----
914+
901915
=== Configurable attributes
902916
903917
|===
904918
| Name | Default value | Configurable values
905919
906920
| DebuggerMethods
907-
| `{"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"]}`
921+
| `{"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"]}`
922+
|
923+
924+
| DebuggerRequires
925+
| `{"debug.rb"=>["debug/open", "debug/open_nonstop", "debug/start"]}`
908926
|
909927
|===
910928

docs/modules/ROOT/pages/cops_naming.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ anything/using_snake_case.rake
462462
| Name | Default value | Configurable values
463463
464464
| Exclude
465-
| `[]`
465+
| `Rakefile.rb`
466466
| Array
467467
468468
| ExpectMatchingDefinition

docs/modules/ROOT/pages/cops_style.adoc

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,9 +1862,7 @@ when the receiver is a hash object.
18621862
----
18631863
# bad
18641864
array.reject(&:nil?)
1865-
array.delete_if(&:nil?)
18661865
array.reject { |e| e.nil? }
1867-
array.delete_if { |e| e.nil? }
18681866
array.select { |e| !e.nil? }
18691867
array.grep_v(nil)
18701868
array.grep_v(NilClass)
@@ -1874,7 +1872,9 @@ array.compact
18741872
18751873
# bad
18761874
hash.reject!(&:nil?)
1875+
array.delete_if(&:nil?)
18771876
hash.reject! { |k, v| v.nil? }
1877+
array.delete_if { |e| e.nil? }
18781878
hash.select! { |k, v| !v.nil? }
18791879
18801880
# good
@@ -4897,35 +4897,35 @@ format('%s', [1, 2, 3]) #=> '[1, 2, 3]'
48974897
[source,ruby]
48984898
----
48994899
# bad
4900-
puts sprintf('%10s', 'hoge')
4901-
puts '%10s' % 'hoge'
4900+
puts sprintf('%10s', 'foo')
4901+
puts '%10s' % 'foo'
49024902
49034903
# good
4904-
puts format('%10s', 'hoge')
4904+
puts format('%10s', 'foo')
49054905
----
49064906
49074907
==== EnforcedStyle: sprintf
49084908
49094909
[source,ruby]
49104910
----
49114911
# bad
4912-
puts format('%10s', 'hoge')
4913-
puts '%10s' % 'hoge'
4912+
puts format('%10s', 'foo')
4913+
puts '%10s' % 'foo'
49144914
49154915
# good
4916-
puts sprintf('%10s', 'hoge')
4916+
puts sprintf('%10s', 'foo')
49174917
----
49184918
49194919
==== EnforcedStyle: percent
49204920
49214921
[source,ruby]
49224922
----
49234923
# bad
4924-
puts format('%10s', 'hoge')
4925-
puts sprintf('%10s', 'hoge')
4924+
puts format('%10s', 'foo')
4925+
puts sprintf('%10s', 'foo')
49264926
49274927
# good
4928-
puts '%10s' % 'hoge'
4928+
puts '%10s' % 'foo'
49294929
----
49304930
49314931
=== Configurable attributes
@@ -7216,6 +7216,70 @@ array.select { |e| some_condition? }
72167216
array.reject { |e| some_condition? }
72177217
----
72187218
7219+
== Style/MapIntoArray
7220+
7221+
|===
7222+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
7223+
7224+
| Pending
7225+
| No
7226+
| Always (Unsafe)
7227+
| 1.63
7228+
| -
7229+
|===
7230+
7231+
Checks for usages of `each` with `<<`, `push`, or `append` which
7232+
can be replaced by `map`.
7233+
7234+
If `PreferredMethods` is configured for `map` in `Style/CollectionMethods`,
7235+
this cop uses the specified method for replacement.
7236+
7237+
NOTE: The return value of `Enumerable#each` is `self`, whereas the
7238+
return value of `Enumerable#map` is an `Array`. They are not autocorrected
7239+
when a return value could be used because these types differ.
7240+
7241+
NOTE: It only detects when the mapping destination is a local variable
7242+
initialized as an empty array and referred to only by the pushing operation.
7243+
This is because, if not, it's challenging to statically guarantee that the
7244+
mapping destination variable remains an empty array:
7245+
7246+
[source,ruby]
7247+
----
7248+
src.each { |e| @dest << e * 2 } # `src` method may mutate `@dest`
7249+
7250+
dest = []
7251+
src.each { |e| dest << transform(e, dest) } # `transform` method may mutate `dest`
7252+
----
7253+
7254+
=== Safety
7255+
7256+
This cop is unsafe because not all objects that have an `each`
7257+
method also have a `map` method (e.g. `ENV`). Additionally, for calls
7258+
with a block, not all objects that have a `map` method return an array
7259+
(e.g. `Enumerator::Lazy`).
7260+
7261+
=== Examples
7262+
7263+
[source,ruby]
7264+
----
7265+
# bad
7266+
dest = []
7267+
src.each { |e| dest << e * 2 }
7268+
dest
7269+
7270+
# good
7271+
dest = src.map { |e| e * 2 }
7272+
7273+
# good - contains another operation
7274+
dest = []
7275+
src.each { |e| dest << e * 2; puts e }
7276+
dest
7277+
----
7278+
7279+
=== References
7280+
7281+
* https://rubystyle.guide#functional-code
7282+
72197283
== Style/MapToHash
72207284
72217285
NOTE: Required Ruby version: 2.6

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy