korbit-ai[bot] commented on code in PR #34330:
URL: https://github.com/apache/superset/pull/34330#discussion_r2233249477
##########
superset-frontend/packages/superset-ui-chart-controls/src/utils/getColorFormatters.ts:
##########
@@ -99,50 +106,67 @@ export const getColorFunction = (
};
break;
case Comparator.GreaterThan:
- comparatorFunction = (value: number, allValues: number[]) =>
- value > targetValue!
- ? { cutoffValue: targetValue!, extremeValue: Math.max(...allValues) }
- : false;
+ if (typeof targetValue === 'number')
+ comparatorFunction = (value: number, allValues: number[]) =>
Review Comment:
### Unhandled Non-numeric Target Value <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Missing default assignment for comparatorFunction when targetValue is not a
number
###### Why this matters
If targetValue is not a number, comparatorFunction remains undefined,
leading to a runtime error when the function is called.
###### Suggested change ∙ *Feature Preview*
Add an else clause to handle non-numeric values:
```typescript
case Comparator.GreaterThan:
if (typeof targetValue === 'number') {
comparatorFunction = (value: number, allValues: number[]) =>
value > targetValue!
? {
cutoffValue: targetValue!,
extremeValue: Math.max(...allValues),
}
: false;
} else {
comparatorFunction = () => false;
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f377e6e7-9630-46b0-9daf-d9aad495e6a2/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f377e6e7-9630-46b0-9daf-d9aad495e6a2?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f377e6e7-9630-46b0-9daf-d9aad495e6a2?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f377e6e7-9630-46b0-9daf-d9aad495e6a2?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f377e6e7-9630-46b0-9daf-d9aad495e6a2)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:95f9c3dc-0e1e-48d9-ae34-d73c4c598163 -->
[](95f9c3dc-0e1e-48d9-ae34-d73c4c598163)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]