Skip to content

chore: enforce clippy in CI, fix all warnings#642

Merged
softmarshmallow merged 13 commits intomainfrom
chore/clippy
Apr 7, 2026
Merged

chore: enforce clippy in CI, fix all warnings#642
softmarshmallow merged 13 commits intomainfrom
chore/clippy

Conversation

@softmarshmallow
Copy link
Copy Markdown
Member

@softmarshmallow softmarshmallow commented Apr 7, 2026

Summary

  • Add clippy.toml with too-many-arguments-threshold = 12 for graphics API ergonomics
  • Add [workspace.lints.clippy] to allow upper_case_acronyms (AABB, RGB, SVG are domain terms)
  • Wire [lints] workspace = true in all 6 crate Cargo.toml files
  • Blanket-allow clippy on vendored third_party/usvg (not our code to maintain)
  • Fix ~471 clippy warnings across all crates (auto-fix + manual fixes)
  • Add cargo clippy --no-deps -- -D warnings to just check and CI (test-crates.yml)

Per-crate changes

  • usvg: #![allow(clippy::all)] — vendored third-party code
  • math2: 12 fixes — collapsible if, legacy constants, excessive precision, bind_instead_of_map, etc.
  • fonts: 2 fixes — doc comment spacing, unnecessary filter_map
  • csscascade: 5 fixes — vec_init_then_push, arc_with_non_send_sync allows, field_reassign_with_default
  • cg: 55 fixes — len_without_is_empty, new_without_default, question_mark, collapsible_match, doc formatting, large_enum_variant allows, needless_range_loop, and auto-fixed Into/From/borrow/cast cleanups
  • grida-canvas-wasm: 3 fixes — unnecessary pointer casts
  • grida-dev: 1 fix — stale doc comment

Test plan

  • cargo clippy --no-deps -- -D warnings passes clean
  • cargo test --workspace --exclude grida-canvas-wasm — all tests pass
  • cargo fmt --all -- --check — no formatting issues

Summary by CodeRabbit

  • Code Quality
    • Enhanced code quality checks and linting infrastructure with workspace-wide Clippy configuration
    • Refactored internal code patterns for better maintainability and consistency

softmarshmallow and others added 9 commits April 8, 2026 02:51
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Apr 7, 2026 6:45pm
docs Ready Ready Preview, Comment Apr 7, 2026 6:45pm
grida Ready Ready Preview, Comment Apr 7, 2026 6:45pm
viewer Ready Ready Preview, Comment Apr 7, 2026 6:45pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
backgrounds Ignored Ignored Preview Apr 7, 2026 6:45pm
code Ignored Ignored Apr 7, 2026 6:45pm
legacy Ignored Ignored Apr 7, 2026 6:45pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8999a616-81ba-44d1-8305-c818c0c7f08e

📥 Commits

Reviewing files that changed from the base of the PR and between 3615385 and 70a509e.

