Uh oh!
There was an error while loading. Please reload this page.
refactor(main): extract execute/secrets/graph dispatch from main() - #1972
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
Extracts the Commands::Execute, Commands::Secrets, and Commands::Graph match arms from main() into standalone async helper functions (dispatch_execute_command, dispatch_secrets_command, dispatch_graph_command). main()'s too_many_lines complexity drops from 496 to 355. No public API or behavior changes; full test suite and clippy --all-targets --all-features pass clean. 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 by Clippy'stoo_many_lineslint at 496/100 lines. The bulk of this was three largematcharms handlingCommands::Execute,Commands::Secrets, andCommands::Graph, each containing substantial inline logic (including a nestedmatchforCommands::Secrets'sSecretsCmdandCommands::Graph'sGraphCmd).What changed
Extracted the logic for these three arms into standalone async helper functions, placed just above
main():dispatch_execute_command(ExecuteCommandArgs) -> Result<()>— handles the--prepare-custom-agent-outputbranch and the normalrun_executepath. NewExecuteCommandArgsstruct groups the CLI-parsed fields.dispatch_secrets_command(SecretsCmd) -> Result<()>— handlesSecretsCmd::Set/List/Delete.dispatch_graph_command(GraphCmd) -> Result<()>— handlesGraphCmd::Dump/Deps/Outputs.main()'s top-levelmatchnow has a single, flat call per arm for these commands, matching the pattern already used elsewhere in the file (e.g.run_execute,run_compile).Result
main()cognitive/line complexity: 496/100 → 355/100 (still above the artificially low 100-line Clippy threshold used to surface candidates, but a meaningful reduction; a further pass could extract more arms).cargo build,cargo test(full suite), andcargo clippy --all-targets --all-featuresall pass clean (one pre-existing, unrelatedfield_reassign_with_defaultwarning increate_work_item.rsremains untouched).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.