🔥 QD-14791 QD-14813 Remove implicit scan injection from CLI dispatch - #962
🔥 QD-14791 QD-14813 Remove implicit scan injection from CLI dispatch#962Anna Zhukova (bindreams) wants to merge 2 commits into
Conversation
Qodana for Go115 new problems were found
@@ Code coverage @@
+ 65% total lines covered
10639 lines analyzed, 6935 lines covered
# Calculated according to the filters of your coverage tool☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bc21cb358
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".
|
This pull request has been automatically marked as stale because it has not had recent activity for 7 days. What happens next?
Thank you for your contribution! 🙏 |
|
This pull request has been automatically closed due to inactivity. Don't worry! You can always:
Thank you for your contribution! 🙏 |
1bc21cb to
f74df16
Compare
Qodana for Go115 new problems were found
@@ Code coverage @@
+ 65% total lines covered
10603 lines analyzed, 6943 lines covered
# Calculated according to the filters of your coverage tool☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
|
This pull request has been automatically marked as stale because it has not had recent activity for 7 days. What happens next?
Thank you for your contribution! 🙏 |
What
Removes the
setDefaultCommandIfNeededlayer ininternal/cmd/root.gothat silently rewroteqodana <args>toqodana scan <args>when args didn't match a hand-rolled list of known invocations. After this PR, cobra's standard subcommand resolution handles every invocation.This is a deliberate, product-approved removal — broader than a narrow patch to QD-14791 alone.
Why
The injection was added in November 2023 to make
qodana -i .work as a shorthand forqodana scan -i .. It has produced a recurring class of UX bugs over 2+ years:qodana completionran scan. Patched narrowly.qodana help completionruns scan. Same root cause as QD-9907; the 2024 patch didn't generalize. This is the bug the PR fixes.qodana pullauto-promoted to scan. Won't-fix.__complete/__completeNoDesc(used by shell completion scripts at every Tab press) were silently misrouted to scan.qodana -i scanwas misread because the oldisCommandRequestedscanned the entire argv for command names.The dispatch layer saved five keystrokes and has cost the team multiple bug reports. Time to retire it.
Tickets
qodana help completionruns scan.Behavior changes (breaking)
qodana help completionqodana <Tab>(shell completion)qodanaqodana -i .-i .-iqodana --linter qodana-jvmqodana scan -i .qodana <known-subcommand> [args]qodana -v/--version/-h/--helpSee QD-14813 for the full table and migration cookbook (TL;DR: anywhere you had
qodana <flags>, writeqodana scan <flags>).Diff
internal/cmd/root.go: −32 lines. DeletesisHelpOrVersion,isCompletionRequested,isCommandRequested,setDefaultCommandIfNeeded, the call site inExecute(), and theslicesimport.Execute()collapses to the warning + update check +rootCommand.Execute().internal/cmd/cmd_test.go: refactor. Deletes the four obsolete helper tests. AddsdispatchTestRoot()test helper and six dispatch tests covering the QD-14791 bug, the QD-9907 prior-art path, cobra's hidden__complete, bare invocation, unknown subcommand, and the latent scan flag-value collision.TDD trail
Two commits, deliberately structured to make TDD visible:
da649ecdaddsTestQD14791HelpCompletionDispatchwith an explicitsetDefaultCommandIfNeeded(...)call that demonstrates the bug. The test fails on this commit (scan runs instead of help dispatch).1bc21cb3deletes the dispatch helpers and the call site. The keystone test loses itssetDefaultCommandIfNeededline (now undefined) and passes against cobra-native dispatch. Adds five additional post-removal dispatch tests.CI on commit 1 in isolation would surface the failing test (the regression the fix addresses). CI on the branch HEAD (commit 2) is green.
Test plan
go test ./internal/cmd/...— all tests pass.