📒 Files selected for processing (112)
  • .github/workflows/test-crates.yml
  • Cargo.toml
  • clippy.toml
  • crates/csscascade/Cargo.toml
  • crates/csscascade/src/adapter.rs
  • crates/csscascade/src/dom.rs
  • crates/csscascade/src/rcdom/mod.rs
  • crates/csscascade/src/tree/mod.rs
  • crates/grida-canvas-fonts/Cargo.toml
  • crates/grida-canvas-fonts/src/parse.rs
  • crates/grida-canvas-fonts/src/parse_feature/mode_full.rs
  • crates/grida-canvas-fonts/src/parse_feature/mode_simple.rs
  • crates/grida-canvas-fonts/src/parse_feature_params.rs
  • crates/grida-canvas-fonts/src/parse_ui.rs
  • crates/grida-canvas-fonts/src/selection.rs
  • crates/grida-canvas-fonts/src/selection_italic.rs
  • crates/grida-canvas-wasm/Cargo.toml
  • crates/grida-canvas-wasm/src/wasm_application.rs
  • crates/grida-canvas/Cargo.toml
  • crates/grida-canvas/src/cache/atlas/mod.rs
  • crates/grida-canvas/src/cache/compositor/promotion.rs
  • crates/grida-canvas/src/cache/fast_hash.rs
  • crates/grida-canvas/src/cache/geometry.rs
  • crates/grida-canvas/src/cache/paragraph.rs
  • crates/grida-canvas/src/cache/picture.rs
  • crates/grida-canvas/src/cache/scene.rs
  • crates/grida-canvas/src/cache/vector_path.rs
  • crates/grida-canvas/src/cg/colormatrix.rs
  • crates/grida-canvas/src/cg/fe.rs
  • crates/grida-canvas/src/cg/stroke_dasharray.rs
  • crates/grida-canvas/src/cg/stroke_width.rs
  • crates/grida-canvas/src/cg/svg.rs
  • crates/grida-canvas/src/cg/tilemode.rs
  • crates/grida-canvas/src/cg/transform.rs
  • crates/grida-canvas/src/cg/types.rs
  • crates/grida-canvas/src/devtools/ruler_overlay.rs
  • crates/grida-canvas/src/export/export_as_image.rs
  • crates/grida-canvas/src/export/mod.rs
  • crates/grida-canvas/src/hittest/hit_tester.rs
  • crates/grida-canvas/src/html/mod.rs
  • crates/grida-canvas/src/htmlcss/collect.rs
  • crates/grida-canvas/src/htmlcss/layout.rs
  • crates/grida-canvas/src/htmlcss/paint.rs
  • crates/grida-canvas/src/htmlcss/style.rs
  • crates/grida-canvas/src/htmlcss/types.rs
  • crates/grida-canvas/src/io/id_converter.rs
  • crates/grida-canvas/src/io/io_css.rs
  • crates/grida-canvas/src/io/io_grida.rs
  • crates/grida-canvas/src/io/io_grida_fbs.rs
  • crates/grida-canvas/src/layout/engine.rs
  • crates/grida-canvas/src/layout/tree.rs
  • crates/grida-canvas/src/node/factory.rs
  • crates/grida-canvas/src/node/id.rs
  • crates/grida-canvas/src/node/scene_graph.rs
  • crates/grida-canvas/src/node/schema.rs
  • crates/grida-canvas/src/painter/effects.rs
  • crates/grida-canvas/src/painter/effects_noise.rs
  • crates/grida-canvas/src/painter/geometry.rs
  • crates/grida-canvas/src/painter/image.rs
  • crates/grida-canvas/src/painter/image_filters.rs
  • crates/grida-canvas/src/painter/layer.rs
  • crates/grida-canvas/src/painter/mod.rs
  • crates/grida-canvas/src/painter/painter.rs
  • crates/grida-canvas/src/painter/painter_debug_node.rs
  • crates/grida-canvas/src/painter/shadow.rs
  • crates/grida-canvas/src/query/hierarchy.rs
  • crates/grida-canvas/src/query/paint.rs
  • crates/grida-canvas/src/runtime/camera.rs
  • crates/grida-canvas/src/runtime/counter.rs
  • crates/grida-canvas/src/runtime/font_repository.rs
  • crates/grida-canvas/src/runtime/scene.rs
  • crates/grida-canvas/src/shape/ellipse.rs
  • crates/grida-canvas/src/shape/ellipse_ring_sector.rs
  • crates/grida-canvas/src/shape/mod.rs
  • crates/grida-canvas/src/shape/rect.rs
  • crates/grida-canvas/src/shape/regular_star.rs
  • crates/grida-canvas/src/shape/rrect.rs
  • crates/grida-canvas/src/shape/vector.rs
  • crates/grida-canvas/src/sk/mappings.rs
  • crates/grida-canvas/src/surface/selection.rs
  • crates/grida-canvas/src/surface/ui/render.rs
  • crates/grida-canvas/src/svg/from_usvg_tree.rs
  • crates/grida-canvas/src/svg/pack.rs
  • crates/grida-canvas/src/sys/clock.rs
  • crates/grida-canvas/src/sys/timer.rs
  • crates/grida-canvas/src/text/attributed_paragraph.rs
  • crates/grida-canvas/src/text/paragraph_cache_layout.rs
  • crates/grida-canvas/src/text/text_style.rs
  • crates/grida-canvas/src/text_edit/attributed_text/html.rs
  • crates/grida-canvas/src/text_edit/attributed_text/mod.rs
  • crates/grida-canvas/src/text_edit/mod.rs
  • crates/grida-canvas/src/text_edit/selection_rects.rs
  • crates/grida-canvas/src/text_edit/session.rs
  • crates/grida-canvas/src/text_edit/skia_layout.rs
  • crates/grida-canvas/src/vectornetwork/vn.rs
  • crates/grida-canvas/src/vectornetwork/vn_painter.rs
  • crates/grida-canvas/src/window/application.rs
  • crates/grida-dev/Cargo.toml
  • crates/grida-dev/src/bench/runner.rs
  • crates/grida-dev/src/reftest/render.rs
  • crates/grida-dev/src/reftest/runner.rs
  • crates/math2/Cargo.toml
  • crates/math2/src/bezier.rs
  • crates/math2/src/layout.rs
  • crates/math2/src/range.rs
  • crates/math2/src/raster.rs
  • crates/math2/src/rect.rs
  • crates/math2/src/snap.rs
  • crates/math2/src/transform.rs
  • justfile
  • third_party/usvg/src/lib.rs
  • third_party/usvg/src/main.rs

