Skip to content

Commit ed66e63

Browse files
committed
Cut 1.19.0
1 parent 4eba6e9 commit ed66e63

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

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.19.0 (2023-08-13)
15+
1416
### New features
1517

1618
* [#364](https://github.com/rubocop/rubocop-performance/pull/364): Add new `Performance/MapMethodChain` cop. ([@koic][])

config/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Performance/MapMethodChain:
197197
Description: 'Checks if the `map` method is used in a chain.'
198198
Enabled: pending
199199
Safe: false
200-
VersionAdded: '<<next>>'
200+
VersionAdded: '1.19'
201201

202202
Performance/MethodObjectAsBlock:
203203
Description: 'Use block explicitly instead of block-passing a method object.'

docs/antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name: rubocop-performance
22
title: 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.19'
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
@@ -36,6 +36,7 @@ Performance cops optimization analysis for your projects.
3636
* xref:cops_performance.adoc#performanceinefficienthashsearch[Performance/InefficientHashSearch]
3737
* xref:cops_performance.adoc#performanceioreadlines[Performance/IoReadlines]
3838
* xref:cops_performance.adoc#performancemapcompact[Performance/MapCompact]
39+
* xref:cops_performance.adoc#performancemapmethodchain[Performance/MapMethodChain]
3940
* xref:cops_performance.adoc#performancemethodobjectasblock[Performance/MethodObjectAsBlock]
4041
* xref:cops_performance.adoc#performanceopenstruct[Performance/OpenStruct]
4142
* xref:cops_performance.adoc#performancerangeinclude[Performance/RangeInclude]

docs/modules/ROOT/pages/cops_performance.adoc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,59 @@ ary.map(&:foo).compact!
11751175
ary.compact.map(&:foo)
11761176
----
11771177

1178+
== Performance/MapMethodChain
1179+
1180+
|===
1181+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
1182+
1183+
| Pending
1184+
| No
1185+
| No
1186+
| 1.19
1187+
| -
1188+
|===
1189+
1190+
Checks if the map method is used in a chain.
1191+
1192+
Autocorrection is not supported because an appropriate block variable name cannot be determined automatically.
1193+
1194+
[source,ruby]
1195+
----
1196+
class X
1197+
def initialize
1198+
@@num = 0
1199+
end
1200+
1201+
def foo
1202+
@@num += 1
1203+
self
1204+
end
1205+
1206+
def bar
1207+
@@num * 2
1208+
end
1209+
end
1210+
1211+
[X.new, X.new].map(&:foo).map(&:bar) # => [4, 4]
1212+
[X.new, X.new].map { |x| x.foo.bar } # => [2, 4]
1213+
----
1214+
1215+
=== Safety
1216+
1217+
This cop is unsafe because false positives occur if the number of times the first method is executed
1218+
affects the return value of subsequent methods.
1219+
1220+
=== Examples
1221+
1222+
[source,ruby]
1223+
----
1224+
# bad
1225+
array.map(&:foo).map(&:bar)
1226+
1227+
# good
1228+
array.map { |item| item.foo.bar }
1229+
----
1230+
11781231
== Performance/MethodObjectAsBlock
11791232

11801233
|===

lib/rubocop/performance/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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.18.0'
7+
STRING = '1.19.0'
88

99
def self.document_version
1010
STRING.match('\d+\.\d+').to_s

relnotes/v1.19.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### New features
2+
3+
* [#364](https://github.com/rubocop/rubocop-performance/pull/364): Add new `Performance/MapMethodChain` cop. ([@koic][])
4+
* [#363](https://github.com/rubocop/rubocop-performance/pull/363): Support safe navigation operator for `Performance/ArraySemiInfiniteRangeSlice`, `Performance/DeletePrefix`, `Performance/DeleteSuffix`, `Performance/Detect`, `Performance/EndWith`, `Performance/InefficientHashSearch`, `Performance/MapCompact`, `Performance/RedundantSplitRegexpArgument`, `Performance/ReverseEach`, `Performance/ReverseFirst`, `Performance/SelectMap`, `Performance/Squeeze`, `Performance/StartWith`, `Performance/StringInclude`, and `Performance/StringReplacement` cops. ([@koic][])
5+
6+
[@koic]: https://github.com/koic

0 commit comments

Comments
 (0)