style: Prefer references to `cli_args::Args`
#532 opened on Mar 27, 2025
Repository metrics
- Stars
- (110 stars)
- PR merge metrics
- (PR metrics pending)
Description
Some test helper setup functions take a reference to cli_args::Args and others take ownership of an object. The latter type generates more boilerplate due to excessive .clone().
The intention behind cli_args::Args is that once set, they never change. (If there is a transgression against this principle anywhere, we need to fix that.) So cloning in order to pass ownership of an object that's not going to change anyway is moot in addition to boilerplatey. Let's prefer references instead.
I do think one exception is necessary. We want one copy of the CLI arguments to live on global state. And we do not want to bother keeping track of lifetimes there. So we clone it once, when constructing global state.
Most of this task boils down to fixing function interfaces in tests and red squiggly lines that result from there.