Skip to content

chore: make the workspace clippy-clean under -D warnings - #64

Merged
Sean-Koval merged 8 commits into
mainfrom
work/code-clippy-clean
Sep 19, 2026
Merged

Sean-Koval merged 8 commits into
mainfrom
work/code-clippy-clean

Conversation

@Sean-Koval

Copy link
Copy Markdown
Contributor

Closes #34

Pure refactor: makes cargo clippy --workspace --all-targets --all-features -- -D warnings pass and makes CI, release and just clippy run that one command. No numeric behaviour, public Rust API, or Python-visible name/signature changes.

Warning counts

Counted as unique (lint, file, line, column) diagnostics from cargo clippy --workspace --all-targets --all-features --message-format=json (clippy 1.88.0), de-duplicated across the lib/test builds of the same file. (The issue's "~160 warning lines" counts the duplicated text output.)

unique warnings
Before (origin/main @ d3e6dfa) 143
After clippy --fix 108
After this PR 0

Fixed vs. allowed per lint

lint before fixed allowed
legacy_numeric_constants 35 35 0
type_complexity 29 29 (type aliases) 0
too_many_arguments 21 1 (params struct) 20
needless_range_loop 16 16 0
uninlined_format_args 8 8 0
manual_range_contains 6 6 0
manual_range_patterns 3 3 0
manual_clamp 2 2 0
iter_cloned_collect 2 2 0
useless_conversion 2 2 0
get_first 2 2 0
default_constructed_unit_structs 2 2 0
unnecessary_cast 2 2 0
useless_vec 2 2 0
unnecessary_to_owned 1 0 1
large_enum_variant, unnecessary_map_or, manual_memcpy, let_and_return, vec_init_then_push, needless_borrow, derivable_impls, len_zero, field_reassign_with_default, redundant_closure 1 each (10) 10 0
total 143 122 21

Every #[allow] added (21)

No crate/module-level allows; clippy.toml thresholds untouched.

#[allow(clippy::too_many_arguments)]:

item reason
openquant::hyperparameter_tuning::randomized_search (8) Public search API: grid_search's arguments plus n_iter and seed; signature kept stable
openquant::labeling::get_events (8) Mirrors the mlfinlab get_events signature
pyopenquant::helpers::build_ohlcv_columns (8) Takes the raw OHLCV columns it validates into OhlcvColumns; a params struct would duplicate that type
pyopenquant #[pyfunction]s: cla_allocate, data_clean_ohlcv, data_quality_report, data_align_calendar, hcaa_allocate, labeling_triple_barrier_events, labeling_triple_barrier_labels, labeling_meta_labels, labeling_get_events, pipeline_run_mid_frequency_pipeline, portfolio_allocate_with_solution, sb_fit_predict_classifier, sb_fit_predict_regressor, sr_estimate_strategy_failure_probability, sbt_generate_ou_paths, sbt_run_synthetic_otr_workflow, sbt_search_optimal_trading_rule (17) Python keyword signature

#[allow(clippy::unnecessary_to_owned)]:

item reason
MicrostructuralFeaturesGenerator::new_from_csv, tick_num_iter field init The generator owns its thresholds (vec::IntoIter<usize>); clippy's borrowed-iterator suggestion would add a lifetime to a public type

Notable hand fixes

  • needless_range_loop: rewritten with iter_mut().enumerate() / .take().skip(); iteration order and float accumulation order are unchanged. sampling::num_concurrent_events deliberately uses .take(end+1).skip(start) rather than a slice so start > end_idx stays a no-op instead of becoming a panic.
  • manual_clamp in bet_sizing::discrete_signal: f64::clamp(-1.0, 1.0) matches the old if-chain, including NaN pass-through.
  • large_enum_variant: private etf_trick::Source::InMemory now holds a Box<InMemoryTables>.
  • too_many_arguments: private-to-the-crate helper pyopenquant::helpers::build_labeling_events takes a new LabelingEventArgs struct.
  • New public aliases (transparent, no signature change): bet_sizing::{ReserveBetSizeRow, MixtureParams}, cross_validation::TrainTestSplit.

Test files

No expected value, tolerance or fixture changed, and no test was removed or ignored. However, --all-targets -D warnings also lints tests, so clippy --fix made semantically identical rewrites inside some test assertions, e.g. assert!(b >= -1.0 && b <= 1.0) -> assert!((-1.0..=1.0).contains(&b)), matches!(bin, -1 | 0 | 1) -> matches!(bin, -1..=1), pca[0].len() >= 1 -> !pca[0].is_empty(), inlined format args in assertion messages, vec![..] -> [..] for two literal lists (same values). Please review crates/openquant/tests/ with that in mind.

CI alignment

ci.yml, release.yml and justfile now all run exactly:

cargo clippy --workspace --all-targets --all-features -- -D warnings

The clippy.toml comment quotes that command (now true); docs/publishing.md and the docs-site local-build page were updated to match.

Caveat: workflows use dtolnay/rust-toolchain@stable (unpinned), and this was verified locally on clippy 1.88.0 only. A newer stable clippy may have additional lints; CI on this PR is the check for that.

Commands run (local, rustc/clippy 1.88.0)

command result
cargo clippy --fix --workspace --all-targets --all-features --allow-dirty 143 -> 108 unique warnings
cargo clippy --workspace --all-targets --all-features -- -D warnings Finished dev profile, exit 0
cargo test --workspace exit 0; 40 test binaries/doc-test sets ok, 172 passed, 0 failed (the pre-existing #[ignore] on test_sadf_test is untouched)
cargo fmt --check exit 0

Not run: Python bindings build (maturin) / Python tests, docs-site API-drift gate, benches (compiled under clippy only).

Observed but intentionally not changed

  • MicrostructuralFeaturesGenerator::new_from_csv seeds current_bar_tick from tick_num_series.first() but the iterator is not advanced, so the first threshold appears to be consumed twice in get_features. Looks like a possible porting bug vs. mlfinlab's generator; behaviour left as is.

🤖 Generated with Claude Code

Sean-Koval and others added 5 commits September 18, 2026 18:53
Resolves clippy::type_complexity in files whose only change is the alias.
Aliases are transparent, so no Rust or Python signature changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cargo clippy --fix output plus hand fixes: legacy numeric constants,
needless_range_loop (iteration order and float summation order kept),
manual_clamp, manual_memcpy, vec_init_then_push, large_enum_variant
(private etf_trick::Source boxed), field_reassign_with_default, and the
remaining type_complexity aliases in files that also had other fixes.
One targeted allow: unnecessary_to_owned in MicrostructuralFeaturesGenerator.

No numeric behaviour or public API changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Private pyopenquant helper build_labeling_events now takes a
LabelingEventArgs struct. Public openquant functions and #[pyfunction]s
whose argument list is the public/Python signature get a targeted
#[allow(clippy::too_many_arguments)] with a one-line reason.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ci.yml, release.yml and the justfile now all run
cargo clippy --workspace --all-targets --all-features -- -D warnings,
which makes the clippy.toml comment true; docs updated to match.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CI's floating stable (1.98) flags six sites that 1.88 does not:
unnecessary_unwrap in cla and codependence, manual_is_multiple_of in
hpc_parallel, a dead assignment in streaming_hpc, needless_range_loop in a
bench and useless_conversion in a test. All are behavior-preserving; the
codependence match keeps a NaN correlation on the bivariate branch, and
progress_every is validated > 0 so is_multiple_of is equivalent.

Add rust-toolchain.toml so -D warnings is reproducible.

Refs #34

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Sean-Koval

Copy link
Copy Markdown
Contributor Author

Review follow-up (pushed b003c10):

  • CI's floating stable (1.98) flagged 6 sites that local 1.88 could not see. Fixed, all behavior-preserving: unnecessary_unwrap ×2 (cla, codependence — the match keeps a NaN correlation on the bivariate branch as before), manual_is_multiple_of (hpc_parallel; progress_every is validated > 0 so it is equivalent), a dead assignment to sell_volume (streaming_hpc), needless_range_loop in a bench, useless_conversion in a test.
  • Added rust-toolchain.toml pinning 1.98.1 so -D warnings cannot break unrelated PRs when a new Rust ships.
  • Verified locally on 1.98.1: clippy -D warnings exit 0 (also clean on 1.88), cargo fmt --check clean, cargo test --workspace 243 passed / 0 failed / 1 ignored.
  • Test-file edits reviewed: all are equivalent rewrites; no expected value, tolerance or fixture changed.
  • docs-checks fails here for a reason unrelated to this PR (depth-1 checkout breaks the freshness gate); the fix is in chore: adopt ai-dlc and record the production-readiness backlog #62. Update this branch after chore: adopt ai-dlc and record the production-readiness backlog #62 merges.
  • Real bug found during review, deliberately not changed here: PurgedKFold::split leaks: test window starts at the first test label's END time #65 (PurgedKFold purge window).

The prose changed (the clippy line), so the freshness gate will rightly ask
for a re-read once CI checks out full history (#62). Re-ran the page's Rust
commands on this branch: build, the fast test suite (243 passed), fmt, clippy
-D warnings and the API-drift check all succeed as written.

Refs #34

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Conflict in microstructural_features.rs: keep main's fix for the duplicated
first tick threshold (#67) and move the unnecessary_to_owned allow onto the
let binding that now holds the to_vec() call.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Sean-Koval
Sean-Koval merged commit 995da1b into main Sep 19, 2026
7 checks passed
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.

Make the workspace clippy-clean and use one lint flag set everywhere

1 participant