Print LOC and SLOC as part of the build process#22
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds source-statistics reporting to build.pas: line-counting and formatting helpers plus a PrintSourceStats procedure, and invokes it during the Build initialization (after PrintVersion) to emit aggregated LOC/SLOC for Pascal-related source files. Changes
Sequence Diagram(s)sequenceDiagram
participant Build as Build()
participant Ver as PrintVersion()
participant Stats as PrintSourceStats()
participant FS as FileSystem
participant Console as Console
Build->>Ver: call PrintVersion
Ver-->>Build: returned
Build->>Stats: call PrintSourceStats
Stats->>FS: enumerate source files (.pas/.dpr/.inc)
FS-->>Stats: file list
loop per file
Stats->>FS: read file contents
FS-->>Stats: file text
Stats->>Stats: StripBlockComments / CountLines
Stats->>Console: aggregate & format numbers
end
Stats-->>Build: done
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@build.pas`:
- Around line 112-126: The parameter AValue in function FormatNumber is not
modified; change its declaration to a const parameter to follow guidelines by
updating the function signature from "function FormatNumber(AValue: Integer):
string;" to use "const AValue: Integer" (keep the body unchanged), ensuring
callers are unaffected while signaling immutability and enabling potential
compiler optimizations.
- Around line 51-106: CountLines currently treats inline or same-line block
comments like '{ ... }' or '(* ... *)' as code; update the per-line handling so
Trimmed is stripped of any inline block comments before deciding SLOC or
toggling InBlock: when not InBlock, scan Trimmed for '{' or '(*' and if a
matching '}' or '*)' exists on the same line remove the entire comment span and
re-evaluate the line (repeat if multiple comments); if an opening '{' or '(*'
has no closing on the same line set InBlock := True and delete from the opening
to end of line (so code before the comment counts); when InBlock is true
continue scanning for closing tokens ('}' or '*)'), remove up through the close,
set InBlock := False, then re-trim and re-evaluate the remaining text for more
comments or code; apply these changes inside CountLines using the existing
variables Trimmed, InBlock, ClosePos, Pos, Delete, Trim, Inc(ASLOC) so
subsequent lines are counted correctly.
Benchmark Results172 benchmarks · 🟢 36 improved · 136 unchanged · avg +4.6% arrays.js — 12 unchanged · avg +1.1%
classes.js — 15 unchanged · avg +4.4%
closures.js — 11 unchanged · avg +2.5%
collections.js — 12 unchanged · avg +2.2%
destructuring.js — 🟢 2 improved, 12 unchanged · avg +3.1%
fibonacci.js — 6 unchanged · avg +3.1%
iterators.js — 🟢 3 improved, 17 unchanged · avg +5.5%
json.js — 🟢 13 improved, 7 unchanged · avg +7.3%
jsx.jsx — 🟢 11 improved, 10 unchanged · avg +7.2%
numbers.js — 11 unchanged · avg +3.1%
objects.js — 🟢 2 improved, 5 unchanged · avg +6.2%
promises.js — 🟢 5 improved, 7 unchanged · avg +6.6%
strings.js — 11 unchanged · avg +2.9%
Measured on ubuntu-latest x64. Changes within ±7% are considered insignificant. |
Summary by CodeRabbit