File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212## master (unreleased)
1313
14+ ## 1.24.0 (2025-02-16)
15+
1416### New features
1517
1618* [ #490 ] ( https://github.com/rubocop/rubocop-performance/pull/490 ) : Pluginfy RuboCop Performance. ([ @koic ] [ ] )
Original file line number Diff line number Diff line change @@ -386,4 +386,4 @@ Performance/ZipWithoutBlock:
386386 Description : ' Checks for `map { |id| [id] }` and suggests replacing it with `zip`.'
387387 Enabled : pending
388388 Safe : false
389- VersionAdded : <<next>>
389+ VersionAdded : ' 1.24 '
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ name: rubocop-performance
22title : RuboCop Performance
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.24 '
66nav :
77 - modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change @@ -63,5 +63,6 @@ Performance cops optimization analysis for your projects.
6363* xref:cops_performance.adoc#performancetimesmap[Performance/TimesMap]
6464* xref:cops_performance.adoc#performanceunfreezestring[Performance/UnfreezeString]
6565* xref:cops_performance.adoc#performanceuridefaultparser[Performance/UriDefaultParser]
66+ * xref:cops_performance.adoc#performancezipwithoutblock[Performance/ZipWithoutBlock]
6667
6768// END_COP_LIST
Original file line number Diff line number Diff line change @@ -2598,3 +2598,38 @@ URI::Parser.new
25982598# good
25992599URI::DEFAULT_PARSER
26002600----
2601+
2602+ [#performancezipwithoutblock]
2603+ == Performance/ZipWithoutBlock
2604+
2605+ |===
2606+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
2607+
2608+ | Pending
2609+ | No
2610+ | Always (Unsafe)
2611+ | 1.24
2612+ | -
2613+ |===
2614+
2615+ Checks for `map { |id| [id] }` and suggests replacing it with `zip`.
2616+
2617+ [#safety-performancezipwithoutblock]
2618+ === Safety
2619+
2620+ This cop is unsafe for novel definitions of `map` and `collect`
2621+ on non-Enumerable objects that do not respond to `zip`.
2622+ To make your object enumerable, define an `each` method
2623+ as described in https://ruby-doc.org/core/Enumerable.html
2624+
2625+ [#examples-performancezipwithoutblock]
2626+ === Examples
2627+
2628+ [source,ruby]
2629+ ----
2630+ # bad
2631+ [1, 2, 3].map { |id| [id] }
2632+
2633+ # good
2634+ [1, 2, 3].zip
2635+ ----
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module RuboCop
44 module Performance
55 # This module holds the RuboCop Performance version information.
66 module Version
7- STRING = '1.23.1 '
7+ STRING = '1.24.0 '
88
99 def self . document_version
1010 STRING . match ( '\d+\.\d+' ) . to_s
Original file line number Diff line number Diff line change 1+ ### New features
2+
3+ * [ #490 ] ( https://github.com/rubocop/rubocop-performance/pull/490 ) : Pluginfy RuboCop Performance. ([ @koic ] [ ] )
4+ * [ #462 ] ( https://github.com/rubocop/rubocop-performance/pull/462 ) : Add new ` Performance/ZipWithoutBlock ` cop that checks patterns like ` .map { |id| [id] } ` or ` .map { [_1] } ` and can replace them with ` .zip ` . ([ @corsonknowles ] [ ] )
5+
6+ ### Bug fixes
7+
8+ * [ #484 ] ( https://github.com/rubocop/rubocop-performance/pull/484 ) : Fix ` Performance/CaseWhenSplat ` cop error on ` when ` node without body. ([ @viralpraxis ] [ ] )
9+
10+ [ @koic ] : https://github.com/koic
11+ [ @corsonknowles ] : https://github.com/corsonknowles
12+ [ @viralpraxis ] : https://github.com/viralpraxis
You can’t perform that action at this time.
0 commit comments