Skip to content

Style/ExpandPathArguments-20230517233328#206

Open
github-actions[bot] wants to merge 3 commits intomasterfrom
rubocop-challenge/20230517233328
Open

Style/ExpandPathArguments-20230517233328#206
github-actions[bot] wants to merge 3 commits intomasterfrom
rubocop-challenge/20230517233328

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Rubocop challenge!

Style/ExpandPathArguments

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Checks for use of the File.expand_path arguments.
Likewise, it also checks for the Pathname.new argument.

Contrastive bad case and good case are alternately shown in
the following examples.

Examples

# bad
File.expand_path('..', __FILE__)

# good
File.expand_path(__dir__)

# bad
File.expand_path('../..', __FILE__)

# good
File.expand_path('..', __dir__)

# bad
File.expand_path('.', __FILE__)

# good
File.expand_path(__FILE__)

# bad
Pathname(__FILE__).parent.expand_path

# good
Pathname(__dir__).expand_path

# bad
Pathname.new(__FILE__).parent.expand_path

# good
Pathname.new(__dir__).expand_path

Auto generated by rubocop_challenger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

0 participants