Skip to content

Commit

Permalink
Mark Lint/RedundantDirGlobSort's autocorrection as unsafe (#10446)
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlyantz committed Mar 9, 2022
1 parent c95a26d commit 857e682
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/fix_lintredundantdirglobsort_unset.md
@@ -0,0 +1 @@
* [#10446](https://github.com/rubocop/rubocop/pull/10446): Lint/RedundantDirGlobSort unset SafeAutoCorrect. ([@friendlyantz][])
2 changes: 2 additions & 0 deletions config/default.yml
Expand Up @@ -2013,6 +2013,8 @@ Lint/RedundantDirGlobSort:
Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
Enabled: pending
VersionAdded: '1.8'
VersionChanged: '<<next>>'
SafeAutoCorrect: false

Lint/RedundantRequireStatement:
Description: 'Checks for unnecessary `require` statement.'
Expand Down
8 changes: 7 additions & 1 deletion docs/modules/ROOT/pages/cops_lint.adoc
Expand Up @@ -4000,7 +4000,7 @@ NOTE: Required Ruby version: 3.0
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Yes
| No
| Yes
| 1.8
| -
Expand All @@ -4009,6 +4009,12 @@ NOTE: Required Ruby version: 3.0
Sort globbed results by default in Ruby 3.0.
This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`.

=== Safety

This cop is unsafe, in case of having a file and a directory with
identical names, since directory will be loaded before the file, which
will break `exe/files.rb` that rely on `exe.rb` file.

=== Examples

[source,ruby]
Expand Down
5 changes: 5 additions & 0 deletions lib/rubocop/cop/lint/redundant_dir_glob_sort.rb
Expand Up @@ -6,6 +6,11 @@ module Lint
# Sort globbed results by default in Ruby 3.0.
# This cop checks for redundant `sort` method to `Dir.glob` and `Dir[]`.
#
# @safety
# This cop is unsafe, in case of having a file and a directory with
# identical names, since directory will be loaded before the file, which
# will break `exe/files.rb` that rely on `exe.rb` file.
#
# @example
#
# # bad
Expand Down

0 comments on commit 857e682

Please sign in to comment.