Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Lint/RedundantDirGlobSort unset SafeAutoCorrect #10446

Merged
merged 1 commit into from Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you insert VersionChanged: '<<next>>'?

Suggested change
VersionAdded: '1.8'
VersionAdded: '1.8'
VersionChanged: '<<next>>'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thank you

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