Class: RuboCop::Cop::Discourse::NoChdir

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/discourse/no_chdir.rb

Overview

Avoid using chdir - it is not thread safe.

Instead, you may be able to use: Discourse::Utils.execute_command(chdir: “test”) do |runner|

runner.exec("pwd")

end

Examples:

# bad
Dir.chdir("test")

Constant Summary collapse

MSG =
"Chdir is not thread safe."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



27
28
29
30
# File 'lib/rubocop/cop/discourse/no_chdir.rb', line 27

def on_send(node)
  return if !(using_dir_chdir?(node) || using_fileutils_cd?(node))
  add_offense(node, message: MSG)
end