Uh oh!
There was an error while loading. Please reload this page.
refactor: reduce complexity of main() dispatch in src/main.rs - #1960
Draft
github-actions[bot] wants to merge 1 commit into
Draft
refactor: reduce complexity of main() dispatch in src/main.rs#1960github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Reduce cognitive complexity of main() by extracting the Commands::Execute, Commands::Secrets, and Commands::Graph match arms into standalone async helper functions (dispatch_execute, dispatch_secrets, dispatch_graph_command). The top-level match in main() is now a flat one-arm-per-command dispatch table instead of embedding nested matches and branching logic inline. No public API or behavior changes; all existing tests pass and clippy is clean. Before: main() flagged by clippy::too_many_lines at 496/100 lines. After: main() reduced to 351/100 lines (still flagged, further reduction left for a future pass). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was complex
main()insrc/main.rswas flagged byclippy::too_many_linesat 496/100 lines. It contained a large top-levelmatchoverCommandswith several arms embedding substantial nested logic inline:Commands::Execute { .. }— anif/elsedeciding between--prepare-custom-agent-outputvalidation/materialization and normal Stage 3 safe-output execution.Commands::Secrets { action }— a nestedmatch action { Set | List | Delete }each building an options struct and dispatching.Commands::Graph { subcommand }— a nestedmatch subcommand { Dump | Deps | Outputs }.What changed
Extracted each of these into standalone, purpose-named async helper functions so
main()'s match becomes a flat, one-line-per-arm dispatch table:dispatch_execute(ExecuteArgs) -> Result<()>— newExecuteArgsstruct carries the raw CLI fields; the function contains the--prepare-custom-agent-outputvalidation/branching that was previously inline.dispatch_secrets(SecretsCmd) -> Result<()>— theSet | List | Deletematch, unchanged in behavior.dispatch_graph_command(GraphCmd) -> Result<()>— theDump | Deps | Outputsmatch, unchanged in behavior.No public CLI behavior, flags, or error messages changed — this is purely a structural extraction to improve readability and testability.
Before / after
main()— 496/100 lines (clippytoo_many_lines).main()— 351/100 lines (still above the 100-line lint threshold; further reduction of the remaining large match arms is left for a future pass).Verification
cargo buildsucceeds.cargo test— full suite passes, no failures.cargo clippy --all-targets --all-features— clean (one pre-existing, unrelated warning increate_work_item.rs).Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.