mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2026-08-03 20:14:19 +02:00
Refactor stack trace caller extraction
Improve the logic for identifying the true caller from the stack trace by using a loop instead of array methods. This enhances readability and reduces cyclomatic complexity.
This commit is contained in:
@@ -9,20 +9,12 @@ engines:
|
|||||||
# Logic & Quality Metrics
|
# Logic & Quality Metrics
|
||||||
lizard:
|
lizard:
|
||||||
enabled: true
|
enabled: true
|
||||||
config:
|
|
||||||
thresholds:
|
|
||||||
cyclomatic_complexity: 10
|
|
||||||
lines_of_code: 50
|
|
||||||
arguments: 4
|
|
||||||
pmd7:
|
pmd7:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# CSS & Web Standards
|
# CSS & Web Standards
|
||||||
stylelint:
|
stylelint:
|
||||||
enabled: true
|
enabled: true
|
||||||
config:
|
|
||||||
rules:
|
|
||||||
function-allowed-list: ["url", "var", "filter", "invert"]
|
|
||||||
|
|
||||||
# Documentation & Config
|
# Documentation & Config
|
||||||
markdownlint:
|
markdownlint:
|
||||||
|
|||||||
+13
-7
@@ -60,14 +60,20 @@ function getCallerName(stack?: string): string {
|
|||||||
return 'unknown function';
|
return 'unknown function';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out empty lines and the logMessage itself to find the true caller
|
const lines = stack.split('\n');
|
||||||
const caller = stack
|
|
||||||
.split('\n')
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(parseStackLine)
|
|
||||||
.find((name) => name !== null && name !== 'logMessage');
|
|
||||||
|
|
||||||
return caller ?? 'unknown function';
|
for (const line of lines) {
|
||||||
|
if (!line) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = parseStackLine(line);
|
||||||
|
if (name && name !== 'logMessage') {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'unknown function';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user