Sha256: 05de76f846bb831e8b7aa1ce5aa959e81509b495ef29c77d3971874289a8612c
Contents?: true
Size: 853 Bytes
Versions: 10
Compression:
Stored size: 853 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Discourse # 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 # # @example # # bad # Dir.chdir("test") class NoChdir < Base MSG = "Chdir is not thread safe." def_node_matcher :using_dir_chdir?, <<-MATCHER (send (const nil? :Dir) :chdir ...) MATCHER def_node_matcher :using_fileutils_cd?, <<-MATCHER (send (const nil? :FileUtils) :cd ...) MATCHER def on_send(node) return if !(using_dir_chdir?(node) || using_fileutils_cd?(node)) add_offense(node, message: MSG) end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems