Skip to content

Commit a3516c9

Browse files
talionwarclaude
andcommitted
fix(analyzer): correct off-by-one in line count for POSIX files
Files ending with newline (POSIX standard) produced split('\n') with a trailing empty string, overcounting by 1. Now handles trailing newline correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ae1de0 commit a3516c9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/analyzers/project-analyzer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ function buildGraph(
181181
? 'component'
182182
: 'lib';
183183

184-
const lineCount = file.rawContent.split('\n').length;
184+
const lineCount = file.rawContent.endsWith('\n')
185+
? file.rawContent.split('\n').length - 1
186+
: file.rawContent.split('\n').length;
185187

186188
nodes.set(file.relativePath, {
187189
id: file.relativePath,

0 commit comments

Comments
 (0)