MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / is_else_if

Function is_else_if

atomic-audit/src/extract/languages.rs:328–343  ·  view source on GitHub ↗
(node: Node<'_>)

Source from the content-addressed store, hash-verified

326}
327
328fn is_else_if(node: Node<'_>) -> bool {
329 let mut previous = node.prev_named_sibling();
330 while previous.is_some_and(super::tokens::comment) {
331 previous = previous.and_then(|item| item.prev_named_sibling());
332 }
333 node.kind() == "elif_clause"
334 || (matches!(node.kind(), "if_statement" | "if_expression")
335 && node.parent().is_some_and(|parent| {
336 parent.kind() == "else_clause"
337 || (matches!(parent.kind(), "if_statement" | "if_expression")
338 && previous.is_some_and(|item| item.kind() == "else"))
339 || parent
340 .child_by_field_name("alternative")
341 .is_some_and(|alternative| alternative.id() == node.id())
342 }))
343}
344
345pub(crate) fn control_flow(root: Node<'_>, source: &str, language: Language) -> (u32, u32) {
346 let mut complexity = 1;

Callers 1

control_flowFunction · 0.85

Calls 3

parentMethod · 0.80
kindMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected