J08nY / pyecsca

Unguarded next inside generator PTC-W0063
Bug risk
Critical
5 months ago5 months old
Call to next() should be wrapped in try-except
309
310
311def reconnect_fliparoo_outputs(graph: FormulaGraph, last_node: Node):
312    dummy = next(filter(lambda x: isinstance(x, DummyNode), graph.nodes))313    dummy.reconnect_outgoing_nodes(last_node)
314    graph.remove_node(dummy)
315    if any(map(lambda x: isinstance(x, DummyNode), graph.nodes)):
Call to next() should be wrapped in try-except
100        node.op = change_operator(node.op, OpType.Add)
101        return []
102    if node.is_pow:
103        exponent = next(104            filter(lambda n: isinstance(n, ConstantNode), node.incoming_nodes)
105        )
106        if exponent.value % 2 == 0:
Call to next() should be wrapped in try-except
289    const_par = next(filter(lambda x: isinstance(x, ConstantNode), node.incoming_nodes))
290    const_par_value = const_par.value
291
292    par = next(filter(lambda x: not isinstance(x, ConstantNode), node.incoming_nodes))293    i, ic, ip = (
294        original_graph.node_index(node),
295        original_graph.node_index(const_par),
Call to next() should be wrapped in try-except
198        graph = deepcopy(graph)
199        node = graph.nodes[i]
200
201    const_par = next(filter(lambda x: isinstance(x, ConstantNode), node.incoming_nodes))202    par = next(filter(lambda x: not isinstance(x, ConstantNode), node.incoming_nodes))
203    initial_node = CodeOpNode.from_str(node.result, par.result, OpType.Add, par.result)
204    graph.add_node(initial_node)
Call to next() should be wrapped in try-except
138        fliparoo = fliparoo.deepcopy()
139
140    first, last = fliparoo.first, fliparoo.last
141    inode = next(142        filter(lambda x: not isinstance(x, ConstantNode), first.incoming_nodes)
143    )
144    const_nodes: List[ConstantNode] = [