29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/bparity/formal/deductive.rb', line 29
def check_file(path, method_name)
result = Prism.parse_file(path)
return ["syntax error"] unless result.success?
method = nodes(result.value).find { |node| node.type == :def_node && node.name.to_s == method_name.to_s }
return ["method #{method_name} was not found"] unless method
nodes(method).filter_map do |node|
if FORBIDDEN_NODES.include?(node.type)
"#{node.type} at line #{node.location.start_line}"
elsif node.type == :call_node && FORBIDDEN_CALLS.include?(node.name)
"#{node.name} at line #{node.location.start_line}"
end
end
end
|