You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow unlink/rm_rf with an existence check as part of a more complex conditional.
Actual behavior
Prevents useful short circuit behaviour.
$ bundle exec rubocop --debug lib/dev/helpers/unix_socket.rb
For /Users/lisaugray/src/github.com/Shopify/dev: configuration from /Users/lisaugray/src/github.com/Shopify/dev/.rubocop.yml
configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-sorbet-0.6.8/config/default.yml
configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-sorbet-0.6.8/config/default.yml
Default configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-1.31.1/config/default.yml
Inheriting configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-shopify-2.7.1/rubocop-cli.yml
Inheriting configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-shopify-2.7.1/rubocop.yml
Inheriting configuration from /Users/lisaugray/src/github.com/Shopify/dev/.rubocop_performance.yml
configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-performance-1.14.2/config/default.yml
configuration from /Users/lisaugray/.gem/ruby/3.1.2/gems/rubocop-performance-1.14.2/config/default.yml
Inheriting configuration from /Users/lisaugray/src/github.com/Shopify/dev/.rubocop.sorbet.yml
Use parallel by default.
Running parallel inspection
Loading cache from /Users/lisaugray/.cache/rubocop_cache/f2fbedb2a77ffd5d8096f1e7d127397d5e9a8518/6d7a3b621ca1730e04accd938619e4bdab66cfb1/38a938a95baf500276c8728c9f8ffc7539831fb5
Inspecting 1 file
Scanning /Users/lisaugray/src/github.com/Shopify/dev/lib/dev/helpers/unix_socket.rb
Loading cache from /Users/lisaugray/.cache/rubocop_cache/f2fbedb2a77ffd5d8096f1e7d127397d5e9a8518/6d7a3b621ca1730e04accd938619e4bdab66cfb1/38a938a95baf500276c8728c9f8ffc7539831fb5
W
Offenses:
lib/dev/helpers/unix_socket.rb:24:33: W: [Correctable] Lint/NonAtomicFileOperation: Remove unnecessary existence checks File.exist?.
FileUtils.rm_rf(path) if File.exist?(path) && File.stat(path).socket?
^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense autocorrectable
Finished in 0.24144500028342009 seconds
The existence check is not unnecessary; it short circuits File.stat which will raise for a missing file.
Expected behavior
Allow
unlink
/rm_rf
with an existence check as part of a more complex conditional.Actual behavior
Prevents useful short circuit behaviour.
The existence check is not unnecessary; it short circuits
File.stat
which will raise for a missing file.Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: