Repository navigation
refactor(chart): split the screener market scan into its steps - #1484
Merged
Merged
Conversation
Refactor lane. Signal: an oversized function. `scan_market` (crates/moon-chart/src/auto_figures/scan.rs:402) was 171 lines from signature to closing brace, over the 120-line limit (CONTRIBUTING.md sets none). It now reads as its steps and is 44 lines; the parts moved into private helpers in the same file: - `run_rows` (scan.rs:461): per-row closed bars, history check and detector run, returning the scanned/short counts. - `pick_rows` (scan.rs:516): each row's `take` plus the cross-row twin pass. - `keep_lines` (scan.rs:551): placing the picked lines against the last price and marking their events. - `mark_confluence` (scan.rs:604): the confluence pass over kept lines. - `best_and_nearest` (scan.rs:625): the best event and the nearest line. Lines: one 171-line function -> 44 + 5 helpers (one file, about 100 insertions, 20 deletions). Signature, visibility, iteration order and arithmetic are unchanged; the scratch buffers `runs` and `kept` are still cleared in `scan_market` at the same point as before; no test file changed. Tests that cover it: `cargo test -p moon-chart auto_figures::scan` (scan/tests.rs, 22 tests, every one calls `scan_market`; green before and after the edit), the whole `cargo test -p moon-chart` (453 passed), and the dependent's screener tests `cargo test -p moon-ui-gpui --bin moonterminal screener::` (62 passed). `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --all` are clean. Reviewer: Codex. Its one finding: the first draft moved `kept.clear()` past the detector loop, so after a panic caught by unwinding, the result's derived `Debug` could show the previous market's kept lines. The clear was moved back to its original position before the commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor lane.
Signal: an oversized function.
scan_market(crates/moon-chart/src/auto_figures/scan.rs:402) was 171 lines from
signature to closing brace, over the 120-line limit (CONTRIBUTING.md sets
none). It now reads as its steps and is 44 lines; the parts moved into
private helpers in the same file:
run_rows(scan.rs:461): per-row closed bars, history check anddetector run, returning the scanned/short counts.
pick_rows(scan.rs:516): each row'stakeplus the cross-row twinpass.
keep_lines(scan.rs:551): placing the picked lines against the lastprice and marking their events.
mark_confluence(scan.rs:604): the confluence pass over kept lines.best_and_nearest(scan.rs:625): the best event and the nearest line.Lines: one 171-line function -> 44 + 5 helpers (one file, about 100
insertions, 20 deletions). Signature, visibility, iteration order and
arithmetic are unchanged; the scratch buffers
runsandkeptare stillcleared in
scan_marketat the same point as before; no test filechanged.
Tests that cover it:
cargo test -p moon-chart auto_figures::scan(scan/tests.rs, 22 tests, every one calls
scan_market; green before andafter the edit), the whole
cargo test -p moon-chart(453 passed), and thedependent's screener tests
cargo test -p moon-ui-gpui --bin moonterminal screener::(62 passed).cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --allare clean.Reviewer: Codex. Its one finding: the first draft moved
kept.clear()past the detector loop, so after a panic caught by unwinding, the
result's derived
Debugcould show the previous market's kept lines.The clear was moved back to its original position before the commit.