From 24a3a4e2af013f1378dca53d541dafed9487e5e8 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 16 Feb 2025 01:06:43 +0900 Subject: [PATCH] Cut 1.24.0 --- CHANGELOG.md | 2 ++ config/default.yml | 2 +- docs/antora.yml | 2 +- docs/modules/ROOT/pages/cops.adoc | 1 + docs/modules/ROOT/pages/cops_performance.adoc | 35 +++++++++++++++++++ lib/rubocop/performance/version.rb | 2 +- relnotes/v1.24.0.md | 12 +++++++ 7 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 relnotes/v1.24.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f801d14a46..1d8bbc8dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## master (unreleased) +## 1.24.0 (2025-02-16) + ### New features * [#490](https://github.com/rubocop/rubocop-performance/pull/490): Pluginfy RuboCop Performance. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index 0ebb259928..606acb83df 100644 --- a/config/default.yml +++ b/config/default.yml @@ -386,4 +386,4 @@ Performance/ZipWithoutBlock: Description: 'Checks for `map { |id| [id] }` and suggests replacing it with `zip`.' Enabled: pending Safe: false - VersionAdded: <> + VersionAdded: '1.24' diff --git a/docs/antora.yml b/docs/antora.yml index 21b1815a34..3ee5f7e808 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -2,6 +2,6 @@ name: rubocop-performance title: RuboCop Performance # We always provide version without patch here (e.g. 1.1), # as patch versions should not appear in the docs. -version: ~ +version: '1.24' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops.adoc b/docs/modules/ROOT/pages/cops.adoc index 7e91ba8416..d319e7fd96 100644 --- a/docs/modules/ROOT/pages/cops.adoc +++ b/docs/modules/ROOT/pages/cops.adoc @@ -63,5 +63,6 @@ Performance cops optimization analysis for your projects. * xref:cops_performance.adoc#performancetimesmap[Performance/TimesMap] * xref:cops_performance.adoc#performanceunfreezestring[Performance/UnfreezeString] * xref:cops_performance.adoc#performanceuridefaultparser[Performance/UriDefaultParser] +* xref:cops_performance.adoc#performancezipwithoutblock[Performance/ZipWithoutBlock] // END_COP_LIST diff --git a/docs/modules/ROOT/pages/cops_performance.adoc b/docs/modules/ROOT/pages/cops_performance.adoc index 5c78a3f0e1..bae90e109e 100644 --- a/docs/modules/ROOT/pages/cops_performance.adoc +++ b/docs/modules/ROOT/pages/cops_performance.adoc @@ -2598,3 +2598,38 @@ URI::Parser.new # good URI::DEFAULT_PARSER ---- + +[#performancezipwithoutblock] +== Performance/ZipWithoutBlock + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| No +| Always (Unsafe) +| 1.24 +| - +|=== + +Checks for `map { |id| [id] }` and suggests replacing it with `zip`. + +[#safety-performancezipwithoutblock] +=== Safety + +This cop is unsafe for novel definitions of `map` and `collect` +on non-Enumerable objects that do not respond to `zip`. +To make your object enumerable, define an `each` method +as described in https://ruby-doc.org/core/Enumerable.html + +[#examples-performancezipwithoutblock] +=== Examples + +[source,ruby] +---- +# bad +[1, 2, 3].map { |id| [id] } + +# good +[1, 2, 3].zip +---- diff --git a/lib/rubocop/performance/version.rb b/lib/rubocop/performance/version.rb index 103e69b485..24695abafb 100644 --- a/lib/rubocop/performance/version.rb +++ b/lib/rubocop/performance/version.rb @@ -4,7 +4,7 @@ module RuboCop module Performance # This module holds the RuboCop Performance version information. module Version - STRING = '1.23.1' + STRING = '1.24.0' def self.document_version STRING.match('\d+\.\d+').to_s diff --git a/relnotes/v1.24.0.md b/relnotes/v1.24.0.md new file mode 100644 index 0000000000..2c9a4586c3 --- /dev/null +++ b/relnotes/v1.24.0.md @@ -0,0 +1,12 @@ +### New features + +* [#490](https://github.com/rubocop/rubocop-performance/pull/490): Pluginfy RuboCop Performance. ([@koic][]) +* [#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][]) + +### Bug fixes + +* [#484](https://github.com/rubocop/rubocop-performance/pull/484): Fix `Performance/CaseWhenSplat` cop error on `when` node without body. ([@viralpraxis][]) + +[@koic]: https://github.com/koic +[@corsonknowles]: https://github.com/corsonknowles +[@viralpraxis]: https://github.com/viralpraxis