(node: any)
| 526 | } |
| 527 | |
| 528 | function 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 | |
| 547 | function getPythonDocstring(node: any): string | null { |
| 548 | // Python docstring is the first expression statement if it's a string |
no test coverage detected