Skip to content

feat: add --skip-var-renames quick check - #41

Merged
longvo92 merged 1 commit into
mainfrom
dev/skip-variable-rename-flag-4bdb90
Sep 11, 2026
Merged

longvo92 merged 1 commit into
mainfrom
dev/skip-variable-rename-flag-4bdb90

Conversation

@longvo92

Copy link
Copy Markdown
Owner

What

A new opt-in flag, --skip-var-renames, for sweeping a regenerate to find what is not a rename.

When a model update renames a wave of variables, the renames bury everything else. With this flag on, a C/C++ hunk whose every line is a binding differing only by variable names is folded as assumed-rename instead of real.

A binding is one statement that names an object and at most copies a single other object or literal into it. Either side may be a plain lvalue path, which is how Embedded Coder reaches its ports and state:

a = b;                     →  x = b;
acc_cmd = rtU.Pedal;       →  drv_cmd = rtU.Pedal;
rtY.Out = filt_in;         →  rtY.Out = filt_val;
buf[2] = rtDW->State;      →  buf[2] = rtDW->Level;
real_T filt_in;            →  real_T filt_val;
boolean_T flag = FALSE;    →  boolean_T other = FALSE;

Why this one is different

Every other rule in the engine proves the difference is noise before folding it. This one does not, and the repo rule says so: if a difference cannot be proven to be noise, it is a real change. A rewiring has exactly the same shape as a rename, so a run using this flag can be missing a real change.

That trade is the point of the flag, so it is contained rather than hidden:

  • off by default, and it has to be asked for by name;
  • what it folds keeps its own kind, assumed-rename — never spelled rename on any surface;
  • the terminal summary prints a QUICK CHECK warning above the counts;
  • the HTML report carries a one-line note between the folder tree and the diffs;
  • the JSON output carries "quick_check": "skip-var-renames";
  • the viewer title bar says QUICK CHECK: variable renames skipped.

What still counts as a real change, even with the flag on

  • a changed literal — a = 0; → x = 1;
  • a changed type — sint32 a = 0; → uint8 x = 0;
  • an ALL_CAPS macro or enum constant on either side — flag = FALSE; → flag = TRUE;, mode = IDLE; → mode = DRIVE;
  • a variable swap (a ↔ b), however consistent it looks
  • any hunk holding one line that is not a binding — an expression, a call, a cast, an address-of, a prototype. One such line leaves the whole hunk real.

Verdicts, counts, exit codes and the ARXML/A2L path are untouched when the flag is absent.

Also in here

Report file headers now carry only the verdict badge. The Affected: <fn> hint and the noise-kind list are gone — a header answers "must I read this file", and the badge is that answer. The enclosing function is still captioned above each hunk (ƒ Calc_step), and a revealed noise group's placeholder row still names its kind.

Testing

tests/test_skip_var_renames.py (35 tests) covers the binding grammar, the map, the fold, every "still real" case above, and the four announcement surfaces.

python -m unittest discover -s tests    # 791 passed
python -m ruff check .                  # clean

🤖 Generated with Claude Code

Fold C/C++ hunks that are only bindings differing by variable names,
labelled `assumed-rename` instead of `real`. Unlike every other rule in
the engine this one does not prove the difference is noise -- a rewiring
has the same shape -- so it is opt-in, off by default, and announced in
the terminal summary, the report, the JSON and the viewer title.

A binding is one statement that names an object and at most copies a
single other object or literal into it; either side may be a plain
lvalue path (a.b, p->q, buf[2]), and a bare declaration counts. Still
real: a changed literal or type, an ALL_CAPS macro/enum swap, a variable
swap, and any hunk holding a line that is not a binding.

Also drop the extra hint from report file headers: the header answers
"must I read this file", and the verdict badge is that answer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@longvo92
longvo92 merged commit a60a4c6 into main Sep 11, 2026
6 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