MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / calculateComplexity

Function calculateComplexity

website/src/lib/parser.worker.ts:528–545  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

526}
527
528function calculateComplexity(node: any): number {
529 const complexityNodes = new Set([
530 "if_statement", "for_statement", "while_statement", "except_clause",
531 "with_statement", "boolean_operator", "list_comprehension",
532 "generator_expression", "case_clause", "conditional_expression",
533 "binary_expression" // for logical ops in some langs
534 ]);
535
536 let count = 1;
537 function traverse(n: any) {
538 if (complexityNodes.has(n.type)) count++;
539 for (let i = 0; i < n.childCount; i++) {
540 traverse(n.child(i));
541 }
542 }
543 traverse(node);
544 return count;
545}
546
547function getPythonDocstring(node: any): string | null {
548 // Python docstring is the first expression statement if it's a string

Callers 1

processNextBatchFunction · 0.85

Calls 1

traverseFunction · 0.85

Tested by

no test coverage detected