[internal] Fix maintainability and reliability issues raised by SonarQube#268
Open
dozro wants to merge 11 commits intoSableClient:devfrom
Open
[internal] Fix maintainability and reliability issues raised by SonarQube#268dozro wants to merge 11 commits intoSableClient:devfrom
dozro wants to merge 11 commits intoSableClient:devfrom
Conversation
fixed sonarqube issues: - React props should be read-only (typescript:S6759) - Spacing between inline elements should be explicit (typescript:S6772)
fixed issues: - typescript:S7781 - typescript:S6759
- typescript:S7773 - typescript:S4158
- Number static methods and properties should be preferred over global equivalents (typescript:S7773) - Function references should not be passed directly to iterator methods (typescript:S7727) - Strings should use "replaceAll()" instead of "replace()" with global regex (typescript:S7781) - "RegExp.exec()" should be preferred over "String.match()" (typescript:S6594) - React props should be read-only (typescript:S6759) - Prefer `Math.min()` to simplify ternary expressions (typescript:S7766) - Optional property declarations should not use both '?' and 'undefined' syntax (typescript:S4782) - Built-in constructors should be called consistently with or without "new" (typescript:S7723)
- Built-in constructors should be called consistently with or without "new" (typescript:S7723) - Negated conditions should be avoided when an else clause is present (typescript:S7735) - Strings should use "replaceAll()" instead of "replace()" with global regex (typescript:S7781) - Use ".some()" instead of ".filter().length" checks or ".find()" for existence testing (typescript:S7754) - React props should be read-only (typescript:S6759) - Number static methods and properties should be preferred over global equivalents (typescript:S7773) - The return value of "useState" should be destructured and named symmetrically (typescript:S6754) - Optional chaining should be preferred (typescript:S6582) - Arrays used only for existence checks should be Sets (typescript:S7776) - Unicode-aware string methods should be used for proper character handling (typescript:S7758)
- Unicode-aware string methods should be used for proper character handling (typescript:S7758)
- Strings should use "replaceAll()" instead of "replace()" with global regex (typescript:S7781) - Existence checks should use ".includes()" instead of ".indexOf()" or ".lastIndexOf()" (typescript:S7765) - Use "globalThis" instead of "window", "self", or "global" (typescript:S7764)
- Use "globalThis" instead of "window", "self", or "global" (typescript:S7764) - Unicode-aware string methods should be used for proper character handling (typescript:S7758)
- Unicode-aware string methods should be used for proper character handling (typescript:S7758)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request focuses on code consistency and minor improvements across multiple UI components. The main themes are enforcing immutability by using
Readonlyfor props, improving array creation patterns for clarity, and standardizing string and regex manipulation withreplaceAll. There are also minor logic and readability enhancements.Immutability and Type Safety Improvements:
Converted component props to use
Readonly<T>in various components (e.g.,SetupVerification,RecoveryKeyDisplay,RenderMessageContentInternal,EmojiSidebar,StickerSidebar,EmojiGroupHolder,EmojiBoard,MenuOptions,EventItem,RenderBody,PreviewImage,PreviewVideo,UploadCardRenderer,DescriptionEditor) to ensure props are not mutated and improve type safety.Array Handling and Code Consistency:
Replaced
Array.from(Array(...).keys())withArray.from(new Array(...).keys())for clarity and consistency in date and time pickers.Simplified array creation in
EmoticonAutocompleteusing spread syntax for better readability.String and Regex Handling Enhancements:
replaceAllfor string and regex replacement operations to improve code clarity and future-proofing. This affects recovery key display, custom HTML processing, and reply formatting.Logic and Readability Improvements:
Number.parseIntinstead ofparseIntfor explicitness and consistency.Math.minfor clarity.Type and Optional Parameter Cleanups:
undefinedfrom optional type definitions for cleaner code.These changes collectively improve code maintainability, readability, and type safety without introducing major feature changes.
Type of change
Checklist: