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

Style/ExpandPathArguments-20220907233817 #780

Merged
merged 3 commits into from
Sep 17, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 7, 2022

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

@mathieujobin mathieujobin merged commit 79dca11 into master Sep 17, 2022
@mathieujobin mathieujobin deleted the rubocop-challenge/20220907233817 branch September 17, 2022 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants