bito-code-review[bot] commented on code in PR #41511:
URL: https://github.com/apache/superset/pull/41511#discussion_r3489470127
##########
superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx:
##########
@@ -104,9 +104,9 @@ jest.mock(
}),
);
-jest.mock('lodash/debounce', () => ({
- __esModule: true,
- default: (fuc: Function) => fuc,
+jest.mock('lodash', () => ({
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-435: Mock Target Module Mismatch</b></div>
<div id="fix">
The mock targets `'lodash'` but the component imports `debounce` from
`'lodash-es'` (index.tsx:48). Jest mocking is by exact module specifier, so
this mock has no effect on the component's import. The test's intent to disable
debouncing is defeated. Use `'lodash-es'` to match the component's import. (See
also: [CWE-435](https://cwe.mitre.org/data/definitions/435.html))
</div>
</div>
<small><i>Code Review Run #638b83</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/components/Chart/DrillBy/DrillBySubmenu.test.tsx:
##########
@@ -37,11 +37,14 @@ import { DrillBySubmenu, DrillBySubmenuProps } from
'./DrillBySubmenu';
const { form_data: defaultFormData } = chartQueries[sliceId];
-jest.mock('lodash/debounce', () => (fn: Function & { debounce: Function }) => {
- // eslint-disable-next-line no-param-reassign
- fn.debounce = jest.fn();
- return fn;
-});
+jest.mock('lodash', () => ({
+ ...jest.requireActual('lodash'),
+ debounce: (fn: Function & { debounce: Function }) => {
+ // eslint-disable-next-line no-param-reassign
+ fn.debounce = jest.fn();
+ return fn;
+ },
+}));
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-435: Mock Targets Wrong Import Path</b></div>
<div id="fix">
The mock at line 40 targets `'lodash'` but `DrillBySubmenu.tsx:46` imports
`debounce` from `'lodash-es'`. Since Jest module mocking is specifier-precise,
mocking `'lodash'` has no effect on `'lodash-es'` imports — the real lodash-es
debounce is loaded and the mock is bypassed entirely. (See also:
[CWE-435](https://cwe.mitre.org/data/definitions/435.html))
</div>
</div>
<small><i>Code Review Run #638b83</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/DataTableControl/FilterInput.test.tsx:
##########
@@ -19,9 +19,9 @@
import { render, screen, userEvent } from 'spec/helpers/testing-library';
import { FilterInput } from '.';
-jest.mock('lodash/debounce', () => ({
- __esModule: true,
- default: (fuc: Function) => fuc,
+jest.mock('lodash', () => ({
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Import path mismatch between mock and component</b></div>
<div id="fix">
The mock targets `lodash` but the component imports debounce from
`lodash-es` (see index.tsx line 23). The mock won't intercept the call, so
tests run with real debounced behavior instead of the synchronous passthrough.
Update the mock path to `lodash-es`.
</div>
</div>
<small><i>Code Review Run #638b83</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]