Class: JRuby::Lint::Checkers::ThreadCritical

Inherits:
Object
  • Object
show all
Includes:
JRuby::Lint::Checker
Defined in:
lib/jruby/lint/checkers/thread_critical.rb

Constant Summary collapse

METHODS =
%w(critical critical=)

Instance Attribute Summary

Attributes included from JRuby::Lint::Checker

#collector

Instance Method Summary collapse

Methods included from JRuby::Lint::Checker

included, loaded_checkers

Instance Method Details

#add_finding(collector, node) ⇒ Object



20
21
22
23
# File 'lib/jruby/lint/checkers/thread_critical.rb', line 20

def add_finding(collector, node)
  collector.findings << Finding.new("Use of Thread.critical is discouraged. Use a Mutex instead.",
                                    [:threads, :warning], node.position)
end

#visitCallNode(node) ⇒ Object Also known as: visitAttrAssignNode



8
9
10
11
12
13
14
15
16
17
# File 'lib/jruby/lint/checkers/thread_critical.rb', line 8

def visitCallNode(node)
  if METHODS.include?(node.name)
    begin
      if node.receiver_node.node_type.to_s == "CONSTNODE" && node.receiver_node.name == "Thread"
        add_finding(collector, node)
      end
    rescue
    end
  end
end