Walkthrough

A comprehensive refactoring that establishes Clippy lint infrastructure (CI job, workspace configuration, clippy.toml) and applies widespread code improvements including trait implementation conversions (Into→From), Default derive adoption, control-flow simplifications, clone removals, and idiomatic Rust pattern updates across 70+ files.

Changes

Cohort / File(s) Summary
CI & Lint Infrastructure
.github/workflows/test-crates.yml, Cargo.toml, clippy.toml, justfile
Added Clippy CI job with system dependency setup and caching; workspace-level lint configuration allowing uppercase acronyms; clippy.toml with increased function argument threshold (12); check recipe now runs Clippy.
Crate Lint Inheritance
crates/*/Cargo.toml
Multiple crates (csscascade, grida-canvas-fonts, grida-canvas-wasm, grida-canvas, grida-dev, math2) updated to inherit workspace lint configuration.
Type System Refactoring
crates/grida-canvas/src/cg/types.rs
Large-scale refactoring: 20+ enums switched to derive Default with #[default] markers; six conversion trait implementations changed from Into to From; assertion condition simplified using range pattern.
Conversion Trait Updates
crates/grida-canvas/src/{cg/fe.rs,export/export_as_image.rs,shape/{mod.rs,rect.rs,regular_star.rs,rrect.rs},sk/mappings.rs}, crates/grida-canvas/src/vectornetwork/vn.rs
Systematic replacement of impl Into<T> for U with impl From<U> for T across shape conversions, filter effects, and Skia mappings for better idiomatic Rust patterns.
Default Implementations
crates/csscascade/src/tree/mod.rs, crates/grida-canvas/src/{cache/{geometry,paragraph,picture,scene,vector_path}.rs,cg/{stroke_width,tilemode}.rs,htmlcss/types.rs,io/io_css.rs,layout/engine.rs,node/factory.rs,painter/shadow.rs,runtime/{clock,counter,font_repository,scene}.rs,shape/vector.rs,sys/clock.rs,text_edit/attributed_text/mod.rs,text_edit/selection_rects.rs,window/application.rs}
Multiple types updated to derive Default instead of providing manual implementations; several cache types now have new is_empty() public methods.
Control Flow Simplifications
crates/csscascade/src/{adapter.rs,dom.rs,rcdom/mod.rs}, crates/grida-canvas/src/{html/mod.rs,htmlcss/{collect.rs,layout.rs,paint.rs},hittest/hit_tester.rs,io/id_converter.rs,io/io_grida_fbs.rs,layout/tree.rs,painter/{layer.rs,painter.rs,shadow.rs},query/hierarchy.rs,text_edit/skia_layout.rs}
Nested conditionals converted to combined && conditions, if let Some chains flattened, early returns replaced with ? operator, match expressions simplified to if let, and unnecessary variable bindings removed.
Clone Removal & Ownership Refactoring
crates/grida-canvas/{src/cache/picture.rs,src/layout/engine.rs,src/node/scene_graph.rs,src/painter/{geometry.rs,layer.rs},src/query/paint.rs,src/runtime/scene.rs,src/svg/pack.rs,src/surface/selection.rs}, crates/grida-canvas-wasm/src/wasm_application.rs
Systematic removal of unnecessary clones; dereferencing used in favor of cloning for Copy types; CloneCopy optimizations in cache and layout operations; NodeId ownership simplified.
Option/Iterator Pattern Modernization
crates/csscascade/src/adapter.rs, crates/grida-canvas/src/{io/io_grida.rs,layout/engine.rs,query/paint.rs,runtime/scene.rs,text/attributed_paragraph.rs,text_edit/mod.rs}, crates/math2/src/snap.rs
Updated to use is_some_and(), strip_prefix(), .map(f) instead of .map(|x| f(x)), try_fold() instead of nested fold/and_then, and .unwrap_or()/.unwrap_or_default() patterns.
Lint Suppression Attributes
crates/grida-canvas/src/{cache/atlas/mod.rs,cg/svg.rs,htmlcss/style.rs,layout/engine.rs,node/id.rs,painter/{layer.rs,mod.rs,painter.rs},sys/timer.rs,text/attributed_paragraph.rs,window/application.rs}, crates/grida-dev/src/reftest/render.rs
Added targeted Clippy allow attributes (module_inception, large_enum_variant, should_implement_trait, type_complexity, needless_range_loop, only_used_in_recursion, arc_with_non_send_sync, too_many_arguments) to specific functions/types; third-party usvg crate blanket suppressed with #![allow(clippy::all)].
Minor Pattern & Style Updates
crates/grida-canvas-fonts/src/{parse.rs,parse_feature/mode_*.rs,parse_feature_params.rs,parse_ui.rs,selection.rs,selection_italic.rs}, crates/grida-canvas/src/{cg/{colormatrix.rs,fast_hash.rs,stroke_dasharray.rs,tilemode.rs,transform.rs},devtools/ruler_overlay.rs,export/mod.rs,painter/{effects.rs,effects_noise.rs,image.rs,image_filters.rs},shape/{ellipse.rs,ellipse_ring_sector.rs},svg/from_usvg_tree.rs}, crates/math2/src/{bezier.rs,layout.rs,range.rs,raster.rs,rect.rs,transform.rs}
Expression-style returns replacing explicit return, const-wrapped initializer for thread-local storage, variable renaming for clarity, iterator-based mutations replacing index loops, type conversions simplified, doc comment formatting adjustments, unused variable removal, and constant value refinements.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/clippy

softmarshmallow and others added 2 commits April 8, 2026 03:01
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skia bindings require pre-built artifacts that are cached by the test
job (shared-key: test-native). Using a separate cache key caused cold
builds that fail on chromium git-sync-deps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Clippy needs to fully compile all dependencies including skia-bindings.
Running after the test job guarantees the shared cargo cache contains
the pre-built Skia artifacts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@softmarshmallow softmarshmallow marked this pull request as ready for review April 7, 2026 19:05
@softmarshmallow softmarshmallow merged commit 210dd16 into main Apr 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant