@vibedrift/cli 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +41 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4318,35 +4318,47 @@ var complexityAnalyzer = {
|
|
|
4318
4318
|
const fns = file.tree ? extractFunctions(file.tree.rootNode, file.relativePath, file.language) : extractFunctionsRegex(file.content, file.relativePath);
|
|
4319
4319
|
allFunctions.push(...fns);
|
|
4320
4320
|
}
|
|
4321
|
-
const
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
})
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4321
|
+
for (const fn of allFunctions) {
|
|
4322
|
+
if (fn.complexity > 20) {
|
|
4323
|
+
findings.push({
|
|
4324
|
+
analyzerId: "complexity",
|
|
4325
|
+
severity: "error",
|
|
4326
|
+
confidence: 0.9,
|
|
4327
|
+
message: `Function "${fn.name}" has cyclomatic complexity ${fn.complexity} (threshold: 20)`,
|
|
4328
|
+
locations: [{
|
|
4329
|
+
file: fn.file,
|
|
4330
|
+
line: fn.line,
|
|
4331
|
+
snippet: `${fn.name}() \u2014 ${fn.lineCount} lines, complexity ${fn.complexity}`
|
|
4332
|
+
}],
|
|
4333
|
+
tags: ["complexity", "critical"]
|
|
4334
|
+
});
|
|
4335
|
+
} else if (fn.complexity > 15) {
|
|
4336
|
+
findings.push({
|
|
4337
|
+
analyzerId: "complexity",
|
|
4338
|
+
severity: "warning",
|
|
4339
|
+
confidence: 0.75,
|
|
4340
|
+
message: `Function "${fn.name}" has cyclomatic complexity ${fn.complexity} (threshold: 15)`,
|
|
4341
|
+
locations: [{
|
|
4342
|
+
file: fn.file,
|
|
4343
|
+
line: fn.line,
|
|
4344
|
+
snippet: `${fn.name}() \u2014 ${fn.lineCount} lines, complexity ${fn.complexity}`
|
|
4345
|
+
}],
|
|
4346
|
+
tags: ["complexity", "high"]
|
|
4347
|
+
});
|
|
4348
|
+
} else if (fn.complexity > 10) {
|
|
4349
|
+
findings.push({
|
|
4350
|
+
analyzerId: "complexity",
|
|
4351
|
+
severity: "info",
|
|
4352
|
+
confidence: 0.5,
|
|
4353
|
+
message: `Function "${fn.name}" has cyclomatic complexity ${fn.complexity} (threshold: 10)`,
|
|
4354
|
+
locations: [{
|
|
4355
|
+
file: fn.file,
|
|
4356
|
+
line: fn.line,
|
|
4357
|
+
snippet: `${fn.name}() \u2014 ${fn.lineCount} lines, complexity ${fn.complexity}`
|
|
4358
|
+
}],
|
|
4359
|
+
tags: ["complexity", "moderate"]
|
|
4360
|
+
});
|
|
4361
|
+
}
|
|
4350
4362
|
}
|
|
4351
4363
|
if (allFunctions.length > 0) {
|
|
4352
4364
|
const avgComplexity = allFunctions.reduce((s, f) => s + f.complexity, 0) / allFunctions.length;
|