Skip to content

refactor: replace send/respond_to? and improve remark roundtrip#306

Merged
ronaldtse merged 4 commits into
mainfrom
fix/code-quality-and-remark-roundtrip
May 14, 2026
Merged

refactor: replace send/respond_to? and improve remark roundtrip#306
ronaldtse merged 4 commits into
mainfrom
fix/code-quality-and-remark-roundtrip

Conversation

@ronaldtse
Copy link
Copy Markdown
Contributor

Summary

Code quality and remark formatting improvements:

Code quality

  • Replace all send calls with public_send (respects encapsulation) across remark_attacher, model_visitor, search_engine
  • Replace respond_to? with explicit is_a? type checks for better type safety
  • Add node_has_remarks? helper checking Identifier, RemarkItem, and InterfacedItem

Remark formatting

  • Add format_end_scope_remark to all declaration types (Function, Procedure, Rule, SubtypeConstraint, Entity)
  • Section marker remarks now survive formatting (improved from 2 to 10 remark lines)
  • Remove dead format_scope_remarks method (60 lines of unused recursive code)

Specs

  • Add 10 new regression specs covering: CASE statements, multi-ID parameters, SELECT types, intervals, nested functions, WhereRule remarks
  • Verified WhereRule remark attachment works correctly (was a false alarm in prior TODO analysis)

Test plan

  • bundle exec rspec spec/expressir/ — 1363 examples, 0 failures
  • bundle exec rubocop — no offenses
  • Full roundtrip of syntax.exp structural content passes

ronaldtse added 4 commits May 14, 2026 18:07
Replace all private send calls with public_send across remark_attacher,
model_visitor, and search_engine. Replace respond_to? with explicit
type checks (is_a?) for better type safety and encapsulation.

Files changed:
- remark_attacher: send -> public_send, respond_to? -> node_has_remarks?
- model_visitor: send -> public_send for attribute iteration
- search_engine: send -> public_send for collection access
- expression_builder: respond_to?(:empty?) -> is_a?(Array)
Add format_end_scope_remark to Function, Procedure, Rule,
SubtypeConstraint, and Entity (unconditional) formatters. Previously
only Type emitted these remarks, losing section marker comments
attached to the last child of each declaration group.

Remove dead format_scope_remarks method (60 lines of unused code).
Update formatted fixture files to reflect improved remark output.
Add regression specs for: CASE statements, formal parameters with
multiple IDs, SELECT types, interval in WHERE, nested functions,
WhereRule remark attachment, and shorthand variable declarations.

Verify that tail remarks correctly attach to WhereRule nodes.
@ronaldtse ronaldtse merged commit b71119d into main May 14, 2026
13 checks passed
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