From f79ecaa45ad7c712ae2242357f780f5cebd23aa6 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 16 Dec 2023 09:17:01 +0800 Subject: [PATCH] Cut 1.20.0 --- CHANGELOG.md | 2 ++ docs/antora.yml | 2 +- docs/modules/ROOT/pages/cops_performance.adoc | 10 +++++---- lib/rubocop/performance/version.rb | 2 +- relnotes/v1.20.0.md | 22 +++++++++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 relnotes/v1.20.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d38f1bea..a7dcdb6827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## master (unreleased) +## 1.20.0 (2023-12-16) + ### New features * [#384](https://github.com/rubocop/rubocop-performance/issues/384): Support optimized `String#dup` for `Performance/UnfreezeString` when Ruby 3.3+. ([@koic][]) diff --git a/docs/antora.yml b/docs/antora.yml index 21b1815a34..186bc944d1 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.20' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops_performance.adoc b/docs/modules/ROOT/pages/cops_performance.adoc index 29dd534556..d25ab7891e 100644 --- a/docs/modules/ROOT/pages/cops_performance.adoc +++ b/docs/modules/ROOT/pages/cops_performance.adoc @@ -544,8 +544,7 @@ passed to the `count` call. === Safety This cop is unsafe because it has known compatibility issues with `ActiveRecord` and other -frameworks. ActiveRecord's `count` ignores the block that is passed to it. -`ActiveRecord` will ignore the block that is passed to `count`. +frameworks. Before Rails 5.1, `ActiveRecord` will ignore the block that is passed to `count`. Other methods, such as `select`, will convert the association to an array and then run the block on the array. A simple work around to make `count` work with a block is to call `to_a.count {...}`. @@ -2075,11 +2074,13 @@ and the following examples are parts of it. send('do_something') attr_accessor 'do_something' instance_variable_get('@ivar') +const_get("string_#{interpolation}") # good send(:do_something) attr_accessor :do_something instance_variable_get(:@ivar) +const_get(:"string_#{interpolation}") ---- == Performance/StringInclude @@ -2111,6 +2112,7 @@ str =~ /ab/ /ab/ =~ str str.match(/ab/) /ab/.match(str) +/ab/ === str # good str.include?('ab') @@ -2328,8 +2330,8 @@ if you expect `ASCII-8BIT` encoding, disable this cop. [source,ruby] ---- # bad -''.dup -"something".dup +''.dup # when Ruby 3.2 or lower +"something".dup # when Ruby 3.2 or lower String.new String.new('') String.new('something') diff --git a/lib/rubocop/performance/version.rb b/lib/rubocop/performance/version.rb index 52ddb9e887..567e69737a 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.19.1' + STRING = '1.20.0' def self.document_version STRING.match('\d+\.\d+').to_s diff --git a/relnotes/v1.20.0.md b/relnotes/v1.20.0.md new file mode 100644 index 0000000000..92530dc39b --- /dev/null +++ b/relnotes/v1.20.0.md @@ -0,0 +1,22 @@ +### New features + +* [#384](https://github.com/rubocop/rubocop-performance/issues/384): Support optimized `String#dup` for `Performance/UnfreezeString` when Ruby 3.3+. ([@koic][]) + +### Bug fixes + +* [#374](https://github.com/rubocop/rubocop-performance/issues/374): Fix an error for `Performance/MapMethodChain` when using `map` method chain without receiver. ([@koic][]) +* [#386](https://github.com/rubocop/rubocop-performance/issues/386): Fix a false negative for `Performance/StringIdentifierArgument` when using string interpolation. ([@earlopain][]) +* [#419](https://github.com/rubocop/rubocop-performance/pull/419): Make `Performance/Count`, `Performance/FixedSize`, `Performance/FlatMap`, `Performance/InefficientHashSearch`, `Performance/RangeInclude`, `Performance/RedundantSortBlock`, `Performance/ReverseFirst`, `Performance/SelectMap`, `Performance/Size`, `Performance/SortReverse`, and `Performance/TimesMap` cops aware of safe navigation operator. ([@koic][]) +* [#390](https://github.com/rubocop/rubocop-performance/issues/390): Fix a false negative for `Performance/ReverseEach` when safe navigation is between `reverse` and `each`. ([@fatkodima][]) +* [#401](https://github.com/rubocop/rubocop-performance/issues/401): Make `Performance/Sum` aware of safe navigation operator. ([@koic][]) + +### Changes + +* [#389](https://github.com/rubocop/rubocop-performance/issues/389): Improve `Performance/MapCompact` to handle more safe navigation calls. ([@fatkodima][]) +* [#395](https://github.com/rubocop/rubocop-performance/issues/395): Enhance `Performance/StringInclude` to handle `===` method. ([@fatkodima][]) +* [#388](https://github.com/rubocop/rubocop-performance/pull/388): Require RuboCop 1.30+ as runtime dependency. ([@koic][]) +* [#380](https://github.com/rubocop/rubocop-performance/pull/380): Require RuboCop AST 1.30.0+. ([@koic][]) + +[@koic]: https://github.com/koic +[@earlopain]: https://github.com/earlopain +[@fatkodima]: https://github.com/fatkodima