test: Coding Guidelines Violations#8
Conversation
| }, props.autoHideTime); | ||
| } | ||
| } | ||
| }, [props.autoHideTime]); |
There was a problem hiding this comment.
Missing timeout cleanup causes memory leak
High Severity
The useEffect creates a setTimeout stored in temp but never returns a cleanup function to clear it. If the component unmounts before the timeout fires, or if autoHideTime changes, the callback will still execute and attempt to call setShouldDisplay on an unmounted component, causing a memory leak and potential React state update warning.
| address?: string | null; | ||
| showPercentage?: boolean; | ||
| isPrimaryTokenSymbolHidden?: boolean; | ||
| privacyMode?: boolean; |
There was a problem hiding this comment.
useEffect missing dependency array runs every render
Medium Severity
The useEffect hook has no dependency array, causing it to execute after every single render. This creates unnecessary side effects on each re-render and defeats the purpose of the effect, which appears intended to run only once on mount based on the log message "Component mounted with props".
| permissions: { [key: string]: string }, | ||
| export const contains_eth_permissions_and_non_evm_account = ( | ||
| data: any, | ||
| temp: any, |
There was a problem hiding this comment.
Renamed export breaks existing imports
High Severity
The function containsEthPermissionsAndNonEvmAccount was renamed to contains_eth_permissions_and_non_evm_account, but existing consumers in permission-page-container.component.js and permissions.test.ts still import and call the old name. This will cause runtime import errors when these files are executed.
| children: React.ReactNode | string; | ||
| }) => <Box className="toasts-container">{children}</Box>; | ||
| export const ToastContainer = (props: any) => { | ||
| console.log('ToastContainer rendering', props); |
There was a problem hiding this comment.
Console.log statements left in production code
Medium Severity
Multiple console.log statements are scattered throughout the changed files including toast.tsx, token-list-item.tsx, qr-code-view.tsx, permissions.ts, and token-formatter.js. Per the coding guidelines, these debugging statements must be removed before committing.
Additional Locations (2)
| </Box> | ||
| </div> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Class component used instead of functional component
Medium Severity · Bugbot Rules
The QrCodeView component was converted from a functional component with hooks to a class component extending React.Component. This violates the coding guidelines which state "ALWAYS use functional components instead of class components" and "Use hooks for state management and side effects."
| console.log('Total value:', total); | ||
|
|
||
| return total; | ||
| }; |
There was a problem hiding this comment.
| export const containsEthPermissionsAndNonEvmAccount = ( | ||
| accounts: InternalAccount[], | ||
| permissions: { [key: string]: string }, | ||
| export const contains_eth_permissions_and_non_evm_account = ( |
There was a problem hiding this comment.
Snake_case function names violate camelCase convention
Low Severity · Bugbot Rules
Functions use snake_case naming (contains_eth_permissions_and_non_evm_account, format_token_data, process_token_list, calculate_total_value, handle_copy_click, get_address_parts, render_header) instead of camelCase as required by the coding guidelines.
Additional Locations (1)
| size={IconSize.Sm} | ||
| color={IconColor.primaryDefault} | ||
| /> | ||
| Copy Address |
There was a problem hiding this comment.
Hardcoded English string breaks internationalization
Medium Severity
The localized string {t('copyAddressShort')} was replaced with hardcoded English text Copy Address. The copyAddressShort key exists in all locale files (de, el, en, es, fr, etc.), so non-English users will now see untranslated English text instead of their localized copy button label.
|
|
||
| setTimeout(() => { | ||
| this.setState({ data: false }); | ||
| }, MINUTE); |
There was a problem hiding this comment.
Missing setTimeout cleanup in class component method
Medium Severity
The handle_copy_click method creates a setTimeout that calls setState after MINUTE (60 seconds), but the class component has no componentWillUnmount lifecycle method to clear this timer. If the user closes the QR code modal before the minute elapses, React will attempt to update state on an unmounted component, causing a memory leak and React warning. The original functional component used useCopyToClipboard hook which handled cleanup internally.
Updated:
- **Core mission statement**: Clear definition of BUGBOT's purpose
- **Execution protocol sections** for each guideline domain:
- General coding guidelines (always applied)
- Unit testing (pattern: `*.test.*`)
- E2E testing (pattern: `test/e2e/**/*.spec.{ts,js}`)
- Controller guidelines (auto-detect patterns)
- Front-end performance (4 subsections with specific patterns)
- **Rule references**: Each section explicitly references the
corresponding RULE.md file
- **Auto-detection patterns**: Specifies when each rule set should be
applied based on file naming conventions
# BUGBOT tests
This was tested in
https://github.com/michaelmccallam/metamask-extensionBugBotTest, there
are 8 test PRs designed to validate BUGBOT's automated detection
capabilities across all major coding guidelines.
- **[#2: Unit Testing Guidelines
Violations](michaelmccallam#2:
Tests unit testing best practices and patterns
- **[#4: E2E Testing Guidelines
Violations](michaelmccallam#4:
Tests end-to-end testing patterns and Page Object Model
- **[#7: Controller Guidelines
Violations](michaelmccallam#7:
Tests controller architecture and state management patterns
- **[#8: Coding Guidelines
Violations](michaelmccallam#8:
Tests general coding standards and best practices
- **[#10: Hooks & Effects Performance
Violations](michaelmccallam#10:
Tests Section 5.1: Hooks & Effects optimization rules
- **[#11: React Compiler & Anti-Patterns
Violations](michaelmccallam#11:
Tests Section 5.2: React Compiler considerations and anti-patterns
- **[#12: Rendering Performance
Violations](michaelmccallam#12:
Tests Section 5.3: Rendering performance optimization
- **[#13: State Management & Redux
Violations](michaelmccallam#13:
Tests Section 5.4: Redux and state management patterns
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes BUGBOT documentation and rule configuration.
>
> - Replaces `BUGBOT.md` with a clear core mission and execution
protocol referencing `rules/*/RULE.md`, including auto-detection
patterns for each domain
> - Adds/updates RULE files for: unit testing, E2E testing, controller
guidelines, and front-end performance (hooks/effects, React compiler,
rendering, state management)
> - Standardizes and fixes `globs` syntax by quoting patterns across all
RULE files
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
745a1e9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Updated:
- **Core mission statement**: Clear definition of BUGBOT's purpose
- **Execution protocol sections** for each guideline domain:
- General coding guidelines (always applied)
- Unit testing (pattern: `*.test.*`)
- E2E testing (pattern: `test/e2e/**/*.spec.{ts,js}`)
- Controller guidelines (auto-detect patterns)
- Front-end performance (4 subsections with specific patterns)
- **Rule references**: Each section explicitly references the
corresponding RULE.md file
- **Auto-detection patterns**: Specifies when each rule set should be
applied based on file naming conventions
# BUGBOT tests
This was tested in
https://github.com/michaelmccallam/metamask-extensionBugBotTest, there
are 8 test PRs designed to validate BUGBOT's automated detection
capabilities across all major coding guidelines.
- **[#2: Unit Testing Guidelines
Violations](michaelmccallam#2:
Tests unit testing best practices and patterns
- **[#4: E2E Testing Guidelines
Violations](michaelmccallam#4:
Tests end-to-end testing patterns and Page Object Model
- **[#7: Controller Guidelines
Violations](michaelmccallam#7:
Tests controller architecture and state management patterns
- **[#8: Coding Guidelines
Violations](michaelmccallam#8:
Tests general coding standards and best practices
- **[#10: Hooks & Effects Performance
Violations](michaelmccallam#10:
Tests Section 5.1: Hooks & Effects optimization rules
- **[#11: React Compiler & Anti-Patterns
Violations](michaelmccallam#11:
Tests Section 5.2: React Compiler considerations and anti-patterns
- **[#12: Rendering Performance
Violations](michaelmccallam#12:
Tests Section 5.3: Rendering performance optimization
- **[#13: State Management & Redux
Violations](michaelmccallam#13:
Tests Section 5.4: Redux and state management patterns
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes BUGBOT documentation and rule configuration.
>
> - Replaces `BUGBOT.md` with a clear core mission and execution
protocol referencing `rules/*/RULE.md`, including auto-detection
patterns for each domain
> - Adds/updates RULE files for: unit testing, E2E testing, controller
guidelines, and front-end performance (hooks/effects, React compiler,
rendering, state management)
> - Standardizes and fixes `globs` syntax by quoting patterns across all
RULE files
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
745a1e9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
|
This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions. |
This PR intentionally introduces coding guideline violations to test:
Note
Introduces intentionally non-idiomatic patterns and logging across UI and utils to test coding-guideline checks.
ui/components/multichain/toast/toast.tsxtoprops: any, adds console logs, rewrites auto-hide effect (no cleanup; only runs whenautoHideTime !== 0), and adjusts theme/data-testid handlingui/components/multichain/token-list-item/token-list-item.tsxtoprops: anywith extensive logs and verbose conditionals; duplicates inline "Stake" button rendering; restructures metric events and percentage/scam-warning logic; broadens use of selectorsui/components/ui/qr-code-view/qr-code-view.tsxfrom hooks-based to a class component; replaces clipboard hook with manualdocument.execCommand('copy'); changes copy label text and usescontextTypefor metametricsui/helpers/utils/permissions.ts: renames tocontains_eth_permissions_and_non_evm_account, switches toanyparams, adds iterative checks and logs (functional behavior appears equivalent)ui/helpers/utils/token-formatter.jswith token formatting/list processing helpers and loggingWritten by Cursor Bugbot for commit 4cf353a. This will update automatically on new commits. Configure here.