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

Add new Lint/RedundantDirGlobSort cop #9301

Merged

Commits on Dec 29, 2020

  1. Add new Lint/RedundantDirGlobSort cop

    Sort globbed results by default in Ruby 3.0.
    https://bugs.ruby-lang.org/issues/8709
    
    This PR adds new `Lint/RedundantDirGlobSort` cop.
    It checks for redundant `sort` method to `Dir.glob` and `Dir[]`.
    
    ```ruby
    # bad
    Dir.glob('./lib/**/*.rb').sort.each do |file|
    end
    
    Dir['./lib/**/*.rb'].sort.each do |file|
    end
    
    # good
    Dir.glob('./lib/**/*.rb').each do |file|
    end
    
    Dir['./lib/**/*.rb'].each do |file|
    end
    
    # good - Respect intent if `sort` keyword option is specified.
    Dir.glob('./lib/**/*.rb', sort: false).each do |file|
    end
    ```
    
    Related PR rubocop#9300.
    koic committed Dec 29, 2020
    Configuration menu
    Copy the full SHA
    adfea8c View commit details
    Browse the repository at this point in the history