class RuboCop::Cop::ThreadSafety::DirChdir


end
puts Dir.pwd
Dir.chdir(“/var/run”) do
# bad
@example AllowCallWithBlock: true
end
puts Dir.pwd
Dir.chdir(“/var/run”) do
# good
@example AllowCallWithBlock: false (default)
FileUtils.chdir(“/var/run”)
# bad
Dir.chdir(“/var/run”)
# bad
@example
calling ‘Dir.chdir` with block will be allowed.
If `AllowCallWithBlock` (disabled by default) option is enabled,
Avoid using `Dir.chdir` due to its process-wide effect.

def allow_call_with_block?

def allow_call_with_block?
  !!cop_config['AllowCallWithBlock']
end

def on_send(node)

def on_send(node)
  return unless chdir?(node)
  return if allow_call_with_block? && (node.block_argument? || node.parent&.block_type?)
  add_offense(
    node,
    message: format(
      MESSAGE,
      module: node.receiver.short_name,
      method: node.method_name,
      dot: node.loc.dot.source
    )
  )
end