Skip to content

Code Health

github-actions[bot] edited this page Nov 29, 2026 · 3 revisions

Code Health

Measured at v2026.48 (fe7adfcef), 2026-11-29. Rebuilt on every release from the code; nothing here is edited by hand.

How to help: pick a task under Pick up a cleanup; check the Code health section in your pull request's checks summary, which shows what your change improves; read how this is measured.

Scorecard

Structure

4 of 8 improved since main@8bed4f27f.

Measure Now Since last release Next milestone Trend Long-term
Upward dependencies (files) 21 better (-178) ▰▱▱▱▱▱▱▱▱▱ 13% to 11 ██▁ 0
Upward module pairs 1 better (-31) ▱▱▱▱▱▱▱▱▱▱ 0% to 0 ██▁ 0
Modules that use each other 10 better (-16) ▰▰▰▰▱▱▱▱▱▱ 43% to 6 ██▁ 0
Files over 3,000 lines 61 better (-1) worse than the baseline (59) ▁█▅ 0
Functions over 150 lines 592 worse (+6) worse than the baseline (532) ▁▇█ 0
Top-level Message variants — — lower
Process-wide mutable statics 320 — ▱▱▱▱▱▱▱▱▱▱ 0% to 160 lower
thread_local! blocks 76 — ▱▱▱▱▱▱▱▱▱▱ 0% to 38 lower

Robustness

3 of 3 improved since main@8bed4f27f.

Measure Now Since last release Next milestone Trend Long-term
unwrap/expect/panic! in production code 670 better (-1) ▱▱▱▱▱▱▱▱▱▱ 0% to 335 ▁█▇ lower
unwrap/expect/panic! in file import and export (src/io) 0 better (-25) reached the target ▅█▁ 0
unsafe without a SAFETY note 101 better (-8) ▰▱▱▱▱▱▱▱▱▱ 8% to 52 ▇█▁ 0

Hygiene

0 of 3 improved since main@8bed4f27f.

Measure Now Since last release Next milestone Trend Long-term
Clippy warnings 1,182 worse (+30) worse than the baseline (29) ▁██ 0
Compiler warnings 214 worse (+11) worse than the baseline (3) ▁██ 0
Files rustfmt would change 716 worse (+170) worse than the baseline (394) ▁▄█ 0

Tests & dependencies

2 of 4 improved since main@8bed4f27f.

