Skip to content

chore: code quality housekeeping — remove deprecated props, fix types - #612

Merged
alfredo1996 merged 2 commits into
release/2.0from
chore/code-quality-housekeeping
Apr 26, 2026
Merged

chore: code quality housekeeping — remove deprecated props, fix types#612
alfredo1996 merged 2 commits into
release/2.0from
chore/code-quality-housekeeping

Conversation

@alfredo1996

@alfredo1996 alfredo1996 commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Summary

Tech debt cleanup across the codebase.

Deprecated colorThresholds removal

  • Removed colorThresholds prop from BarChart, LineChart, PieChart, SingleValueChart
  • Removed colorThresholds from PluginProps interface and all 4 plugin components
  • Removed thresholds parameter from resolveItemColor() (was unused by all callers)
  • Cleaned up parseColorThresholds and resolveThresholdColor imports from chart-utils
  • Converted 3 SingleValueChart tests from colorThresholds to stylingRules
  • The card-container migration path (resolveStylingConfig) is preserved for old dashboards

Type safety improvements

  • Removed as any cast in sunburst sort function (use undefined instead of null)
  • Documented the any in chart-plugin-registry transformWithMapping (cross-package boundary)

Impact

  • 11 files changed, net -33 lines of dead code removed
  • Build passes, all tests pass (82 component, 165 app)
  • No behavioral changes — only code cleanup

Test plan

  • Component tests: 82/82 passed (1251 tests)
  • App tests: 165/165 passed (2194 tests)
  • Build passes (TypeScript type-check clean)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Refactor

    • Removed deprecated colorThresholds configuration from charts; use stylingRules for all styling instead
  • Improvements

    • Enhanced type safety for sunburst chart sorting behavior
  • Documentation

    • Updated API documentation for chart plugin configuration

alfredorubin96 and others added 2 commits April 25, 2026 04:36
The legacy colorThresholds prop (JSON string) was replaced by
stylingRules (structured StylingRule[]) in v0.8. The migration
happens at the card-container level via resolveStylingConfig(),
so the backward-compat code in chart components was dead weight.

Removed from:
- BarChart, LineChart, PieChart, SingleValueChart (prop + parsing)
- resolveItemColor() — removed unused thresholds parameter
- chart-utils.ts — removed ColorThreshold/resolveThresholdColor imports
- All 4 plugin components — removed colorThresholds pass-through
- PluginProps interface — removed colorThresholds field

Tests:
- Converted 3 SingleValueChart threshold tests to use stylingRules
- Removed 1 test for invalid JSON colorThresholds (prop no longer exists)

The card-container still reads chartOptions.colorThresholds for
migration purposes — old dashboards are auto-upgraded on load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ing type

sunburst-chart.tsx:
- Replace \`sort: sortFn as any\` with proper typed \`undefined\` for no-sort
- Change null to undefined for ECharts compatibility

chart-plugin-registry.ts:
- Keep \`any\` for transformWithMapping mapping parameter but add
  documentation explaining it's due to cross-package type boundary
  (ColumnMapping lives in component/, registry in app/)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

Walkthrough

This PR removes the deprecated colorThresholds prop from plugin and chart components across both app and component packages, migrating color styling logic to the newer stylingRules and paramValues approach. Documentation for ChartPluginConfig.transformWithMapping is clarified, and a minor type improvement is applied to SunburstChart.sort handling.

Changes

Cohort / File(s) Summary
Registry & Documentation
app/src/lib/plugin/chart-plugin-registry.ts
JSDoc clarification for transformWithMapping describing expected ColumnMapping structure and justifying loose any type to avoid component package dependency.
Plugin Component Cleanup
app/src/plugins/bar/component.tsx, app/src/plugins/line/component.tsx, app/src/plugins/pie/component.tsx, app/src/plugins/single-value/component.tsx
Removes colorThresholds prop destructuring and forwarding to underlying chart components.
Plugin Props Interface
app/src/plugins/utils.ts
Removes optional colorThresholds?: string declaration from exported PluginProps interface.
Chart Component Cleanup
component/src/charts/bar-chart.tsx, component/src/charts/line-chart.tsx, component/src/charts/pie-chart.tsx, component/src/charts/single-value-chart.tsx
Removes deprecated colorThresholds prop, associated JSON parsing logic (parseColorThresholds import), and forwards color resolution to stylingRules/paramValues only.
Utility Function Update
component/src/charts/chart-utils.ts
Simplifies resolveItemColor signature by removing thresholds parameter; color resolution now depends solely on stylingRules with paramValues optional.
Type Improvement
component/src/charts/sunburst-chart.tsx
Changes sort field type from any to "desc" | "asc" | undefined and passes undefined instead of null when sort prop is "none".
Test Updates
component/src/charts/__tests__/single-value-chart.test.tsx
Migrates three color-threshold tests from legacy colorThresholds JSON to new stylingRules rule-based objects; removes invalid-JSON resilience test and reformats invocations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PR #278: Introduces stylingRules and paramValues as the replacement mechanism for threshold-based coloring that this PR fully migrates to.
  • PR #378: Modifies plugin-driven renderer that forwards props to plugins; directly affected by removal of colorThresholds from PluginProps.
  • PR #428: Modifies ChartPluginConfig interface; related to registry updates in this PR.

Suggested labels

tech-debt, pkg:component, pkg:app, area:charts

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: removing deprecated props and fixing types across multiple chart components, which aligns with the detailed changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/code-quality-housekeeping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
component/src/charts/chart-utils.ts (1)

342-355: ⚠️ Potential issue | 🟡 Minor

Stale doc comment — drop the "legacy color thresholds" mention.

The JSDoc still advertises "legacy color thresholds as fallback", but that path is gone. Trim it so the contract matches the implementation.

📝 Proposed fix
 /**
- * Resolve a color for a numeric value using styling rules (preferred) or
- * legacy color thresholds as fallback. Returns undefined when no rule matches.
+ * Resolve a color for a numeric value using styling rules.
+ * Returns undefined when no rule matches or no rules are provided.
  */
 export function resolveItemColor(
   value: number,
   stylingRules: StylingRule[] | undefined,
   paramValues?: Record<string, unknown>,
 ): string | undefined {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@component/src/charts/chart-utils.ts` around lines 342 - 355, Update the JSDoc
