Skip to content

fix(benchmarks): match CRLF code fences in loc.js#340

Open
Lakshya77089 wants to merge 1 commit into
DietrichGebert:mainfrom
Lakshya77089:fix-loc-crlf
Open

fix(benchmarks): match CRLF code fences in loc.js#340
Lakshya77089 wants to merge 1 commit into
DietrichGebert:mainfrom
Lakshya77089:fix-loc-crlf

Conversation

@Lakshya77089

Copy link
Copy Markdown
Contributor

Fixes #339.

loc.js extracts code blocks with /```[a-zA-Z0-9_+-]* ([\s\S]*?)```/g — no ? before the , so a CRLF fence (```js) never matches. With no block found it falls back to counting the entire response, prose and fence lines included.

correctness.js already handles this with ?, so on CRLF input the LOC metric and the correctness gate disagree. This aligns loc.js with it.

Before:

loc(lf)              -> 2   (correct)
loc(lf as CRLF)      -> 6   (counts prose + fences)

After: both score 2.

Added a CRLF case to benchmarks/loc.test.js (now 6/6). LF input is unaffected; one-token regex change.

The fenced-block regex had no \r? before \n, so CRLF output ( ```js\r\n )
matched no block and the metric fell back to counting the whole response,
prose and fences included. correctness.js already handles \r?\n; align loc.js
with it and add a CRLF regression case.

Fixes DietrichGebert#339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

benchmarks: loc.js misses CRLF code fences and counts the whole response

1 participant