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 cop ChefModernize/ConditionalUsingTest #666

Merged
merged 4 commits into from
Jul 9, 2020
Merged

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Jul 9, 2020

Avoid shelling out when we can just use Ruby which is going to be faster.

Fixes #543

Signed-off-by: Tim Smith tsmith@chef.io

Avoid shelling out when we can just use Ruby which is going to be faster.

Signed-off-by: Tim Smith <tsmith@chef.io>
@tas50 tas50 requested review from a team as code owners July 9, 2020 04:41
not_if { ::File.exist?('/sbin/apt') }
end
RUBY
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I could see this being a tiny bit confusing if the user uses test -e and this suggests not using test -f.

Also this is the nitpickiest of nitpicks, but someone could want the behavior of -f that does more than test for existence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah -f is a bit different than File.exist?, but looking at how users were using it throughout supermarket cookbooks they were just looking for File.exist? functionality. Someone out there isn't going to like this and for that user they can disable it inline or entirely in a .rubocop.yml. For most people, I think it gives the appropriate direction.

tas50 and others added 3 commits July 9, 2020 10:43
Signed-off-by: Tim Smith <tsmith@chef.io>

Co-authored-by: pete higgins <pete@peterhiggins.org>
Signed-off-by: Tim Smith <tsmith@chef.io>

Co-authored-by: pete higgins <pete@peterhiggins.org>
Signed-off-by: Tim Smith <tsmith@chef.io>

Co-authored-by: pete higgins <pete@peterhiggins.org>
@tas50 tas50 merged commit b9544f2 into master Jul 9, 2020
@chef-expeditor chef-expeditor bot deleted the conditional_test branch July 9, 2020 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't use 'test -f XYZ' in a only_if / not_if
2 participants