fix: clean cargo warnings and add unit tests (#45) #46

Merged
rawdaGastan merged 1 commit from development_warnings_tests into development 2026-04-22 14:25:34 +00:00
Member

Closes #45.

Summary

Clears every warning emitted by cargo check / build / clippy / test on development, so make lint and make test-all (which run cargo clippy --workspace --all-targets -- -D warnings) are green again. Also adds 55 unit tests for previously untested pure-logic modules.

Warning fixes

crates/hero_router/src/server/mcp.rs — 7 dead-code warnings

Deleted 7 unused helpers that formed a self-contained island (named_to_positional + coerce_value / coerce_to_{array,bool,integer,number,string}). The current MCP dispatch path in mcp.rs already passes MCP arguments through as-is to the backend service (see the comment // Pass arguments through as-is; only coerce empty/missing into params object rather than null). These helpers were stranded by the earlier switch made in commit 77a9066 (fix(mcp): pass named args through instead of named->positional conversion).

crates/hero_router/src/python_codegen.rs:539 — clippy collapsible_if

Collapsed a nested if let Some(components) = … { if !components.is_empty() { … } } into a single if let + && let-chain. Let-chains have been stable since Rust 1.88; the workspace pins 1.93.

crates/hero_router/src/server/terminal.rs — 2 clippy unnecessary_cast

Dropped two as i64 casts where the source expression was already i64 (lines 64 and 181 in the pre-PR file).

Test additions (16 → 71)

File New tests Covers
config.rs 4 defaults, builder overrides, derived socket paths, server_socket_path alias
manifest.rs 7 load-missing, save/load roundtrip, dedupe on add, remove by id/source/name_override, remove-not-found, auto-mkdir parent, unique UUIDs
cache.rs 24 SourceKind::from_source, derive_group_name well-known sockets vs stem fallback, ServiceEntry::has_openrpc/has_web/primary_protocol, RouterCache::upsert including ghost-eviction and pinned-survival, sorted_entries healthy-first + case-insensitive title order, context filtering, get_by_name_or_title priority chain, get_entries_by_group OpenRPC-first sort, stats, mark_scanned, set/get_contexts, McpLog push/recent/service-normalized filter/clear, RouterLog push/delete_ids/clear
generator/markdown.rs 9 header + metadata block, socket/URL/file source snippets, OpenRPC socat vs HTTP curl branches, empty-methods placeholder, parameter table + example JSON, no-params path, $ref resolution into the Types section
generator/html.rs 11 html_escape XSS coverage (ampersand precedence, quotes, single-quotes, no-op), document skeleton, socket vs URL rendering, status badge, escaping of title/description, empty-methods placeholder, method accordion + HTML-escaped example request, method-count badge

All new tests are synchronous or tokio::test async — no sockets, no network, tempdir only where persistence is involved (manifest). Total runtime <10 ms.

Misc

cargo fmt --all reformatting was already in progress on the branch (mostly argument-list reflows in main.rs, routes.rs, hero_inspector_app/**); it is included here so the tree is fmt-clean and make test-all passes end-to-end.

Verification

make test-all
#   cargo fmt --all --check            → ok
#   cargo clippy --all-targets -Dwarn  → ok
#   cargo test --workspace             → 71 passed, 0 failed
#   cargo build --workspace --release  → ok
Closes #45. ## Summary Clears every warning emitted by `cargo check` / `build` / `clippy` / `test` on `development`, so `make lint` and `make test-all` (which run `cargo clippy --workspace --all-targets -- -D warnings`) are green again. Also adds 55 unit tests for previously untested pure-logic modules. ## Warning fixes ### `crates/hero_router/src/server/mcp.rs` — 7 dead-code warnings Deleted 7 unused helpers that formed a self-contained island (`named_to_positional` + `coerce_value` / `coerce_to_{array,bool,integer,number,string}`). The current MCP dispatch path in `mcp.rs` already passes MCP arguments through as-is to the backend service (see the comment `// Pass arguments through as-is; only coerce empty/missing into params object rather than null`). These helpers were stranded by the earlier switch made in commit `77a9066` (`fix(mcp): pass named args through instead of named->positional conversion`). ### `crates/hero_router/src/python_codegen.rs:539` — clippy `collapsible_if` Collapsed a nested `if let Some(components) = … { if !components.is_empty() { … } }` into a single `if let` + `&&` let-chain. Let-chains have been stable since Rust 1.88; the workspace pins 1.93. ### `crates/hero_router/src/server/terminal.rs` — 2 clippy `unnecessary_cast` Dropped two `as i64` casts where the source expression was already `i64` (lines 64 and 181 in the pre-PR file). ## Test additions (16 → 71) | File | New tests | Covers | |---|---|---| | `config.rs` | 4 | defaults, builder overrides, derived socket paths, `server_socket_path` alias | | `manifest.rs` | 7 | load-missing, save/load roundtrip, dedupe on add, remove by id/source/name_override, remove-not-found, auto-mkdir parent, unique UUIDs | | `cache.rs` | 24 | `SourceKind::from_source`, `derive_group_name` well-known sockets vs stem fallback, `ServiceEntry::has_openrpc/has_web/primary_protocol`, `RouterCache::upsert` including ghost-eviction and pinned-survival, `sorted_entries` healthy-first + case-insensitive title order, context filtering, `get_by_name_or_title` priority chain, `get_entries_by_group` OpenRPC-first sort, `stats`, `mark_scanned`, `set/get_contexts`, `McpLog` push/recent/service-normalized filter/clear, `RouterLog` push/delete_ids/clear | | `generator/markdown.rs` | 9 | header + metadata block, socket/URL/file source snippets, OpenRPC socat vs HTTP curl branches, empty-methods placeholder, parameter table + example JSON, no-params path, `$ref` resolution into the Types section | | `generator/html.rs` | 11 | `html_escape` XSS coverage (ampersand precedence, quotes, single-quotes, no-op), document skeleton, socket vs URL rendering, status badge, escaping of title/description, empty-methods placeholder, method accordion + HTML-escaped example request, method-count badge | All new tests are synchronous or `tokio::test` async — no sockets, no network, tempdir only where persistence is involved (manifest). Total runtime <10 ms. ## Misc `cargo fmt --all` reformatting was already in progress on the branch (mostly argument-list reflows in `main.rs`, `routes.rs`, `hero_inspector_app/**`); it is included here so the tree is fmt-clean and `make test-all` passes end-to-end. ## Verification ``` make test-all # cargo fmt --all --check → ok # cargo clippy --all-targets -Dwarn → ok # cargo test --workspace → 71 passed, 0 failed # cargo build --workspace --release → ok ```
fix: clean cargo warnings and add unit tests
All checks were successful
Build & Test / check (push) Successful in 1m45s
Build & Test / check (pull_request) Successful in 1m40s
5ea70f34ec
Closes #45.

- Remove dead MCP arg-coercion helpers in server/mcp.rs.
- Collapse nested if-let in python_codegen.rs (let-chain).
- Drop redundant `as i64` casts in server/terminal.rs.
- Apply rustfmt across the workspace.
- Add 55 unit tests across config, manifest, cache, and the
  markdown/html generators (16 → 71).

make test-all passes end-to-end.
rawdaGastan merged commit b3f9f58663 into development 2026-04-22 14:25:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_router!46
No description provided.