Class: JRuby::Lint::Checkers::ForkExec

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

Instance Attribute Summary

Attributes included from JRuby::Lint::Checker

#collector

Instance Method Summary collapse

Methods included from JRuby::Lint::Checker

#grand_parent, included, loaded_checkers, #parent, #src_line

Instance Method Details

#add_finding(node) ⇒ Object



27
28
29
# File 'lib/jruby/lint/checkers/fork_exec.rb', line 27

def add_finding(node)
  collector.add_finding('Kernel#fork is not implemented on JRuby.', [:fork, :error], node.line+1)
end

#fork?(node) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jruby/lint/checkers/fork_exec.rb', line 23

def fork?(node)
  node.name == :fork
end

#visitCallNode(node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/jruby/lint/checkers/fork_exec.rb', line 4

def visitCallNode(node)
  if fork?(node)
    @call_node = node
    child = node.child_nodes.first
    if child && %w(COLON3NODE CONSTNODE).include?(child.node_type.to_s) && child.name == :Kernel
      add_finding(node)
    end
    proc { @call_node = nil }
  end
end

#visitFCallNode(node) ⇒ Object



15
16
17
# File 'lib/jruby/lint/checkers/fork_exec.rb', line 15

def visitFCallNode(node)
  add_finding node if fork?(node)
end

#visitVCallNode(node) ⇒ Object



19
20
21
# File 'lib/jruby/lint/checkers/fork_exec.rb', line 19

def visitVCallNode(node)
  add_finding node if fork?(node) && !@call_node
end