Conversation
|
Looks useful! With that said, automated renaming risks
I'd rather run this on a few modules at a time, starting with modules that have not been updated recently, to be able to review everything manually. |
Python tool (dev/check_param_names.py) that compares function parameter names across header declarations, RST documentation, and .c source definitions. Supports auto-fixing mismatches with --fix and --dry-run. Includes 86 unit tests (dev/test_check_param_names.py).
d318f3d to
a9e26d8
Compare
When two parameters have their names exchanged between header and source (e.g. header has val,len but source has len,val), the tool now prints a WARNING flagging a possible bug. This catches cases like _padic_poly_fprint_pretty where the header and source disagree on parameter order.
|
Sounds good, I'll submit fixes a few modules at a time for manual review and to keep improving the script. Here's the full list grouped by review effort, with the first batch already up in #2604: Batch 1 (done, #2604)
Batch 2: trivial modules (1-3 functions each, ~50 params total)
Batch 3: small modules (4-10 functions each, ~165 params total)
Batch 4: medium modules (11-25 functions each, ~530 params total)
Batch 5: large modules (26+ functions each, ~2470 params total)
|
|
I might need to think a bit more about the next batches. They look horrendous to review. Maybe an interim approach is to have this merged and get CI to check the modules that we declare "done". What do you think? I would also take suggestions how to make this less painful to review. As we saw from the last one #2604, it took a couple of iterations between @fredrik-johansson and me to get it right, mostly the blame is on me. |
That's an option.
If you want, we could schedule a session where I review the whole PR and we discuss the issues to fix in real time. |
This is a follow-up to #1895 and the manual fixes in #2601. It adds
dev/check_param_names.py, a tool that compares function parameter names across headers (.h), documentation (.rst), and source files (.c) to catch mismatches.The tool treats the header as the source of truth and can auto-fix docs and sources to match. It currently finds 1758 functions with mismatches across 97 modules, totalling 3288 individual parameter name differences. Of these, 2573 can be auto-fixed; 21 are skipped due to local variable name collisions.
Example:
fmpzimoduleWith
--fix --dry-run, the tool shows what it would change and what it must skip:Scope of auto-fixable changes per module
How to proceed?
This tool is ready to auto-fix ~2500 parameter name mismatches across the codebase. However, given the scale, I'd like your input on how to proceed:
arb_*, allfmpz_*, etc.)?The remaining ~21 skipped cases (local variable collisions) would need separate manual fixes regardless of approach.
Usage
Test plan
python3 dev/test_check_param_names.py)