refactor: drop default arguments from virtual functions (google-default-arguments)#1488
Conversation
…lt-arguments) Closes the loop on the deferred clang-tidy finding from #1487: defaults on virtual / override methods are a Google-style anti-pattern because the default value depends on which static type the call goes through. Calling `pass_base_ptr->Move(a, b)` would use the base-class default; calling `pass_derived_ptr->Move(a, b)` would be a compile error if the override didn't redeclare it. The defaults silently make the value depend on whether the caller has narrowed the pointer type. QtPass's Pass interface had this on Move, Copy, Grep, and the 6-arg executeWrapper, with the defaults duplicated on the ImitatePass/RealPass overrides. Removed from both sides; callers now pass `false` (or `true,true` for executeWrapper readStdout/readStderr) explicitly. Production callsites updated: - src/storemodel.cpp: 4× Move/Copy in handleDirDrop / handleFileToDirDrop — all rely on the force=false default for normal drag-drop semantics. - src/mainwindow.cpp: 2× Move in renameFolder() / renamePassword() — same. - src/pass.cpp: GenerateGPGKeys's executeWrapper call had relied on readStdout=true, readStderr=true defaults. Test callsites updated (3 files): - tests/auto/util/tst_util.cpp: 2× Grep("anything"/"[invalid"). - tests/auto/integration/tst_integration.cpp: 3× Grep("token"/"url"), plus Move/Copy. Plus .clang-tidy: enable google-default-arguments now that the codebase is clean. Build clean, 124/124 tst_util pass, 20/20 tst_integration pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR removes default argument values from several Pass interface methods and updates all call sites to explicitly pass these arguments. The change enables the ChangesDefault argument removal
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Closes the loop on the deferred clang-tidy finding from #1487. Defaults on `virtual` / `override` methods are a Google-style anti-pattern because the default value depends on which static type the call goes through:
```cpp
// Base virtual with default
virtual void Move(QString src, QString dest, bool force = false) = 0;
// Override redeclares the default (or it would be a compile error)
void Move(QString src, QString dest, bool force = false) override;
Pass *base = new RealPass();
base->Move(a, b); // uses BASE default
realpass_ptr->Move(a, b); // uses RealPass default — may differ
```
If subclasses ever drift, the default value silently differs by pointer type. Remove the trap.
Changes
`src/pass.h` — remove defaults from 4 base virtuals:
`src/imitatepass.h` / `src/realpass.h` — strip the duplicated `= false` from every override declaration (`Insert`, `Remove`, `Move`, `Copy`, `Grep`, plus `executeWrapper` for ImitatePass).
Callers updated to pass values explicitly:
`.clang-tidy` — add `google-default-arguments` now that the codebase is clean. Locks the status quo in.
Test plan
Note
This is a refactor with semantic-preservation guarantees: every explicit `false` / `true, true` matches the previous implicit default exactly. No behavioural change.
🤖 Generated with Claude Code
Summary by CodeRabbit