bito-code-review[bot] commented on code in PR #36760:
URL: https://github.com/apache/superset/pull/36760#discussion_r2637366369
##########
superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx:
##########
@@ -99,21 +103,38 @@ function coerceAdhocMetrics(value) {
const emptySavedMetric = { metric_name: '', expression: '' };
// TODO: use typeguards to distinguish saved metrics from adhoc metrics
-const getMetricsMatchingCurrentDataset = (value, columns, savedMetrics) =>
- ensureIsArray(value).filter(metric => {
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+const getMetricsMatchingCurrentDataset = (value: any, columns: any,
savedMetrics: any) =>
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ensureIsArray(value).filter((metric: any) => {
if (typeof metric === 'string' || metric.metric_name) {
return savedMetrics?.some(
- savedMetric =>
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (savedMetric: any) =>
savedMetric.metric_name === metric ||
savedMetric.metric_name === metric.metric_name,
);
}
return columns?.some(
- column =>
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (column: any) =>
!metric.column || metric.column.column_name === column.column_name,
);
});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Type Safety Violation</b></div>
<div id="fix">
The changes add 'as any' type assertions and eslint disables for
@typescript-eslint/no-explicit-any, violating the development standards that
explicitly prohibit 'any' types in favor of proper TypeScript typing. The TODO
comment suggests using typeguards to distinguish metric types, but instead
'any' is used throughout, which defeats TypeScript's type safety. Consider
importing typeguards from @superset-ui/core/src/query/types/Metric and defining
proper union types for parameters.
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/fcf2d2f/.cursor/rules/dev-standard.mdc#L15">dev-standard.mdc:15</a>
</li>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/fcf2d2f/AGENTS.md#L56">AGENTS.md:56</a>
</li>
</ul>
</details>
<small><i>Code Review Run #14ed29</i></small>
</div><div>
<div id="suggestion">
<div id="issue"><b>Replace `any` types with proper TypeScript types</b></div>
<div id="fix">
The function parameters use `any` types, violating the project's TypeScript
standards that prohibit `any` in favor of proper types. Consider defining
interfaces for the parameters to enhance type safety.
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/35a90de/AGENTS.md#L57">AGENTS.md:57</a>
</li>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/35a90de/.cursor/rules/dev-standard.mdc#L16">dev-standard.mdc:16</a>
</li>
</ul>
</details>
<small><i>Code Review Run #09aefd</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]