@emeryld/manager 1.4.6 → 1.4.7
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.
|
@@ -33,15 +33,14 @@ export function recordDuplicateLines(normalizedLines, filePath, limits, duplicat
|
|
|
33
33
|
const slice = normalizedLines.slice(i, i + minLines);
|
|
34
34
|
if (slice.some((entry) => !entry.normalized))
|
|
35
35
|
continue;
|
|
36
|
-
const key = slice.map((entry) => entry.normalized).join('\n');
|
|
37
|
-
// Require at least one non-empty, non-punctuation-only line to consider this a meaningful duplicate.
|
|
38
|
-
const meaningfulLineCount = slice.filter((entry) => entry.trimmed.length > 0 && !entry.isPunctuationOnly).length;
|
|
39
|
-
if (meaningfulLineCount === 0)
|
|
40
|
-
continue;
|
|
41
36
|
if (slice.some((entry) => entry.isImport))
|
|
42
37
|
continue;
|
|
43
|
-
//
|
|
44
|
-
//
|
|
38
|
+
// Punctuation-only lines should not count as a line for the minDuplicateLines threshold.
|
|
39
|
+
// i.e., we require >= minLines "real" lines (non-empty AND not punctuation-only).
|
|
40
|
+
const realLineCount = slice.filter((entry) => entry.trimmed.length > 0 && !entry.isPunctuationOnly).length;
|
|
41
|
+
if (realLineCount < minLines)
|
|
42
|
+
continue;
|
|
43
|
+
const key = slice.map((entry) => entry.normalized).join('\n');
|
|
45
44
|
const firstNonEmptyIndex = slice.findIndex((entry) => entry.trimmed.length > 0);
|
|
46
45
|
let lastNonEmptyIndex = -1;
|
|
47
46
|
for (let offset = slice.length - 1; offset >= 0; offset -= 1) {
|
|
@@ -56,7 +55,7 @@ export function recordDuplicateLines(normalizedLines, filePath, limits, duplicat
|
|
|
56
55
|
const endLine = i + 1 + lastNonEmptyIndex;
|
|
57
56
|
const { startColumn } = getLineColumnRange(slice[firstNonEmptyIndex].raw);
|
|
58
57
|
const { endColumn } = getLineColumnRange(slice[lastNonEmptyIndex].raw);
|
|
59
|
-
// Keep
|
|
58
|
+
// Keep punctuation-only lines inside the snippet, but keep indentation.
|
|
60
59
|
const snippet = slice
|
|
61
60
|
.slice(firstNonEmptyIndex, lastNonEmptyIndex + 1)
|
|
62
61
|
.map((entry) => trimRightKeepIndent(entry.raw))
|