Function $trimTextContentFromAnchor
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
export function $trimTextContentFromAnchor(
editor: LexicalEditor,
anchor: Point,
delCount: number,
): void {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function $patchStyleText
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
export function $patchStyleText(
selection: BaseSelection,
patch: Record<
string,
| string
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function $sliceSelectedTextNodeContent
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
export function $sliceSelectedTextNodeContent(
selection: BaseSelection,
textNode: TextNode,
): LexicalNode {
const anchorAndFocus = selection.getStartEndPoints();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function $patchStyleText
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $patchStyleText(
selection: BaseSelection,
patch: Record<
string,
| string
File lexical-node.ts
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Function $trimTextContentFromAnchor
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $trimTextContentFromAnchor(
editor: LexicalEditor,
anchor: Point,
delCount: number,
): void {
Function $sliceSelectedTextNodeContent
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $sliceSelectedTextNodeContent(
selection: BaseSelection,
textNode: TextNode,
): LexicalNode {
const anchorAndFocus = selection.getStartEndPoints();
Avoid deeply nested control flow statements. Open
if (anchorOffset < remaining) {
anchorOffset = currentNodeSize;
}
Avoid deeply nested control flow statements. Open
if (isSelected && splitStart === 0) {
const [excessNode] = currentNode.splitText(splitStart, splitEnd);
excessNode.remove();
} else {
const [, excessNode] = currentNode.splitText(splitStart, splitEnd);