diff --git a/changelog/fix_lintredundantdirglobsort_unset.md b/changelog/fix_lintredundantdirglobsort_unset.md new file mode 100644 index 00000000000..9c85b468755 --- /dev/null +++ b/changelog/fix_lintredundantdirglobsort_unset.md @@ -0,0 +1 @@ +* [#10446](https://github.com/rubocop/rubocop/pull/10446): Lint/RedundantDirGlobSort unset SafeAutoCorrect. ([@friendlyantz][]) diff --git a/config/default.yml b/config/default.yml index 05941e58a6a..772462dcb98 100644 --- a/config/default.yml +++ b/config/default.yml @@ -2013,6 +2013,8 @@ Lint/RedundantDirGlobSort: Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.' Enabled: pending VersionAdded: '1.8' + VersionChanged: '<>' + SafeAutoCorrect: false Lint/RedundantRequireStatement: Description: 'Checks for unnecessary `require` statement.' diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc index 2d6e94a2687..59b5d01ca6a 100644 --- a/docs/modules/ROOT/pages/cops_lint.adoc +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -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 | - @@ -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] diff --git a/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb b/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb index 430880f0539..78c7f881f6e 100644 --- a/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +++ b/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb @@ -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