Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(health): count Pascal for-in loops, add a performance dialect - #2233

Open
Laex wants to merge 9 commits into
repowise-dev:mainfrom
Laex:fix/pascal-foreach-loop-and-perf-dialect
Open

fix(health): count Pascal for-in loops, add a performance dialect#2233
Laex wants to merge 9 commits into
repowise-dev:mainfrom
Laex:fix/pascal-foreach-loop-and-perf-dialect

Conversation

@Laex

@Laex Laex commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pascal's for x in collection do parses as its own foreach grammar node, distinct from the counted for -- and it was missing from loop_kinds, so the complexity walker skipped it entirely. Any Pascal function using a for-in loop understated both CCN and nesting depth. Confirmed against a real ~150-file Delphi codebase: 70 occurrences in one module alone.
  • Registers a Pascal PerfDialect (io_in_loop / hot_path_sync_io), closing the other visible gap: the performance pillar was completely silent for Pascal (0.8% LOC coverage on a real Delphi repo's health report, 100% after this change). Scoped to filesystem and subprocess sinks matched by distinctive RTL/VCL/FPC call names (CopyFile, TFileStream.SaveToFile, ShellExecute, CreateProcess, ...). DB and network sinks are deliberately left out: Pascal's uses clause has no import-classification table behind it yet, so there is no evidence to disambiguate Open/Get/Post from an unrelated method of the same name -- precision over recall.
  • Bumps HEALTH_ANALYZER_VERSION to 12 (documented stamp convention) so an existing index re-scores these findings on its next update.
  • Updates docs/CHANGELOG.md (+ the bundled mirror) and docs/layers/LANGUAGE_SUPPORT.md.

Test plan

  • New regression test for the foreach nesting/CCN undercount (test_pascal_foreach_counts_as_a_loop)
  • New Pascal cases in the perf pass corpus (test_perf_io_in_loop.py): bare filesystem call in a loop, attribute-call stream I/O in a loop, process spawn in a loop, and a negative case (Copy the built-in substring function vs. TFile.Copy)
  • test_model_version_coupling.py pin updated to the new stamp
  • Full tests/unit/health/ suite passes (1627 passed, 18 skipped)
  • Validated live against a real ~150-file Delphi codebase: perf coverage 0.8% -> 100%, and genuine io_in_loop hits surfaced (e.g. a retry-delete loop, recursive tree-copy/delete/list operations) with no false positives on the Copy-substring-builtin case

Laex and others added 9 commits August 16, 2026 17:22
…w dialects

Adds a Pascal LanguageNodeMap (branch/loop/case/try/catch/boolean-op/CFG
node kinds, derived from parsing real tree-sitter-pascal ASTs) so Pascal
gets complexity/nesting, clone detection, and CFG-based dataflow markers.
Class-level metrics (LCOM4/god-class) are deliberately left unmapped:
Pascal splits a class into signature-only declarations and separate
top-level qualified-method implementations, so there is no single node
grouping a method's body the way class analysis expects (same posture as
Go). Also fixes name/parameter extraction in ast_utils.py, which assumed
fields Pascal's grammar doesn't use (name nested under a header field,
params field named "args" not "parameters", grouped params like
"A, B, C: Boolean").

Validated against the 150-file MTN2 Delphi codebase via repowise health.
feat(health): register Pascal in complexity, duplication, and dataflow dialects
…lpers

_extract_pascal_heritage carried both the parent-list extraction and the
class-helper's positional "for TFoo" lookup in one function (CCN 14,
nesting 4 -- flagged by repowise health). Splits into _extract_parents and
_extract_helper_extended_types, each a guard-clause loop with its own
narrow job; the orchestrator now just wires them together. Behavior is
unchanged (verified against the existing extends/implements test plus a
new test covering the previously-uncovered class-helper branch).
# Conflicts:
#	packages/core/src/repowise/core/ingestion/extractors/heritage/pascal.py
# Conflicts:
#	docs/layers/LANGUAGE_SUPPORT.md
Pascal's `for x in collection do` parses as its own `foreach` grammar
node, distinct from the counted `for`, and was missing from
`loop_kinds` -- the complexity walker skipped it entirely, so any
Pascal function using a for-in loop understated both CCN and nesting
depth. Confirmed against a ~150-file Delphi codebase: 70 occurrences
in one module alone.

Also registers a Pascal PerfDialect (io_in_loop / hot_path_sync_io),
closing the other visible gap: the performance pillar was completely
silent for Pascal (0.8% LOC coverage on a real Delphi repo, now
100%). Scoped to filesystem and subprocess sinks matched by RTL/VCL/
FPC call name (CopyFile, TFileStream.SaveToFile, ShellExecute, ...);
DB and network sinks are intentionally left out since Pascal's `uses`
clause has no import-classification table behind it yet, so there is
no evidence to disambiguate Open/Get/Post from an unrelated method of
the same name.

Bumps HEALTH_ANALYZER_VERSION to 12 so an existing index re-scores
these findings on its next update, per the documented stamp
convention.
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.

1 participant