for resolveItemColor to remove the mention of "legacy color thresholds as
fallback" so the comment matches the implementation; specifically edit the
comment above the function resolveItemColor (and adjust any wording referencing
fallback behavior) to state that it resolves a color using styling rules and
returns undefined when no rule matches, referencing resolveStylingRuleColor if
needed.
🧹 Nitpick comments (2)
component/src/charts/single-value-chart.tsx (1)

128-128: Drop the redundant alias.

thresholdColor is just textColor under a stale name. Inline it at the use site to keep the cleanup honest.

♻️ Proposed fix
-  const thresholdColor = textColor;
-
   const trendColor =
-              style={{ color: thresholdColor ?? autoContrast ?? undefined }}
+              style={{ color: textColor ?? autoContrast ?? undefined }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@component/src/charts/single-value-chart.tsx` at line 128, Remove the
redundant alias declaration "const thresholdColor = textColor;" and replace all
uses of thresholdColor within the SingleValueChart component (or surrounding
scope) with textColor directly; ensure no other logic depends on thresholdColor
and delete the declaration to avoid the stale name.
component/src/charts/sunburst-chart.tsx (1)

147-147: Remove redundant type assertion on line 147.

sortFn is already inferred as "asc" | "desc" | undefined from lines 59–60, so the explicit cast adds no type safety and masks future type changes. Drop it.

Proposed change
-          sort: sortFn as "desc" | "asc" | undefined,
+          sort: sortFn,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@component/src/charts/sunburst-chart.tsx` at line 147, The property assignment
uses a redundant type assertion: remove the "as \"desc\" | \"asc\" | undefined"
cast and just pass sortFn directly (i.e., change sort: sortFn as ... to sort:
sortFn) because sortFn is already inferred as "asc" | "desc" | undefined (see
the variable declaration around lines 59–60); update the object where sort is
set (the place using sort: ...) and run the TypeScript check to ensure no
further casts are needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@component/src/charts/chart-utils.ts`:
- Around line 342-355: Update the JSDoc for resolveItemColor to remove the
mention of "legacy color thresholds as fallback" so the comment matches the
implementation; specifically edit the comment above the function
resolveItemColor (and adjust any wording referencing fallback behavior) to state
that it resolves a color using styling rules and returns undefined when no rule
matches, referencing resolveStylingRuleColor if needed.

---

Nitpick comments:
In `@component/src/charts/single-value-chart.tsx`:
- Line 128: Remove the redundant alias declaration "const thresholdColor =
textColor;" and replace all uses of thresholdColor within the SingleValueChart
component (or surrounding scope) with textColor directly; ensure no other logic
depends on thresholdColor and delete the declaration to avoid the stale name.

In `@component/src/charts/sunburst-chart.tsx`:
- Line 147: The property assignment uses a redundant type assertion: remove the
"as \"desc\" | \"asc\" | undefined" cast and just pass sortFn directly (i.e.,
change sort: sortFn as ... to sort: sortFn) because sortFn is already inferred
as "asc" | "desc" | undefined (see the variable declaration around lines 59–60);
update the object where sort is set (the place using sort: ...) and run the
TypeScript check to ensure no further casts are needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 56553b7e-1010-4a38-aa0b-be2cbcb89e31

📥 Commits

Reviewing files that changed from the base of the PR and between 848a19d and 86e77d0.

📒 Files selected for processing (13)
  • app/src/lib/plugin/chart-plugin-registry.ts
  • app/src/plugins/bar/component.tsx
  • app/src/plugins/line/component.tsx
  • app/src/plugins/pie/component.tsx
  • app/src/plugins/single-value/component.tsx
  • app/src/plugins/utils.ts
  • component/src/charts/__tests__/single-value-chart.test.tsx
  • component/src/charts/bar-chart.tsx
  • component/src/charts/chart-utils.ts
  • component/src/charts/line-chart.tsx
  • component/src/charts/pie-chart.tsx
  • component/src/charts/single-value-chart.tsx
  • component/src/charts/sunburst-chart.tsx
💤 Files with no reviewable changes (5)
  • app/src/plugins/utils.ts
  • app/src/plugins/single-value/component.tsx
  • app/src/plugins/line/component.tsx
  • app/src/plugins/pie/component.tsx
  • app/src/plugins/bar/component.tsx

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
71.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@alfredo1996
alfredo1996 merged commit f2b996e into release/2.0 Apr 26, 2026
10 of 13 checks passed
@alfredo1996
alfredo1996 deleted the chore/code-quality-housekeeping branch May 16, 2026 17:47
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