Measure Now Since last release Next milestone Trend Long-term
Line coverage of the core layers (%) 63.3 better (+0.5) ▰▰▱▱▱▱▱▱▱▱ 24% to 67.1 ▁▅█ 100
Test functions (#[test]) 8,810 better (+193) ▰▰▰▰▰▰▰▱▱▱ 69% to 9,065 ▁▇█ higher
RustSec advisories in dependencies 19 no change ▰▰▰▰▰▰▰▰▰▱ 94% to 18 █▁▁ 0
Crates in the dependency tree 851 no change above the baseline (809) ▁██ lower

Coverage by layer

Line coverage of production code in each core layer (test code, generated files and the excluded paths are left out).

Layer Coverage Lines not run by tests Since last release Trend
0 Foundations 61.0% 693 better (+2.2) █▁▇
1 Drawing model and geometry 57.1% 27,565 better (+2.9) ▁▂█
2 File formats and rendering 75.9% 29,035 better (+1.0) ▁▅█
3 Tool contract and plugin runtime 77.1% 1,945 better (+13.0) ▁▁█
4 Features (modules) 49.1% 44,119 worse (-0.2) █▃▁

Crate readiness

The crates planned in TARGET.md, lowest first. A crate can move out of the root package when its modules use nothing that is neither in the crate nor in a crate below it. Test code is counted apart: the tests move with their crate. Unlike the upward dependencies, this also counts ui using app::Message, items in the crate root and the exported macros.

Crate Modules Production code Test code
ocs_base par, perf, i18n, config, network, wildcard, xml_depth, schema_validation, sys, sysinfo, paths, icon_assets ready ready
ocs_model entities, parametric, filter, calc, display, text, catalog, media ready ready
ocs_io io, ifc_plan ready ready
ocs_session — no modules yet no modules yet
ocs_render scene, gpu_backend, snap ready 37 files
ocs_commands command, plugin_catalog, modules, entity_creation ready ready
ocs_ui ui, input 176 files 19 files

What blocks ocs_render

What blocks ocs_ui

Not in a planned crate yet: loader, output (CRATES in scripts/arch_check.py).

Process-wide state

State held for the whole process, by module: statics whose value can change after start (atomics, mutexes, OnceLock, cells) and thread_local! blocks. Step 3 of TARGET.md moves it into the session or the app state.

Module Mutable statics thread_local! blocks For example
modules 75 5 src/modules/annotate/dim_cmd.rs:80
ui 28 24 src/ui/command_line.rs:1863
app 40 9 src/app/alt_code.rs:144
scene 38 11 src/scene/analysis.rs:27
text 32 6 crates/ocs_model/src/text/font_repo.rs:22
io 21 2 crates/ocs_io/src/io/backup.rs:17
entities 13 6 crates/ocs_model/src/entities/civil.rs:37
sys 13 3 crates/ocs_base/src/sys/clipboard_svg.rs:311
media 15 0 crates/ocs_model/src/media/image_source.rs:45
perf 12 0 crates/ocs_base/src/perf.rs:15
plugin 5 5 src/plugin/external.rs:611
catalog 5 0 crates/ocs_model/src/catalog/linetypes.rs:132
i18n 2 3 crates/ocs_base/src/i18n.rs:257
display 4 0 crates/ocs_model/src/display/hatch_patterns.rs:27
output 4 0 src/output/plot_device.rs:214
config 2 0 crates/ocs_base/src/config.rs:34
rest 2 0 src/rest.rs:55
src/bin/ocs_launcher.rs 2 0 src/bin/ocs_launcher.rs:46
entity_creation 1 0 src/entity_creation.rs:251
gpu_backend 1 0 src/gpu_backend.rs:228
input 1 0 src/input/trackpad.rs:34
mcp 0 1 src/mcp.rs:270
paths 1 0 crates/ocs_base/src/paths.rs:40
schema_validation 1 0 crates/ocs_base/src/schema_validation.rs:11
snap 0 1 src/snap.rs:3933
src/lib.rs 1 0 src/lib.rs:30
sysinfo 1 0 crates/ocs_base/src/sysinfo.rs:23

Thanks

Contributors whose merged work improved a measure in this release, in alphabetical order:

Pick up a cleanup

Document an unsafe block

Add a // SAFETY: comment saying why the block is sound (for an unsafe fn, a # Safety doc section). Size: comments only.

Apply an automatic clippy fix

These warnings have a fix clippy can apply. One lint per pull request keeps the diff easy to review: cargo clippy --fix --workspace --all-targets -- -A clippy::all -W <lint>, then check the diff. Size: mechanical.

Lint Fixable warnings
clippy::chunks_exact_to_as_chunks 119
clippy::useless_conversion 27
clippy::unnecessary_cast 18
clippy::items_after_test_module 16
clippy::unnecessary_lazy_evaluations 13
clippy::needless_borrow 12
clippy::cloned_ref_to_slice_refs 12
clippy::bool_assert_comparison 11
clippy::collapsible_match 10
clippy::needless_return 9

Add tests here

Core-layer files with the most lines no test runs, weighted by how often the file changed in the last 28 days, so a test here protects code that is actively changing. Size: one test or more.

File Lines not run by tests Coverage Changes in 28 days
src/scene/mod.rs 1,934 78.5% 187
src/scene/modify.rs 1,254 53.0% 24
src/scene/convert/tess.rs 672 61.9% 30
src/modules/draw/draw/hatch.rs 1,053 42.4% 18
src/scene/entity.rs 353 89.1% 53
src/snap.rs 717 78.8% 21
src/scene/cache/block_cache.rs 456 86.7% 33
src/scene/convert/tessellate.rs 589 78.0% 25
src/modules/draw/modify/fillet.rs 1,019 55.1% 14
src/modules/annotate/mleader_cmd.rs 936 7.4% 15

No tests yet: 41 core-layer files are not run by any test. The largest:

Discuss splitting a long function

Larger work: propose a split in a discussion first.

History

Measure v2026.48 main@8bed4f27f v2026.47
Upward dependencies (files) 21 199 196
Upward module pairs 1 32 32
Modules that use each other 10 26 26
Files over 3,000 lines 61 62 60
Functions over 150 lines 592 586 553
Top-level Message variants — — —
Process-wide mutable statics 320 — —
thread_local! blocks 76 — —
unwrap/expect/panic! in production code 670 671 663
unwrap/expect/panic! in file import and export (src/io) 0 25 15
unsafe without a SAFETY note 101 109 108
Clippy warnings 1,182 1,152 29
Compiler warnings 214 203 3
Files rustfmt would change 716 546 394
Line coverage of the core layers (%) 63.3 62.8 62.1
Test functions (#[test]) 8,810 8,617 7,830
RustSec advisories in dependencies 19 19 36
Crates in the dependency tree 851 851 809

Why these measures

  • Upward dependencies (files): Lower layers that do not reach up can be built, tested and reused without the app.
  • Upward module pairs: Each pair is a place where a lower layer depends on a higher one.
  • Modules that use each other: Two modules that depend on each other change together and cannot be understood apart.
  • Files over 3,000 lines: Large files are hard to review and collect merge conflicts.
  • Functions over 150 lines: Long functions are hard to test and to change safely.
  • Top-level Message variants: One enum for every event couples all features to the app module.
  • Process-wide mutable statics: State held for the whole process is shared by every drawing and every test, so tests that touch it run one at a time; it belongs in the session or the app state (TARGET.md, step 3).
  • thread_local! blocks: Per-thread state is hidden from the code that calls it and differs between the UI thread and the workers; it belongs in the session or the app state (TARGET.md, step 3).
  • unwrap/expect/panic! in production code: A panic closes the app and can lose unsaved work; returning an error lets the user recover.
  • unwrap/expect/panic! in file import and export (src/io): A damaged or unusual drawing, or a failed export, should give an error message, never a crash.
  • unsafe without a SAFETY note: A SAFETY note records why the code is sound, so later changes keep it sound.
  • Clippy warnings: Clippy's default lints catch common mistakes and unclear code.
  • Compiler warnings: With zero warnings, a new one is noticed.
  • Files rustfmt would change: One format means diffs show only real changes.
  • Line coverage of the core layers (%): Every line a test runs is a line a change cannot silently break.
  • Test functions (#[test]): Tests let contributors change code without fear of breaking it.
  • RustSec advisories in dependencies: Known vulnerable or unmaintained crates.
  • Crates in the dependency tree: Each crate adds build time and supply-chain risk.

Clone this wiki locally