You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improvement 1: Replace redundant closures with method references in serde_json::Value extraction
Category: Type Safety File(s): labels/helpers.rs, labels/backend.rs, labels/response_items.rs, labels/response_paths.rs Effort: Small (< 15 min) Risk: Low
Problem
cargo clippy -- -W clippy::pedantic flags 11 sites using .and_then(|v| v.as_bool()) / .and_then(|v| v.as_u64()) / .map(|value| value.trim()) where the closure is a redundant wrapper around a method call. Clippy's redundant_closure_for_method_calls lint recommends passing the method itself.
Apply the same and_then(Value::as_bool) / and_then(Value::as_u64) substitution at the other 9 sites listed above (note serde_json::Value is already in scope in all four files).
Why This Matters
Removes 11 unnecessary closure allocations flagged by clippy::pedantic, clarifies intent (the code is just delegating to an existing method), and is a pure syntactic simplification with zero behavior change — trivially verified by cargo clippy and the existing test suite.
Improvement 2: Take integrity Vec<String> arguments by reference in cap_integrity/max_integrity
Category: Type Safety / Performance File(s): labels/helpers.rs Effort: Small (< 15 min) Risk: Low
Problem
cap_integrity (line 654) and max_integrity (line 1645) both take current/cap/candidate as owned Vec<String>, but each function only ever reads the vectors via integrity_rank_normalized(&normalized_scope, ¤t) — it never mutates or moves them. Clippy's needless_pass_by_value pedantic lint flags this. Because the parameters are owned, two test call sites are forced to add avoidable .clone() calls just to keep using the value afterward for an assertion:
labels/helpers.rs:3413 — cap_integrity(scope, current.clone(), cap, &ctx) (clones current only so it can be compared against result afterward)
labels/helpers.rs:3426 — max_integrity(scope, current, candidate.clone(), &ctx) (clones candidate for the same reason)
Suggested Change
Change both function signatures to accept &[String] instead of Vec<String>. Update the ~13 call sites across labels/helpers.rs and labels/tool_rules.rs to pass references (e.g. &integrity, &cap) instead of owned vectors — most call sites already own a local Vec<String> binding, so this is a & prefix change, not a restructure.
// test call site — no clone needed, current is still owned by the callerlet result = cap_integrity(scope,¤t,&cap,&ctx);
Apply the equivalent signature change to max_integrity, and update all callers (e.g. labels/tool_rules.rs:199, :212, :402-431; labels/helpers.rs:471, 550, 884, 913, 927, 1849, 1980-2222) to pass &integrity/&floor/&cap etc.
Why This Matters
Eliminates the needless_pass_by_value clippy warning at 4 parameter sites, removes 2 test-only .clone() calls that exist purely as a workaround for the ownership requirement, and avoids moving/copying Vec<String> at every one of the ~15 call sites in hot label-computation paths (each call currently transfers ownership of a heap-allocated vector it didn't need to consume).
Areas with no further improvements found this run: labels/constants.rs, tools.rs (well-organized, no new raw-literal duplication found beyond prior extractions)
Note: cargo clippy --lib -- -W clippy::pedantic also surfaces ~90 uninlined_format_args and ~60 doc-backtick warnings, but these are high-volume/low-value style nits better handled by a bulk cargo clippy --fix pass rather than a manual PR, so they were excluded from this report in favor of the two concrete, hand-verified improvements above.
Generated by Rust Guard Improver • Run: 36117626642
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
index.crates.io
static.crates.io
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
Improvement 1: Replace redundant closures with method references in
serde_json::ValueextractionCategory: Type Safety
File(s):
labels/helpers.rs,labels/backend.rs,labels/response_items.rs,labels/response_paths.rsEffort: Small (< 15 min)
Risk: Low
Problem
cargo clippy -- -W clippy::pedanticflags 11 sites using.and_then(|v| v.as_bool())/.and_then(|v| v.as_u64())/.map(|value| value.trim())where the closure is a redundant wrapper around a method call. Clippy'sredundant_closure_for_method_callslint recommends passing the method itself.Sites:
labels/helpers.rs:50—.and_then(|v| v.as_u64())labels/helpers.rs:73—.and_then(|v| v.as_u64())labels/helpers.rs:97—.and_then(|v| v.as_u64())labels/helpers.rs:341—.map(|value| value.trim())labels/helpers.rs:1150—.and_then(|v| v.as_bool())labels/helpers.rs:1753—.and_then(|v| v.as_bool())labels/backend.rs:692—.and_then(|v| v.as_bool())labels/backend.rs:1569—.and_then(|v| v.as_bool())labels/response_items.rs:73—.and_then(|v| v.as_bool())labels/response_paths.rs:97—.and_then(|v| v.as_bool())Suggested Change
Replace each closure with the bare method reference.
Before
After
Apply the same
and_then(Value::as_bool)/and_then(Value::as_u64)substitution at the other 9 sites listed above (noteserde_json::Valueis already in scope in all four files).Why This Matters
Removes 11 unnecessary closure allocations flagged by
clippy::pedantic, clarifies intent (the code is just delegating to an existing method), and is a pure syntactic simplification with zero behavior change — trivially verified bycargo clippyand the existing test suite.Improvement 2: Take integrity
Vec<String>arguments by reference incap_integrity/max_integrityCategory: Type Safety / Performance
File(s):
labels/helpers.rsEffort: Small (< 15 min)
Risk: Low
Problem
cap_integrity(line 654) andmax_integrity(line 1645) both takecurrent/cap/candidateas ownedVec<String>, but each function only ever reads the vectors viaintegrity_rank_normalized(&normalized_scope, ¤t)— it never mutates or moves them. Clippy'sneedless_pass_by_valuepedantic lint flags this. Because the parameters are owned, two test call sites are forced to add avoidable.clone()calls just to keep using the value afterward for an assertion:labels/helpers.rs:3413—cap_integrity(scope, current.clone(), cap, &ctx)(clonescurrentonly so it can be compared againstresultafterward)labels/helpers.rs:3426—max_integrity(scope, current, candidate.clone(), &ctx)(clonescandidatefor the same reason)Suggested Change
Change both function signatures to accept
&[String]instead ofVec<String>. Update the ~13 call sites acrosslabels/helpers.rsandlabels/tool_rules.rsto pass references (e.g.&integrity,&cap) instead of owned vectors — most call sites already own a localVec<String>binding, so this is a&prefix change, not a restructure.Before
After
Apply the equivalent signature change to
max_integrity, and update all callers (e.g.labels/tool_rules.rs:199,:212,:402-431;labels/helpers.rs:471,550,884,913,927,1849,1980-2222) to pass&integrity/&floor/&capetc.Why This Matters
Eliminates the
needless_pass_by_valueclippy warning at 4 parameter sites, removes 2 test-only.clone()calls that exist purely as a workaround for the ownership requirement, and avoids moving/copyingVec<String>at every one of the ~15 call sites in hot label-computation paths (each call currently transfers ownership of a heap-allocated vector it didn't need to consume).Codebase Health Summary
lib.rs,tools.rs,labels/mod.rs,labels/backend.rs,labels/constants.rs,labels/helpers.rs,labels/response_items.rs,labels/response_paths.rs,labels/tool_rules.rslabels/constants.rs,tools.rs(well-organized, no new raw-literal duplication found beyond prior extractions)Note:
cargo clippy --lib -- -W clippy::pedanticalso surfaces ~90uninlined_format_argsand ~60 doc-backtick warnings, but these are high-volume/low-value style nits better handled by a bulkcargo clippy --fixpass rather than a manual PR, so they were excluded from this report in favor of the two concrete, hand-verified improvements above.Generated by Rust Guard Improver • Run: 36117626642
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
index.crates.iostatic.crates.ioTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.