MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / countLoc

Function countLoc

Support/SingleFileLibs/javascript/app.js:265–281  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

263 }
264
265 function countLoc(content) {
266 let code = 0, comments = 0, inBlock = false;
267 const lines = content.split(/\r?\n/);
268 for (const line of lines) {
269 const s = line.trim();
270 if (!s) continue;
271 if (inBlock) {
272 comments++;
273 if (s.includes('*/')) inBlock = false;
274 continue;
275 }
276 if (s.startsWith('//')) { comments++; continue; }
277 if (s.startsWith('/*')) { comments++; if (!s.includes('*/')) inBlock = true; continue; }
278 code++;
279 }
280 return { code, comments };
281 }
282
283 async function fetchFileCached(ref, path) {
284 const key = `${ref}:${path}`;

Callers

nothing calls this directly

Calls 2

trimMethod · 0.80
startsWithMethod · 0.80

Tested by

no test coverage detected