Skip to content

refactor: Codacy code quality + dal-python 2026.9.5 - #3

Merged
wegamekinglc merged 3 commits into
mainfrom
chore/codacy-quality-dal-upgrade
Sep 5, 2026
Merged

refactor: Codacy code quality + dal-python 2026.9.5#3
wegamekinglc merged 3 commits into
mainfrom
chore/codacy-quality-dal-upgrade

Conversation

@wegamekinglc

Copy link
Copy Markdown
Owner

Summary

Two logical commits from one working session:

  1. refactor: satisfy Codacy Biome rules and reduce backend complexity — code style + cyclomatic complexity per the repo's Codacy setup (bandit + Biome engines in .codacy.yml).
  2. chore(deps): bump dal-python from 2026.8.14 to 2026.9.5 — latest published wheel; upstream exposes quote risk through the public Python API and unifies the quote-risk GIL execution protocol.

Code quality (commit 1)

Frontend — new frontend/biome.json (picked up by Codacy's Biome engine; line width 100 matching backend ruff), @biomejs/biome devDependency + npm run lint/format scripts:

  • safe fixes across 56 files (formatting, import organization)
  • useExhaustiveDependencies: split target/family effects + memoized invalidateCanonicalRequest in CurveLabQuoteAuthoring (identical invalidation behavior)
  • removed overridden duplicate .topbar background in styles.css
  • build stepper renders as semantic ol/li (a11y)
  • style/noDescendingSpecificity disabled: all 48 flagged selector pairs are ancestor-disjoint → pure false positives

Backend — radon grades, behavior-preserving extraction (error payloads and native call order unchanged):

function before after
curve_risk._execute_risk_run F (51) C (16)
dal_gateway.price_curve_lab_trades E (34) C (11)
curve_risk._admit_risk_run E (33) C (12)
schemas._validate_topology D (23) A (4)
curve_risk._runtime_dependencies C (19) guard helpers

No D/E/F-graded functions remain (average A 2.86). Frontend cognitive complexity: 0 functions above 15.

Dependency bump (commit 2)

pyproject.toml / requirements.txt floor raised to dal-python>=2026.9.5, uv.lock regenerated, README version note updated.

Verification

  • ruff clean, bandit clean, biome check clean (56 files)
  • Backend: pytest 491 passed (fake dal) + 2 passed native-marked
  • Frontend: vitest 101 passed, tsc -b + vite build pass
  • Real native binding (2026.9.5): app.native_runtime preflight OK; async valuation with full AAD greeks; single-curve calibration completed; Curve Lab draft → build → version → risk run succeeded with trade-to-node matrix AVAILABLE / NATIVE_AAD_PARITY_VERIFIED
  • Playwright e2e: 4 passed on the native path (17 canned-only specs skip by design), 21 passed with DAL_PLAYWRIGHT_TEST_BACKEND=1

Frontend (Biome 2.5.12, governed by new frontend/biome.json which the
Codacy Biome engine picks up):
- add biome.json (line width 100 matching backend ruff, double quotes,
  semicolons) and npm lint/format scripts; @biomejs/biome devDependency
- apply safe fixes across 56 files: formatting + import organization
- CurveLabQuoteAuthoring: split the target/family effect and memoize
  invalidateCanonicalRequest so useExhaustiveDependencies passes with
  identical invalidation behavior
- styles.css: drop the overridden duplicate .topbar background
- CurveLabWorkspace: render the build stepper as semantic ol/li
  (a11y useAriaPropsSupportedByRole/useSemanticElements)
- disable style/noDescendingSpecificity: every flagged selector pair is
  ancestor-disjoint, so the rule only yields false positives here

Backend (radon cyclomatic complexity, behavior-preserving extraction):
- curve_risk._execute_risk_run F(51) -> C(16): _RiskRunContext plus
  trade-to-node / jacobian / composed / key-rate / parallel helpers
- curve_risk._admit_risk_run E(33) -> C(12): import-lineage, runtime
  document/axes, fixing-compatibility and method-fallback guards
- curve_risk._runtime_dependencies C(19) -> guard helpers
- dal_gateway.price_curve_lab_trades E(34) -> C(11): pricing-curves,
  xccy-market and aad-rows helpers; native call order unchanged
- schemas CurveDraftDocumentInputV2._validate_topology D(23) -> A(4):
  populated / unique-keys / mode-roles / component-assignments split

Verified: ruff clean, bandit clean, biome check clean (56 files),
pytest 491 passed, vitest 101 passed, tsc + vite build pass.
Latest published wheel; upstream exposes quote risk through the public
Python API and unifies the quote-risk GIL execution protocol.

Verified against the real native binding:
- app.native_runtime preflight passes
- pytest 491 passed (fake dal) + 2 passed (native-marked)
- async valuation completes with full AAD greeks
- single-curve calibration completes and persists the curve DTO
- Curve Lab draft -> build -> version -> risk run succeeds;
  trade-to-node matrix AVAILABLE via NATIVE_AAD_PARITY_VERIFIED
- Playwright e2e: 4 passed on the native path, 21 passed with the
  canned test backend
Copilot AI lite review requested due to automatic review settings September 5, 2026 09:04
@codacy-production

codacy-production Bot commented Sep 5, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity · 6 duplication

Metric Results
Complexity 8
Duplication 6

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The backend refactors in Curve Lab risk/pricing are substantial and warrant careful human verification despite appearing behavior-preserving.

Pull request overview

This PR aligns the repo with Codacy’s configured quality gates (notably Biome for the frontend and complexity reductions in the backend) while also bumping the backend’s dal-python dependency to 2026.9.5.

Changes:

  • Add Biome configuration + scripts/devDependency and apply automated formatting/lint fixes across the frontend (including tests and minor a11y-related markup/CSS tweaks).
  • Refactor backend Curve Lab pricing/risk code to reduce complexity via helper extraction while keeping behavior stable.
  • Bump backend dal-python minimum version to 2026.9.5 and regenerate lockfiles.
File summaries
File Description
README.md Updates documented dal-python minimum version.
frontend/vite.config.ts Import order/style-only cleanup.
frontend/tests/unit/valuation_panel.test.tsx Biome-driven formatting updates.
frontend/tests/unit/setup.ts Import order/style-only cleanup.
frontend/tests/unit/quote_bump_panel.test.tsx Biome-driven formatting updates.
frontend/tests/unit/models.test.tsx Biome-driven formatting updates.
frontend/tests/unit/curves_quote_integration.test.tsx Biome-driven formatting updates.
frontend/tests/unit/curve_run.test.tsx Biome-driven formatting updates.
frontend/tests/unit/curve_lab_workspace.test.tsx Biome-driven formatting updates.
frontend/tests/unit/curve_lab_utils.test.ts Biome-driven formatting updates.
frontend/tests/unit/curve_lab_quote_authoring.test.tsx Biome-driven formatting updates.
frontend/tests/unit/curve_builder_utils.test.ts Biome-driven formatting updates.
frontend/tests/unit/api_client.test.ts Biome-driven formatting updates.
frontend/tests/e2e/valuation.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/trades.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/product_builder.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/portfolios.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/models.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/dashboard.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/curves.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/curve_lab_workspace.spec.ts Biome-driven formatting updates.
frontend/tests/e2e/app.spec.ts Biome-driven formatting updates.
frontend/src/styles.css Formatting + lifecycle list styling and minor cleanup.
frontend/src/pages/Valuations.tsx Promise chain formatting/readability cleanup.
frontend/src/pages/Trades.tsx Import consolidation + small readability refactor.
frontend/src/pages/ProductBuilder.tsx Promise chain formatting/readability cleanup.
frontend/src/pages/Portfolios.tsx Promise chain formatting/readability cleanup.
frontend/src/pages/Models.tsx Promise chain formatting/readability cleanup.
frontend/src/pages/Dashboard.tsx Promise chain formatting/readability cleanup.
frontend/src/pages/Curves.tsx Formatting + minor readability refactors.
frontend/src/pages/CurveRun.tsx Formatting + minor readability refactors.
frontend/src/main.tsx Formatting-only tweak (trailing comma).
frontend/src/format.ts Function signature formatting/readability.
frontend/src/curves/visualization.ts Formatting-only refactor.
frontend/src/curves/examples.ts Formatting-only refactor.
frontend/src/curves/curveLabUtils.ts Formatting-only refactor.
frontend/src/curves/curveLabRegistry.ts Formatting-only refactor.
frontend/src/curves/curveBuilderUtils.ts Formatting-only refactor.
frontend/src/components/ValuationPanel.tsx Formatting-only refactor.
frontend/src/components/QuoteBumpPanel.tsx Formatting-only refactor.
frontend/src/components/MatrixHeatmap.tsx Formatting-only refactor.
frontend/src/components/FitPlot.tsx Formatting-only refactor.
frontend/src/components/CurvePreview.tsx Formatting-only refactor.
frontend/src/components/CurveLabQuoteAuthoring.tsx Hook dependency/invalidation refactor + formatting.
frontend/src/components/CalibrationLifecycle.tsx Type-cast formatting cleanup.
frontend/src/App.tsx Promise chain formatting/readability cleanup.
frontend/src/api/client.ts Formatting-only refactor (no API shape change observed).
frontend/playwright.config.ts Formatting-only refactor.
frontend/package.json Adds Biome scripts + devDependency.
frontend/package-lock.json Locks Biome dependency tree.
frontend/biome.json New Biome configuration for Codacy/local lint/format.
backend/uv.lock Locks dal-python to 2026.9.5 and updates metadata.
backend/requirements.txt Raises dal-python floor to 2026.9.5.
backend/pyproject.toml Raises dal-python floor to 2026.9.5.
backend/app/services/dal_gateway.py Extracts pricing helpers to reduce complexity.
backend/app/services/curve_risk.py Large refactor into helper functions/context objects to reduce complexity.
backend/app/schemas/curve_lab.py Refactors topology validation into smaller helpers.
Review details

Files not reviewed (1)

  • frontend/package-lock.json: Generated file
  • Files reviewed: 56/58 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

- run ruff format over the refactored backend modules (CI gate)
- Valuations: prefer-nullish-coalescing for the error fallback
- split _validate_mode_roles per build mode (Lizard CCN 13 -> 4)
- split _key_rate_dv01 success path (Lizard CCN 10 -> 4)
- extract CurveBuilderStepper and derived-state helpers out of
  CurveLabWorkspace (Lizard CCN 9 -> 4)
@wegamekinglc
wegamekinglc merged commit 26aaf32 into main Sep 5, 2026
4 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.

2 participants