Skip to content

chore(lints): adopt surgical clippy opt-ins workspace-wide#40

Merged
lostmygithubaccount merged 2 commits into
mainfrom
agent3/clippy-surgical
Apr 13, 2026
Merged

chore(lints): adopt surgical clippy opt-ins workspace-wide#40
lostmygithubaccount merged 2 commits into
mainfrom
agent3/clippy-surgical

Conversation

@lostmygithubaccount
Copy link
Copy Markdown
Member

Summary

  • Enable six high-signal clippy lints at [workspace.lints.clippy] and fix every existing violation across all 6 crates (including draw-py, which is its own workspace and mirrors the block manually).
  • Lints chosen: manual_let_else, missing_errors_doc, missing_panics_doc, redundant_closure_for_method_calls, uninlined_format_args, semicolon_if_nothing_returned.
  • Skipped pedantic wholesale plus must_use_candidate and needless_pass_by_value — the f32/f64 cast warnings and getter-spam would overwhelm the real signals without catching any bugs in this codebase.

Notable refactors

  • export_svg no longer splices <defs> in via svg.find('\n').unwrap() + 1. Assembles header → defs → body → footer in order.
  • find_nearest_snap_point uses Option::is_none_or instead of is_none() || .unwrap().
  • update_element_style (wasm) replaces three match { _ => return false } chains with let…else.
  • .map(|x| x.method()) rewrites to fn-item refs where trait dispatch is unambiguous (String::as_str, Element::id, f64::to_string).
  • # Errors / # Panics docs added on export_png, export_svg, the storage API, run_webapp, run_app, run_cli, and Renderer::render. Each names the actual failure surface rather than boilerplate.

Reviewed via /critique

Round 1: correctness + design + performance reviewers. Incorporated fixes for misleading # Panics text on Renderer::render, over-broad # Errors on run_cli / run_app, duplicate export_png docs, stale export_svg comment, and the draw-py coverage gap. Performance reviewer flagged a small extra allocation in the no-defs SVG path; kept for readability (sub-ms on realistic inputs) but documented as a possible future follow-up.

Test plan

  • bin/check green locally (fmt + clippy -D warnings + cargo test --workspace + Python ruff/ty)
  • Hachure-fill SVG output inspected for byte equivalence vs. pre-refactor
  • CI green

lostmygithubaccount and others added 2 commits April 13, 2026 00:36
Enable six high-signal clippy lints at workspace level and fix existing
violations across draw-core, draw-wasm, draw-webapp, draw-app, draw-cli,
and draw-py:

  - manual_let_else
  - missing_errors_doc
  - missing_panics_doc
  - redundant_closure_for_method_calls
  - uninlined_format_args
  - semicolon_if_nothing_returned

Pedantic as a whole, must_use_candidate, and needless_pass_by_value were
deliberately left disabled — they produce noise (f32/f64 cast spam,
getter spam) without catching real bugs in this codebase.

Notable semantics-preserving refactors driven by the new lints:

  * `export_svg` assembles header + defs + body + footer in order instead
    of splicing `<defs>` in via `svg.find('\n').unwrap() + 1` after the
    fact, removing an unwrap on an invariant the compiler can't see.
  * `find_nearest_snap_point` uses `Option::is_none_or` instead of
    `.is_none() || ….unwrap()`.
  * `render/draw.rs` uses `let Some(...) else { return }` for the
    `Mask::new` short-circuit.
  * `update_element_style` (wasm) replaces three `match { _ => return
    false }` chains with `let…else`.
  * `.map(|x| x.method())` → `.map(Type::method)` in wasm/core.

`# Errors` and `# Panics` sections added on `export_png`,
`export_png_with_scale`, `export_svg`, the `storage` API, `run_webapp`,
`run_app`, `run_cli`, and `Renderer::render`. Doc text describes the
actual failure surface (I/O, JSON, allocator OOM) rather than generic
boilerplate.

draw-py is its own cargo workspace so the outer `[workspace.lints]`
can't propagate; the same six lints are duplicated in its manifest.

Reviewed via `/critique` (correctness + design + performance, round 1).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Round-2 critique noted that `render_hachure_group` writes both
`opacity="…"` and `style="opacity:…"` on the same <g>, and the inline
style wins the cascade. The format-arg inlining in this PR touched that
line, so add a TODO comment to make the bug explicit rather than
silently-accepted. Fix scoped for a later PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lostmygithubaccount lostmygithubaccount merged commit 8beaf79 into main Apr 13, 2026
1 check passed
@lostmygithubaccount lostmygithubaccount deleted the agent3/clippy-surgical branch April 13, 2026 04:47
lostmygithubaccount added a commit that referenced this pull request Apr 13, 2026
Bumps all Rust crates and the Python package from 0.2.1 to 0.3.0. This
minor bump reflects one breaking change in the dkdc-draw-core public API
surface (pub -> pub(crate) demotions in #42), accumulated with the
non-breaking work from this cycle:

  - #35: arrow snap-to-shape connection points
  - #36: CONTRIBUTING.md + README badges
  - #37: integration tests for draw-core public API
  - #38: Rust + Python hello-world examples
  - #39: CHANGELOG.md scaffolding
  - #40: surgical clippy opt-ins workspace-wide
  - #41: sample gallery (5 drawings × json/svg/png)
  - #42: pub -> pub(crate) demotions (BREAKING)
  - #43: Python test coverage 5 -> 27

See CHANGELOG.md for the 0.3.0 section and migration notes for the
demoted symbols.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lostmygithubaccount lostmygithubaccount mentioned this pull request Apr 13, 2026
4 tasks
lostmygithubaccount added a commit that referenced this pull request Apr 13, 2026
Bumps all Rust crates and the Python package from 0.2.1 to 0.3.0. This
minor bump reflects one breaking change in the dkdc-draw-core public API
surface (pub -> pub(crate) demotions in #42), accumulated with the
non-breaking work from this cycle:

  - #35: arrow snap-to-shape connection points
  - #36: CONTRIBUTING.md + README badges
  - #37: integration tests for draw-core public API
  - #38: Rust + Python hello-world examples
  - #39: CHANGELOG.md scaffolding
  - #40: surgical clippy opt-ins workspace-wide
  - #41: sample gallery (5 drawings × json/svg/png)
  - #42: pub -> pub(crate) demotions (BREAKING)
  - #43: Python test coverage 5 -> 27

See CHANGELOG.md for the 0.3.0 section and migration notes for the
demoted symbols.

Co-authored-by: Claude Opus 4.6 (1M context) <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