Skip to content

Commit

Permalink
[Fix #8783] Disable Style/ArrayCoercion cop by default
Browse files Browse the repository at this point in the history
Fixes #8783, #8391, and #8334.

This PR disables `Style/ArrayCoercion` cop by default.
Because false positive will occur if the argument of `Array()` is not an array (e.g. Hash, Set),
an array will be returned as an incompatibility result.
  • Loading branch information
koic authored and bbatsov committed Sep 25, 2020
1 parent d5a5506 commit 9526de4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

* [#8785](https://github.com/rubocop-hq/rubocop/pull/8785): Update TargetRubyVersion 2.8 to 3.0 (experimental). ([@koic][])
* [#8650](https://github.com/rubocop-hq/rubocop/issues/8650): Faster find of hidden files in `TargetFinder` class which improves rubocop initial startup speed. ([@tleish][])
* [#8783](https://github.com/rubocop-hq/rubocop/pull/8783): Disable `Style/ArrayCoercion` cop by default. ([@koic][])

## 0.91.1 (2020-09-23)

Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ Style/ArrayCoercion:
with a variable you want to treat as an Array, but you're not certain it's an array.
StyleGuide: '#array-coercion'
Safe: false
Enabled: 'pending'
Enabled: false
VersionAdded: '0.88'

Style/ArrayJoin:
Expand Down
6 changes: 5 additions & 1 deletion docs/modules/ROOT/pages/cops_style.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ end
|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Pending
| Disabled
| No
| Yes (Unsafe)
| 0.88
Expand All @@ -304,6 +304,10 @@ end

This cop enforces the use of `Array()` instead of explicit `Array` check or `[*var]`.

This cop is disabled by default because false positive will occur if
the argument of `Array()` is not an array (e.g. Hash, Set),
an array will be returned as an incompatibility result.

=== Examples

[source,ruby]
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/style/array_coercion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module Cop
module Style
# This cop enforces the use of `Array()` instead of explicit `Array` check or `[*var]`.
#
# This cop is disabled by default because false positive will occur if
# the argument of `Array()` is not an array (e.g. Hash, Set),
# an array will be returned as an incompatibility result.
#
# @example
# # bad
# paths = [paths] unless paths.is_a?(Array)
Expand Down

0 comments on commit 9526de4

Please sign in to comment.