Skip to content

Fix the clippy pedantic warnings in walgit-config - #28

Open
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:clippy/walgit-config
Open

Fix the clippy pedantic warnings in walgit-config#28
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:clippy/walgit-config

Conversation

@0bserver07

Copy link
Copy Markdown

Second slice of the debt #15 described, after #23 did walgit-proto. This gets cargo clippy -p walgit-config --all-targets -- -D warnings to zero. One file: crates/walgit-config/src/lib.rs.

Most of it is mechanical:

  • Duration values written in seconds now use the minute or hour constructor. Every value is identical; no default moved.
  • Doc comments get their backticks; a handful of closures, map().unwrap_or chains and a collapsible if take clippy's suggestion.
  • The WALGIT__ env override walker takes the path apart with split_first instead of indexing it, so the panic path is gone and well formed paths behave exactly as before.
  • The default listen address is built with SocketAddr::from instead of parsed, so that unwrap is gone rather than renamed.
  • Three structs mirror TOML sections and keep a targeted #[allow(clippy::struct_excessive_bools)], since turning their flags into enums would change walgit.toml. That's the only allow in here.

Checked with clippy on the crate (zero warnings), cargo test -p walgit-config (12 pass), cargo fmt, and cargo check -p walgit-server to show the public API is unchanged. walgit-git is next if this shape works for you; it has 184 warnings in its lib.

The lint gate merged in tobi#15 left 45 warned locations in this crate across 17
lints: Duration values built from seconds where a minute or hour constructor
reads the same, doc comments missing backticks or a paragraph break, a Result
unwrap and four indexing sites clippy counts as panic paths, and a set of
mechanical style lints such as redundant closures, map().unwrap_or and a
collapsible if. Every Duration keeps its exact value, so no default moved:
from_secs(7 * 24 * 3600) is now from_hours(7 * 24), and the rest follow the same
rule. The env override walker takes the path apart with split_first instead of
indexing it, which removes the panic path while a well formed path behaves as
before. The default listen address is built with SocketAddr::from instead of
parsed, so that unwrap is gone rather than renamed. The three structs that
mirror a TOML section carry a targeted allow for struct_excessive_bools, because
folding their flags into enums would change the shape of walgit.toml; it is the
only allow added. Config's Default impl is derived now, which is what the hand
written one did field by field. Checked with cargo clippy -p walgit-config
--all-targets --no-deps -- -D warnings for zero warnings, cargo test -p
walgit-config for 12 passing tests, cargo fmt --all -- --check, and cargo check
-p walgit-server to show the public API is untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant