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 Style/FileDirnameLevel cop #10419

Merged

Commits on Mar 9, 2022

  1. Add new Style/NestedFileDirname cop

    ## Summary
    
    This cop checks for nested `File.dirname`.
    It replaces nested `File.dirname` with the level argument introduced in Ruby 3.1.
    
    ```ruby
    # bad
    File.dirname(File.dirname(path))
    
    # good
    File.dirname(path, 2)
    ```
    
    See: https://bugs.ruby-lang.org/issues/12194
    
    ## Other Information
    
    For `File.expand_path('../..', path)`, there is a partial conflict with `Style/ExpandPathArguments` cop.
    So this PR does not support it.
    https://docs.rubocop.org/rubocop/1.25/cops_style.html#styleexpandpatharguments
    koic committed Mar 9, 2022
    Copy the full SHA
    a975c1b View commit details
    Browse the repository at this point in the history