Skip to content

fix(benchmarks): strip block comments before counting LOC#232

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

fix(benchmarks): strip block comments before counting LOC#232
Lakshya77089 wants to merge 1 commit into
DietrichGebert:mainfrom
Lakshya77089:fix-loc-block-comments

Conversation

@Lakshya77089

Copy link
Copy Markdown
Contributor

Fixes #231.

loc.js filtered comments line by line, so /* ... */ block comments whose continuation lines are not *-aligned had their inner lines counted as code. A plain indented block comment scored higher than the same code written JSDoc-style:

function f() {        function f() {
  /* explain             /*
     the rest */          * explain
  return 1;               */
}                       return 1;
                      }
scores 5                scores 3   <- same code, different count

This strips /* ... */ before the line count so both forms agree, and adds benchmarks/loc.test.js to lock it.

Why it matters: the over-count lands on whichever arm writes more block comments, which is the verbose baseline more often than ponytail, so it nudged the headline "less code" number in ponytail's favor. Small, but worth keeping honest.

Verified:

  • indented and JSDoc block comments now both count 3
  • inline /* */, //, and # line comments still handled
  • plain code is unchanged

node benchmarks/loc.test.js passes (5/5); the main test suite is unaffected.

loc.js filtered comments line by line, so /* ... */ block comments whose
continuation lines are not *-aligned had their inner lines counted as code.
A plain indented block comment scored higher than the same code written
JSDoc-style. Strip /* ... */ before the line count so both are equal, and
add loc.test.js to lock the behavior.

Fixes DietrichGebert#231
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 counts plain block-comment lines as code, inflating the LOC metric

2 participants