bito-code-review[bot] commented on code in PR #36760:
URL: https://github.com/apache/superset/pull/36760#discussion_r2636969119
##########
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx:
##########
@@ -58,7 +78,7 @@ class AdhocMetricOption extends PureComponent {
onMetricEdit,
columns,
savedMetricsOptions,
- savedMetric,
+ savedMetric = {} as SavedMetricTypeDef,
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Invalid Default Value</b></div>
<div id="fix">
Defaulting to `{}` creates an invalid `SavedMetricTypeDef` object (missing
`metric_name`), which can cause issues in AdhocMetricPopoverTrigger expecting
required fields. Provide a proper default with required properties to maintain
type safety.
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/fc3fe76/.cursor/rules/dev-standard.mdc#L120">dev-standard.mdc:120</a>
</li>
</ul>
</details>
<small><i>Code Review Run #fbef04</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
##########
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx:
##########
@@ -18,12 +18,32 @@
*/
import { PureComponent } from 'react';
import PropTypes from 'prop-types';
+import { Metric } from '@superset-ui/core';
import { OptionControlLabel } from
'src/explore/components/controls/OptionControls';
import { DndItemType } from 'src/explore/components/DndItemType';
+import { Datasource } from 'src/explore/types';
+import { ISaveableDatasource } from 'src/SqlLab/components/SaveDatasetModal';
import columnType from './columnType';
import AdhocMetric from './AdhocMetric';
import savedMetricType from './savedMetricType';
import AdhocMetricPopoverTrigger from './AdhocMetricPopoverTrigger';
+import { savedMetricType as SavedMetricTypeDef } from './types';
+
+interface AdhocMetricOptionProps {
+ adhocMetric: AdhocMetric;
+ onMetricEdit: (newMetric: Metric, oldMetric: Metric) => void;
+ onRemoveMetric?: (index: number) => void;
+ columns?: { column_name: string; type: string }[];
+ savedMetricsOptions?: SavedMetricTypeDef[];
+ savedMetric?: SavedMetricTypeDef | Record<string, never>;
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Type Safety Violation</b></div>
<div id="fix">
The type `SavedMetricTypeDef | Record<string, never>` allows an empty object
`{}` which doesn't satisfy `SavedMetricTypeDef` (missing required
`metric_name`), leading to type safety issues. Since the rules emphasize proper
TypeScript without type assertions, simplify to `SavedMetricTypeDef` and ensure
defaults provide valid objects.
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/fc3fe76/.cursor/rules/dev-standard.mdc#L16">dev-standard.mdc:16</a>
</li>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/fc3fe76/AGENTS.md#L57">AGENTS.md:57</a>
</li>
</ul>
</details>
<small><i>Code Review Run #fbef04</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]