• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nshkrdotcom / ElixirScope / c7479091597c3382f92c87a4fd0395db3ee30193

30 May 2025 03:48PM UTC coverage: 57.42% (-0.3%) from 57.672%
c7479091597c3382f92c87a4fd0395db3ee30193

push

github

NSHkr
refactor expression_processors

98 of 221 new or added lines in 6 files covered. (44.34%)

28 existing lines in 2 files now uncovered.

6210 of 10815 relevant lines covered (57.42%)

3137.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/lib/elixir_scope/ast_repository/enhanced/cfg_generator/expression_processors/function_processors.ex
1
defmodule ElixirScope.ASTRepository.Enhanced.CFGGenerator.ExpressionProcessors.FunctionProcessors do
2
  @moduledoc """
3
  Processors for function calls, guards, and anonymous functions.
4
  """
5

6
  alias ElixirScope.ASTRepository.Enhanced.CFGNode
7

8
  # Get dependencies from application config for testability
9
  defp state_manager do
10
    Application.get_env(:elixir_scope, :state_manager,
2,822✔
11
      ElixirScope.ASTRepository.Enhanced.CFGGenerator.StateManager)
12
  end
13

14
  defp ast_utilities do
15
    Application.get_env(:elixir_scope, :ast_utilities,
5,644✔
16
      ElixirScope.ASTRepository.Enhanced.CFGGenerator.ASTUtilities)
17
  end
18

19
  @doc """
20
  Processes a function call.
21
  """
22
  def process_function_call(func_name, args, meta, state) do
23
    line = ast_utilities().get_line_number(meta)
1,406✔
24

25
    # Check if this is a guard function
26
    node_type = if func_name in [:is_map, :is_list, :is_atom, :is_binary, :is_integer, :is_float, :is_number, :is_boolean, :is_tuple, :is_pid, :is_reference, :is_function] do
1,406✔
27
      :guard_check
28
    else
29
      :function_call
30
    end
31

32
    {call_id, updated_state} = state_manager().generate_node_id("function_call", state)
1,406✔
33

34
    call_node = %CFGNode{
1,406✔
35
      id: call_id,
36
      type: node_type,
37
      ast_node_id: ast_utilities().get_ast_node_id(meta),
38
      line: line,
39
      scope_id: state.current_scope,
1,406✔
40
      expression: {func_name, meta, args},
41
      predecessors: [],
42
      successors: [],
43
      metadata: %{function: func_name, args: args, is_guard: node_type == :guard_check}
44
    }
45

46
    nodes = %{call_id => call_node}
1,406✔
47
    {nodes, [], [call_id], %{}, updated_state}
1,406✔
48
  end
49

50
  @doc """
51
  Processes a module function call.
52
  """
53
  def process_module_function_call(module, func_name, args, meta1, meta2, state) do
54
    line = ast_utilities().get_line_number(meta2)
1,416✔
55
    {call_id, updated_state} = state_manager().generate_node_id("module_call", state)
1,416✔
56

57
    call_node = %CFGNode{
1,416✔
58
      id: call_id,
59
      type: :function_call,
60
      ast_node_id: ast_utilities().get_ast_node_id(meta2),
61
      line: line,
62
      scope_id: state.current_scope,
1,416✔
63
      expression: {{:., meta1, [module, func_name]}, meta2, args},
64
      predecessors: [],
65
      successors: [],
66
      metadata: %{module: module, function: func_name, args: args}
67
    }
68

69
    nodes = %{call_id => call_node}
1,416✔
70
    {nodes, [], [call_id], %{}, updated_state}
1,416✔
71
  end
72

73
  @doc """
74
  Processes a when guard expression.
75
  """
76
  def process_when_guard(expr, guard, meta, state) do
NEW
77
    line = ast_utilities().get_line_number(meta)
×
NEW
78
    {guard_id, updated_state} = state_manager().generate_node_id("guard", state)
×
79

NEW
80
    guard_node = %CFGNode{
×
81
      id: guard_id,
82
      type: :guard_check,
83
      ast_node_id: ast_utilities().get_ast_node_id(meta),
84
      line: line,
NEW
85
      scope_id: state.current_scope,
×
86
      expression: {:when, meta, [expr, guard]},
87
      predecessors: [],
88
      successors: [],
89
      metadata: %{expression: expr, guard: guard}
90
    }
91

NEW
92
    nodes = %{guard_id => guard_node}
×
NEW
93
    {nodes, [], [guard_id], %{}, updated_state}
×
94
  end
95

96
  @doc """
97
  Processes an anonymous function.
98
  """
99
  def process_anonymous_function(clauses, meta, state) do
NEW
100
    line = ast_utilities().get_line_number(meta)
×
NEW
101
    {fn_id, updated_state} = state_manager().generate_node_id("anonymous_fn", state)
×
102

NEW
103
    fn_node = %CFGNode{
×
104
      id: fn_id,
105
      type: :anonymous_function,
106
      ast_node_id: ast_utilities().get_ast_node_id(meta),
107
      line: line,
NEW
108
      scope_id: state.current_scope,
×
109
      expression: {:fn, meta, clauses},
110
      predecessors: [],
111
      successors: [],
112
      metadata: %{clauses: clauses}
113
    }
114

NEW
115
    nodes = %{fn_id => fn_node}
×
NEW
116
    {nodes, [], [fn_id], %{}, updated_state}
×
117
  end
118
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc