From 750371057a93ed72a6372cdc256aa231597d29a7 Mon Sep 17 00:00:00 2001 From: Tejas Bubane Date: Mon, 23 Nov 2020 16:30:54 +0530 Subject: [PATCH] [Fix #197] Disable `Performance/ArraySemiInfiniteRangeSlice` cop This cop was created due to a mistake in microbenchmark Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 Closes #197, #198 --- CHANGELOG.md | 4 ++++ config/default.yml | 6 +++++- docs/modules/ROOT/pages/cops_performance.adoc | 9 ++++++--- .../cop/performance/array_semi_infinite_range_slice.rb | 3 +++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638ede116e..1164365c3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [#185](https://github.com/rubocop-hq/rubocop-performance/issues/185): Fix incorrect replacement recommendation for `Performance/ChainArrayAllocation`. ([@fatkodima][]) +### Changes + +* [#197](https://github.com/rubocop-hq/rubocop-performance/issues/197): Disable `Performance/ArraySemiInfiniteRangeSlice` cop. ([@tejasbubane][]) + ## 1.9.0 (2020-11-17) ### New features diff --git a/config/default.yml b/config/default.yml index 547c610846..dfb20d66d7 100644 --- a/config/default.yml +++ b/config/default.yml @@ -9,7 +9,11 @@ Performance/AncestorsInclude: Performance/ArraySemiInfiniteRangeSlice: Description: 'Identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`.' - Enabled: pending + # This cop was created due to a mistake in microbenchmark. + # Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 + Enabled: false + # Unsafe for string slices because strings do not have `#take` and `#drop` methods. + Safe: false VersionAdded: '1.9' Performance/BigDecimalWithNumericArgument: diff --git a/docs/modules/ROOT/pages/cops_performance.adoc b/docs/modules/ROOT/pages/cops_performance.adoc index 499c3d28f0..407211b4c7 100644 --- a/docs/modules/ROOT/pages/cops_performance.adoc +++ b/docs/modules/ROOT/pages/cops_performance.adoc @@ -37,15 +37,18 @@ NOTE: Required Ruby version: 2.7 |=== | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged -| Pending -| Yes -| Yes +| Disabled +| No +| Yes (Unsafe) | 1.9 | - |=== This cop identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`. +This cop was created due to a mistake in microbenchmark and hence is disabled by default. +Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 +This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods. === Examples diff --git a/lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb b/lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb index dffe677c55..61250a3596 100644 --- a/lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb +++ b/lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb @@ -5,6 +5,9 @@ module Cop module Performance # This cop identifies places where slicing arrays with semi-infinite ranges # can be replaced by `Array#take` and `Array#drop`. + # This cop was created due to a mistake in microbenchmark and hence is disabled by default. + # Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 + # This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods. # # @example # # bad