uilint-eslint 0.2.92 → 0.2.94
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
CHANGED
|
@@ -4267,6 +4267,20 @@ function cosineSimilarity(a, b) {
|
|
|
4267
4267
|
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
4268
4268
|
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
4269
4269
|
}
|
|
4270
|
+
function extractCodeFromFile(filePath, startLine, endLine) {
|
|
4271
|
+
try {
|
|
4272
|
+
if (!existsSync6(filePath)) {
|
|
4273
|
+
return null;
|
|
4274
|
+
}
|
|
4275
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
4276
|
+
const lines = content.split("\n");
|
|
4277
|
+
const start = Math.max(0, startLine - 1);
|
|
4278
|
+
const end = Math.min(lines.length, endLine);
|
|
4279
|
+
return lines.slice(start, end).join("\n");
|
|
4280
|
+
} catch {
|
|
4281
|
+
return null;
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4270
4284
|
function findSimilarChunks(index, chunkId, threshold) {
|
|
4271
4285
|
log(`findSimilarChunks: chunkId=${chunkId}, threshold=${threshold}`);
|
|
4272
4286
|
const vector = index.vectorStore.get(chunkId);
|
|
@@ -4400,6 +4414,16 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4400
4414
|
reportedChunks.add(chunkId);
|
|
4401
4415
|
const relPath = relative3(projectRoot, bestMeta.filePath);
|
|
4402
4416
|
const similarity = Math.round(best.score * 100);
|
|
4417
|
+
const sourceCode = extractCodeFromFile(
|
|
4418
|
+
filename,
|
|
4419
|
+
meta17.startLine,
|
|
4420
|
+
meta17.endLine
|
|
4421
|
+
);
|
|
4422
|
+
const targetCode = extractCodeFromFile(
|
|
4423
|
+
bestMeta.filePath,
|
|
4424
|
+
bestMeta.startLine,
|
|
4425
|
+
bestMeta.endLine
|
|
4426
|
+
);
|
|
4403
4427
|
log(` REPORTING: ${meta17.kind} '${name || meta17.name}' is ${similarity}% similar to '${bestMeta.name}' at ${relPath}:${bestMeta.startLine}`);
|
|
4404
4428
|
context.report({
|
|
4405
4429
|
node,
|
|
@@ -4413,7 +4437,27 @@ var no_semantic_duplicates_default = createRule({
|
|
|
4413
4437
|
name: name || meta17.name || "(anonymous)",
|
|
4414
4438
|
similarity: String(similarity),
|
|
4415
4439
|
otherName: bestMeta.name || "(anonymous)",
|
|
4416
|
-
otherLocation: `${relPath}:${bestMeta.startLine}
|
|
4440
|
+
otherLocation: `${relPath}:${bestMeta.startLine}`,
|
|
4441
|
+
// Extended data for inspector panel
|
|
4442
|
+
sourceCode: sourceCode || "",
|
|
4443
|
+
targetCode: targetCode || "",
|
|
4444
|
+
sourceLocation: JSON.stringify({
|
|
4445
|
+
filePath: filename,
|
|
4446
|
+
startLine: meta17.startLine,
|
|
4447
|
+
endLine: meta17.endLine,
|
|
4448
|
+
startColumn: meta17.startColumn,
|
|
4449
|
+
endColumn: meta17.endColumn
|
|
4450
|
+
}),
|
|
4451
|
+
targetLocation: JSON.stringify({
|
|
4452
|
+
filePath: bestMeta.filePath,
|
|
4453
|
+
startLine: bestMeta.startLine,
|
|
4454
|
+
endLine: bestMeta.endLine,
|
|
4455
|
+
startColumn: bestMeta.startColumn,
|
|
4456
|
+
endColumn: bestMeta.endColumn
|
|
4457
|
+
}),
|
|
4458
|
+
sourceName: name || meta17.name || "(anonymous)",
|
|
4459
|
+
targetName: bestMeta.name || "(anonymous)",
|
|
4460
|
+
similarityScore: String(best.score)
|
|
4417
4461
|
}
|
|
4418
4462
|
});
|
|
4419
4463
|
}
|