Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/metricsAnalyzer/languages/csharpAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class CSharpMetricsAnalyzer {
private nesting = 0;
/** Depth of preprocessor block nesting (preproc_if / preproc_else etc.) during traversal */
private preprocessorDepth = 0;

/**
* Caches the { increment, reason } pair computed by the ERROR-node / malformed-declaration
* heuristics, keyed by the node they were computed for. `visit()` always calls
Expand Down
8 changes: 7 additions & 1 deletion src/metricsAnalyzer/languages/pythonAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ export class PythonMetricsAnalyzer {

/** Current nesting level during analysis */
private nesting = 0;
/**
* Bound reference to `getBooleanOperator`, created once per instance instead of as a new
* arrow-function closure on every `isOutermostInSameOperatorChain` call.
*/
private readonly getBooleanOperatorBound = (n: Parser.SyntaxNode): string | null =>
this.getBooleanOperator(n);
/** Current complexity score during analysis */
private complexity = 0;
/** Array of complexity details for the current function being analyzed */
Expand Down Expand Up @@ -297,7 +303,7 @@ export class PythonMetricsAnalyzer {
if (op === "and" || op === "or") {
// Only count the outermost node in a same-operator chain.
// e.g. `a and b and c` has two boolean_operators, but counts once.
if (isOutermostInSameOperatorChain(node, op, "boolean_operator", (n) => this.getBooleanOperator(n))) {
if (isOutermostInSameOperatorChain(node, op, "boolean_operator", this.getBooleanOperatorBound)) {
return 1 + this.nesting;
}
return 0; // inner node of a same-operator chain β€” already counted by parent
Expand Down
Loading