bito-code-review[bot] commented on code in PR #37218:
URL: https://github.com/apache/superset/pull/37218#discussion_r2729073064
##########
superset-frontend/packages/superset-ui-core/src/validator/validateTimeComparisonRangeValues.ts:
##########
@@ -22,13 +22,13 @@ import { t } from '@apache-superset/core';
import { ensureIsArray } from '../utils';
export const validateTimeComparisonRangeValues = (
- timeRangeValue?: any,
- controlValue?: any,
-) => {
+ timeRangeValue?: unknown,
+ controlValue?: unknown,
+): string[] => {
const isCustomTimeRange = timeRangeValue === ComparisonTimeRangeType.Custom;
- const isCustomControlEmpty = controlValue?.every(
- (val: any) => ensureIsArray(val).length === 0,
- );
+ const isCustomControlEmpty =
+ Array.isArray(controlValue) &&
+ controlValue.every((val: unknown) => ensureIsArray(val).length === 0);
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Logic Bug in Null Handling</b></div>
<div id="fix">
The logic for `isCustomControlEmpty` incorrectly handles null/undefined
`controlValue`, treating them as not empty, but tests expect them to trigger
validation errors like empty arrays do. This changes observable behavior for
null/undefined inputs.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
const isCustomControlEmpty =
!Array.isArray(controlValue) ||
controlValue.every((val: unknown) => ensureIsArray(val).length === 0);
````
</div>
</details>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/84c1224/.cursor/rules/dev-standard.mdc#L16">dev-standard.mdc:16</a>
</li>
<li>
Rule Violated: <a
href="https://github.com/apache/superset/blob/84c1224/AGENTS.md#L78">AGENTS.md:78</a>
</li>
</ul>
</details>
<small><i>Code Review Run #0ea597</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]