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
|
||||
lizard:
|
||||
enabled: true
|
||||
config:
|
||||
thresholds:
|
||||
cyclomatic_complexity: 10
|
||||
lines_of_code: 50
|
||||
arguments: 4
|
||||
pmd7:
|
||||
enabled: true
|
||||
|
||||
# CSS & Web Standards
|
||||
stylelint:
|
||||
enabled: true
|
||||
config:
|
||||
rules:
|
||||
function-allowed-list: ["url", "var", "filter", "invert"]
|
||||
|
||||
# Documentation & Config
|
||||
markdownlint:
|
||||
|
||||
+13
-7
@@ -60,14 +60,20 @@ function getCallerName(stack?: string): string {
|
||||
return 'unknown function';
|
||||
}
|
||||
|
||||
// Filter out empty lines and the logMessage itself to find the true caller
|
||||
const caller = stack
|
||||
.split('\n')
|
||||
.filter(Boolean)
|
||||
.map(parseStackLine)
|
||||
.find((name) => name !== null && name !== 'logMessage');
|
||||
const lines = stack.split('\n');
|
||||
|
||||
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