BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/lexical/core/LexicalSelection.ts

Summary

Maintainability
F
1 mo
Test Coverage

File LexicalSelection.ts has 2308 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.
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 6 days to fix

    Function insertText has a Cognitive Complexity of 149 (exceeds 5 allowed). Consider refactoring.
    Open

      insertText(text: string): void {
        const anchor = this.anchor;
        const focus = this.focus;
        const format = this.format;
        const style = this.style;
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 days to fix

    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 insertText has 285 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      insertText(text: string): void {
        const anchor = this.anchor;
        const focus = this.focus;
        const format = this.format;
        const style = this.style;
    Severity: Major
    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 day to fix

      Function modify has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

        modify(
          alter: 'move' | 'extend',
          isBackward: boolean,
          granularity: 'character' | 'word' | 'lineboundary',
        ): void {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 day to fix

      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 $internalResolveSelectionPoint has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

      function $internalResolveSelectionPoint(
        dom: Node,
        offset: number,
        lastPoint: null | PointType,
        editor: LexicalEditor,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 day to fix

      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 getTextContent has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

        getTextContent(): string {
          const nodes = this.getNodes();
          if (nodes.length === 0) {
            return '';
          }
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 day to fix

      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 deleteCharacter has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

        deleteCharacter(isBackward: boolean): void {
          const wasCollapsed = this.isCollapsed();
          if (this.isCollapsed()) {
            const anchor = this.anchor;
            let anchorNode: TextNode | ElementNode | null = anchor.getNode();
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 7 hrs to fix

      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 updateDOMSelection has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      export function updateDOMSelection(
        prevSelection: BaseSelection | null,
        nextSelection: BaseSelection | null,
        editor: LexicalEditor,
        domSelection: Selection,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 6 hrs to fix

      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 formatText has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        formatText(formatType: TextFormatType): void {
          if (this.isCollapsed()) {
            this.toggleFormat(formatType);
            // When changing format, we should stop composition
            $setCompositionKey(null);
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 5 hrs to fix

      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 updateDOMSelection has 124 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function updateDOMSelection(
        prevSelection: BaseSelection | null,
        nextSelection: BaseSelection | null,
        editor: LexicalEditor,
        domSelection: Selection,
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

        Function modify has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          modify(
            alter: 'move' | 'extend',
            isBackward: boolean,
            granularity: 'character' | 'word' | 'lineboundary',
          ): void {
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

          Function extract has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            extract(): Array<LexicalNode> {
              const selectedNodes = this.getNodes();
              const selectedNodesLength = selectedNodes.length;
              const lastIndex = selectedNodesLength - 1;
              const anchor = this.anchor;
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

          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 $internalResolveSelectionPoint has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function $internalResolveSelectionPoint(
            dom: Node,
            offset: number,
            lastPoint: null | PointType,
            editor: LexicalEditor,
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

            Function formatText has 94 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              formatText(formatType: TextFormatType): void {
                if (this.isCollapsed()) {
                  this.toggleFormat(formatType);
                  // When changing format, we should stop composition
                  $setCompositionKey(null);
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

              Function $updateSelectionResolveTextNodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

              function $updateSelectionResolveTextNodes(selection: RangeSelection): void {
                const anchor = selection.anchor;
                const anchorOffset = anchor.offset;
                const focus = selection.focus;
                const focusOffset = focus.offset;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

              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 deleteCharacter has 90 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                deleteCharacter(isBackward: boolean): void {
                  const wasCollapsed = this.isCollapsed();
                  if (this.isCollapsed()) {
                    const anchor = this.anchor;
                    let anchorNode: TextNode | ElementNode | null = anchor.getNode();
              Severity: Major
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                Function $updateElementSelectionOnCreateDeleteNode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                export function $updateElementSelectionOnCreateDeleteNode(
                  selection: RangeSelection,
                  parentNode: LexicalNode,
                  nodeOffset: number,
                  times = 1,
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                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

                RangeSelection has 28 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class RangeSelection implements BaseSelection {
                  format: number;
                  style: string;
                  anchor: PointType;
                  focus: PointType;
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                  Function insertNodes has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    insertNodes(nodes: Array<LexicalNode>): void {
                      if (nodes.length === 0) {
                        return;
                      }
                      if (this.anchor.key === 'root') {
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                    Function resolveSelectionPointOnBoundary has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function resolveSelectionPointOnBoundary(
                      point: TextPointType,
                      isBackward: boolean,
                      isCollapsed: boolean,
                    ): void {
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                    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 insertNodes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                      insertNodes(nodes: Array<LexicalNode>): void {
                        if (nodes.length === 0) {
                          return;
                        }
                        if (this.anchor.key === 'root') {
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                    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 $wrapInlineNodes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function $wrapInlineNodes(nodes: LexicalNode[]) {
                      // We temporarily insert the topLevelNodes into an arbitrary ElementNode,
                      // since insertAfter does not work on nodes that have no parent (TO-DO: fix that).
                      const virtualRoot = $createParagraphNode();
                    
                    
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                    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 getTextContent has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      getTextContent(): string {
                        const nodes = this.getNodes();
                        if (nodes.length === 0) {
                          return '';
                        }
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                      Function getNodes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getNodes(): Array<LexicalNode> {
                          const cachedNodes = this._cachedNodes;
                          if (cachedNodes !== null) {
                            return cachedNodes;
                          }
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                      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 $internalCreateRangeSelection has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function $internalCreateRangeSelection(
                        lastSelection: null | BaseSelection,
                        domSelection: Selection | null,
                        editor: LexicalEditor,
                        event: UIEvent | Event | null,
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                        Function $updateElementSelectionOnCreateDeleteNode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function $updateElementSelectionOnCreateDeleteNode(
                          selection: RangeSelection,
                          parentNode: LexicalNode,
                          nodeOffset: number,
                          times = 1,
                        Severity: Major
                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                          Function $updateSelectionResolveTextNodes has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function $updateSelectionResolveTextNodes(selection: RangeSelection): void {
                            const anchor = selection.anchor;
                            const anchorOffset = anchor.offset;
                            const focus = selection.focus;
                            const focusOffset = focus.offset;
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                            Function $internalCreateRangeSelection has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function $internalCreateRangeSelection(
                              lastSelection: null | BaseSelection,
                              domSelection: Selection | null,
                              editor: LexicalEditor,
                              event: UIEvent | Event | null,
                            Severity: Minor
                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                            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 $updateCaretSelectionForUnicodeCharacter has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function $updateCaretSelectionForUnicodeCharacter(
                              selection: RangeSelection,
                              isBackward: boolean,
                            ): void {
                              const anchor = selection.anchor;
                            Severity: Minor
                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                            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 resolveSelectionPointOnBoundary has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function resolveSelectionPointOnBoundary(
                              point: TextPointType,
                              isBackward: boolean,
                              isCollapsed: boolean,
                            ): void {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

                              Function moveSelectionPointToSibling has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function moveSelectionPointToSibling(
                                point: PointType,
                                node: LexicalNode,
                                parent: ElementNode,
                                prevSibling: LexicalNode | null,
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                              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 extract has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                extract(): Array<LexicalNode> {
                                  const selectedNodes = this.getNodes();
                                  const selectedNodesLength = selectedNodes.length;
                                  const lastIndex = selectedNodesLength - 1;
                                  const anchor = this.anchor;
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                Function getNodes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  getNodes(): Array<LexicalNode> {
                                    const cachedNodes = this._cachedNodes;
                                    if (cachedNodes !== null) {
                                      return cachedNodes;
                                    }
                                Severity: Minor
                                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                  Function $internalResolveSelectionPoints has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function $internalResolveSelectionPoints(
                                    anchorDOM: null | Node,
                                    anchorOffset: number,
                                    focusDOM: null | Node,
                                    focusOffset: number,
                                  Severity: Minor
                                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                    Function deleteLine has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      deleteLine(isBackward: boolean): void {
                                        if (this.isCollapsed()) {
                                          // Since `domSelection.modify('extend', ..., 'lineboundary')` works well for text selections
                                          // but doesn't properly handle selections which end on elements, a space character is added
                                          // for such selections transforming their anchor's type to 'text'
                                    Severity: Minor
                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                    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 $splitNodeAtPoint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function $splitNodeAtPoint(
                                      node: LexicalNode,
                                      offset: number,
                                    ): [parent: ElementNode, offset: number] {
                                      const parent = node.getParent();
                                    Severity: Minor
                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                      Function moveSelectionPointToSibling has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      export function moveSelectionPointToSibling(
                                        point: PointType,
                                        node: LexicalNode,
                                        parent: ElementNode,
                                        prevSibling: LexicalNode | null,
                                      Severity: Minor
                                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                        Function $removeSegment has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                        function $removeSegment(
                                          node: TextNode,
                                          isBackward: boolean,
                                          offset: number,
                                        ): void {
                                        Severity: Minor
                                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                          Function applyDOMRange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                            applyDOMRange(range: StaticRange): void {
                                              const editor = getActiveEditor();
                                              const currentEditorState = editor.getEditorState();
                                              const lastSelection = currentEditorState._selection;
                                              const resolvedSelectionPoints = $internalResolveSelectionPoints(
                                          Severity: Minor
                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                            Function $wrapInlineNodes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                            function $wrapInlineNodes(nodes: LexicalNode[]) {
                                              // We temporarily insert the topLevelNodes into an arbitrary ElementNode,
                                              // since insertAfter does not work on nodes that have no parent (TO-DO: fix that).
                                              const virtualRoot = $createParagraphNode();
                                            
                                            
                                            Severity: Minor
                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                              Function $internalResolveSelectionPoints has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              function $internalResolveSelectionPoints(
                                                anchorDOM: null | Node,
                                                anchorOffset: number,
                                                focusDOM: null | Node,
                                                focusOffset: number,
                                              Severity: Minor
                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                              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 forwardDeletion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                forwardDeletion(
                                                  anchor: PointType,
                                                  anchorNode: TextNode | ElementNode,
                                                  isBackward: boolean,
                                                ): boolean {
                                              Severity: Minor
                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                              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 $splitNodeAtPoint has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              function $splitNodeAtPoint(
                                                node: LexicalNode,
                                                offset: number,
                                              ): [parent: ElementNode, offset: number] {
                                                const parent = node.getParent();
                                              Severity: Minor
                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                              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 selectPointOnNode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              function selectPointOnNode(point: PointType, node: LexicalNode): void {
                                                let key = node.__key;
                                                let offset = point.offset;
                                                let type: 'element' | 'text' = 'element';
                                                if ($isTextNode(node)) {
                                              Severity: Minor
                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                              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 $updateCaretSelectionForUnicodeCharacter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                              function $updateCaretSelectionForUnicodeCharacter(
                                                selection: RangeSelection,
                                                isBackward: boolean,
                                              ): void {
                                                const anchor = selection.anchor;
                                              Severity: Minor
                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                Function $normalizeSelectionPointsForBoundaries has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                function $normalizeSelectionPointsForBoundaries(
                                                  anchor: PointType,
                                                  focus: PointType,
                                                  lastSelection: null | BaseSelection,
                                                ): void {
                                                Severity: Minor
                                                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                  Consider simplifying this complex logical expression.
                                                  Open

                                                      if (
                                                        isLineBreakNode ||
                                                        ($isDecoratorNode(node) && node.isInline()) ||
                                                        ($isElementNode(node) && node.isInline()) ||
                                                        $isTextNode(node) ||
                                                  Severity: Major
                                                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                    Consider simplifying this complex logical expression.
                                                    Open

                                                        } else if (
                                                          this.isCollapsed() &&
                                                          startOffset === 0 &&
                                                          (firstNode.isSegmented() ||
                                                            firstNode.isToken() ||
                                                    Severity: Major
                                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                      Consider simplifying this complex logical expression.
                                                      Open

                                                          if (
                                                            !isBackward &&
                                                            // Delete forward handle case
                                                            ((anchor.type === 'element' &&
                                                              $isElementNode(anchorNode) &&
                                                      Severity: Major
                                                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                        Consider simplifying this complex logical expression.
                                                        Open

                                                            if (
                                                              this.isCollapsed() &&
                                                              startOffset === firstNodeTextLength &&
                                                              (firstNode.isSegmented() ||
                                                                firstNode.isToken() ||
                                                        Severity: Major
                                                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                                                          Function $removeSegment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                          function $removeSegment(
                                                            node: TextNode,
                                                            isBackward: boolean,
                                                            offset: number,
                                                          ): void {
                                                          Severity: Minor
                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 55 mins to fix

                                                          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 updateDOMSelection has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                            prevSelection: BaseSelection | null,
                                                            nextSelection: BaseSelection | null,
                                                            editor: LexicalEditor,
                                                            domSelection: Selection,
                                                            tags: Set<string>,
                                                          Severity: Major
                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 50 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                      if (descendant === null) {
                                                                        resolvedElement = child;
                                                                      } else {
                                                                        child = descendant;
                                                                        resolvedElement = $isElementNode(child)
                                                            Severity: Major
                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                              Function $internalMakeRangeSelection has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                                anchorKey: NodeKey,
                                                                anchorOffset: number,
                                                                focusKey: NodeKey,
                                                                focusOffset: number,
                                                                anchorType: 'text' | 'element',
                                                              Severity: Minor
                                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                          } else if (node === lastNode) {
                                                                            text = isBefore
                                                                              ? text.slice(0, focusOffset)
                                                                              : text.slice(0, anchorOffset);
                                                                          }
                                                                Severity: Major
                                                                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                              if (node === lastNode) {
                                                                                if (
                                                                                  anchor.type !== 'element' ||
                                                                                  focus.type !== 'element' ||
                                                                                  focus.offset === anchor.offset
                                                                  Severity: Major
                                                                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                                if ($isElementNode(firstValidNode)) {
                                                                                  firstValidNode.selectStart();
                                                                                } else {
                                                                                  firstValidNode.getParentOrThrow().selectStart();
                                                                                }
                                                                    Severity: Major
                                                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                  if ($isElementNode(lastValidNode)) {
                                                                                    lastValidNode.selectEnd();
                                                                                  } else {
                                                                                    lastValidNode.getParentOrThrow().selectEnd();
                                                                                  }
                                                                      Severity: Major
                                                                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                        Avoid deeply nested control flow statements.
                                                                        Open

                                                                                  if (
                                                                                    anchorNode.is(focusNode) ||
                                                                                    (isBackward && offset !== 0) ||
                                                                                    (!isBackward && offset !== textContentSize)
                                                                                  ) {
                                                                        Severity: Major
                                                                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                          Function $internalResolveSelectionPoints has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                          Open

                                                                            anchorDOM: null | Node,
                                                                            anchorOffset: number,
                                                                            focusDOM: null | Node,
                                                                            focusOffset: number,
                                                                            editor: LexicalEditor,
                                                                          Severity: Minor
                                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                            Function applySelectionTransforms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                            Open

                                                                            export function applySelectionTransforms(
                                                                              nextEditorState: EditorState,
                                                                              editor: LexicalEditor,
                                                                            ): void {
                                                                              const prevEditorState = editor.getEditorState();
                                                                            Severity: Minor
                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                            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

                                                                            Avoid deeply nested control flow statements.
                                                                            Open

                                                                                        if (!firstAndLastElementsAreEqual) {
                                                                                          insertionTarget.insertAfter(lastNodeChild, false);
                                                                                        }
                                                                            Severity: Major
                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

                                                                              Consider simplifying this complex logical expression.
                                                                              Open

                                                                                  } else if (
                                                                                    (isCollapsed || isBackward) &&
                                                                                    nextSibling === null &&
                                                                                    $isElementNode(parent) &&
                                                                                    parent.isInline() &&
                                                                              Severity: Major
                                                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                                                                                Consider simplifying this complex logical expression.
                                                                                Open

                                                                                  if (
                                                                                    anchorOffset === nextAnchorOffset &&
                                                                                    focusOffset === nextFocusOffset &&
                                                                                    anchorDOMNode === nextAnchorNode &&
                                                                                    focusDOMNode === nextFocusNode && // Badly interpreted range selection when collapsed - #1482
                                                                                Severity: Major
                                                                                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                                                                                  Consider simplifying this complex logical expression.
                                                                                  Open

                                                                                    if (
                                                                                      !tags.has('skip-scroll-into-view') &&
                                                                                      nextSelection.isCollapsed() &&
                                                                                      rootElement !== null &&
                                                                                      rootElement === document.activeElement
                                                                                  Severity: Major
                                                                                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                                                                                    Consider simplifying this complex logical expression.
                                                                                    Open

                                                                                      if (
                                                                                        isCollapsed &&
                                                                                        (prevSelection === null ||
                                                                                          anchorFormatOrStyleChanged ||
                                                                                          ($isRangeSelection(prevSelection) &&
                                                                                    Severity: Major
                                                                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                                                                                      Function adjustPointOffsetForMergedSibling has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                      Open

                                                                                        point: PointType,
                                                                                        isBefore: boolean,
                                                                                        key: NodeKey,
                                                                                        target: TextNode,
                                                                                        textLength: number,
                                                                                      Severity: Minor
                                                                                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 35 mins to fix

                                                                                        Function moveSelectionPointToSibling has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                        Open

                                                                                          point: PointType,
                                                                                          node: LexicalNode,
                                                                                          parent: ElementNode,
                                                                                          prevSibling: LexicalNode | null,
                                                                                          nextSibling: LexicalNode | null,
                                                                                        Severity: Minor
                                                                                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 35 mins to fix

                                                                                          Function isBefore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            isBefore(b: PointType): boolean {
                                                                                              let aNode = this.getNode();
                                                                                              let bNode = b.getNode();
                                                                                              const aOffset = this.offset;
                                                                                              const bOffset = b.offset;
                                                                                          Severity: Minor
                                                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 35 mins to fix

                                                                                          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

                                                                                          Avoid too many return statements within this function.
                                                                                          Open

                                                                                                    return;
                                                                                          Severity: Major
                                                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                            Avoid too many return statements within this function.
                                                                                            Open

                                                                                                        return;
                                                                                            Severity: Major
                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                              Avoid too many return statements within this function.
                                                                                              Open

                                                                                                return [resolvedAnchorPoint, resolvedFocusPoint];
                                                                                              Severity: Major
                                                                                              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                Avoid too many return statements within this function.
                                                                                                Open

                                                                                                          return;
                                                                                                Severity: Major
                                                                                                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                  Avoid too many return statements within this function.
                                                                                                  Open

                                                                                                          return;
                                                                                                  Severity: Major
                                                                                                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                    Avoid too many return statements within this function.
                                                                                                    Open

                                                                                                      return [parent, node.getIndexWithinParent() + 1];
                                                                                                    Severity: Major
                                                                                                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

                                                                                                            return;
                                                                                                      Severity: Major
                                                                                                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                            return null;
                                                                                                        Severity: Major
                                                                                                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                          Avoid too many return statements within this function.
                                                                                                          Open

                                                                                                            return new RangeSelection(
                                                                                                              resolvedAnchorPoint,
                                                                                                              resolvedFocusPoint,
                                                                                                              !$isRangeSelection(lastSelection) ? 0 : lastSelection.format,
                                                                                                              !$isRangeSelection(lastSelection) ? '' : lastSelection.style,
                                                                                                          Severity: Major
                                                                                                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 30 mins to fix

                                                                                                            Function insertRawText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                            Open

                                                                                                              insertRawText(text: string): void {
                                                                                                                const parts = text.split(/(\r?\n|\t)/);
                                                                                                                const nodes = [];
                                                                                                                const length = parts.length;
                                                                                                                for (let i = 0; i < length; i++) {
                                                                                                            Severity: Minor
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 25 mins to fix

                                                                                                            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 $moveSelectionPointToEnd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                            Open

                                                                                                            export function $moveSelectionPointToEnd(
                                                                                                              point: PointType,
                                                                                                              node: LexicalNode,
                                                                                                            ): void {
                                                                                                              if ($isElementNode(node)) {
                                                                                                            Severity: Minor
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 25 mins to fix

                                                                                                            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

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                            export type ElementPointType = {
                                                                                                              _selection: BaseSelection;
                                                                                                              getNode: () => ElementNode;
                                                                                                              is: (point: PointType) => boolean;
                                                                                                              isBefore: (point: PointType) => boolean;
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 67..76

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 131.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                            export type TextPointType = {
                                                                                                              _selection: BaseSelection;
                                                                                                              getNode: () => TextNode;
                                                                                                              is: (point: PointType) => boolean;
                                                                                                              isBefore: (point: PointType) => boolean;
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 78..87

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 131.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                              if ($isElementNode(focusNode)) {
                                                                                                                const childSize = focusNode.getChildrenSize();
                                                                                                                const focusOffsetAtEnd = focusOffset >= childSize;
                                                                                                                const child = focusOffsetAtEnd
                                                                                                                  ? focusNode.getChildAtIndex(childSize - 1)
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2432..2445

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 125.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                              if ($isElementNode(anchorNode)) {
                                                                                                                const childSize = anchorNode.getChildrenSize();
                                                                                                                const anchorOffsetAtEnd = anchorOffset >= childSize;
                                                                                                                const child = anchorOffsetAtEnd
                                                                                                                  ? anchorNode.getChildAtIndex(childSize - 1)
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2446..2459

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 125.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if (parentNode.is(lastPointNode)) {
                                                                                                                  const lastPointOffset = lastPoint.offset;
                                                                                                                  if (
                                                                                                                    (nodeOffset <= lastPointOffset && times > 0) ||
                                                                                                                    (nodeOffset < lastPointOffset && times < 0)
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 2 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2375..2387

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 87.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if (parentNode.is(firstPointNode)) {
                                                                                                                  const firstPointOffset = firstPoint.offset;
                                                                                                                  if (
                                                                                                                    (nodeOffset <= firstPointOffset && times > 0) ||
                                                                                                                    (nodeOffset < firstPointOffset && times < 0)
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 2 hrs to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2388..2400

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 87.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                  this.isCollapsed() &&
                                                                                                                  startOffset === 0 &&
                                                                                                                  (firstNode.isSegmented() ||
                                                                                                                    firstNode.isToken() ||
                                                                                                                    !firstNode.canInsertTextBefore() ||
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 757..763

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 61.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                  this.isCollapsed() &&
                                                                                                                  startOffset === firstNodeTextLength &&
                                                                                                                  (firstNode.isSegmented() ||
                                                                                                                    firstNode.isToken() ||
                                                                                                                    !firstNode.canInsertTextAfter() ||
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 787..793

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 61.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                              delete(key: NodeKey): void {
                                                                                                                this.dirty = true;
                                                                                                                this._nodes.delete(key);
                                                                                                                this._cachedNodes = null;
                                                                                                              }
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 307..311

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 56.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                              add(key: NodeKey): void {
                                                                                                                this.dirty = true;
                                                                                                                this._nodes.add(key);
                                                                                                                this._cachedNodes = null;
                                                                                                              }
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 313..317

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 56.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if ($isElementNode(aNode)) {
                                                                                                                  const aNodeDescendant = aNode.getDescendantByIndex<ElementNode>(aOffset);
                                                                                                                  aNode = aNodeDescendant != null ? aNodeDescendant : aNode;
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 2 other locations - About 40 mins to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 122..125
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 478..482

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 49.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if ($isElementNode(firstNode)) {
                                                                                                                  const firstNodeDescendant =
                                                                                                                    firstNode.getDescendantByIndex<ElementNode>(startOffset);
                                                                                                                  firstNode = firstNodeDescendant != null ? firstNodeDescendant : firstNode;
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 2 other locations - About 40 mins to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 118..121
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 122..125

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 49.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if ($isElementNode(bNode)) {
                                                                                                                  const bNodeDescendant = bNode.getDescendantByIndex<ElementNode>(bOffset);
                                                                                                                  bNode = bNodeDescendant != null ? bNodeDescendant : bNode;
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 2 other locations - About 40 mins to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 118..121
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 478..482

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 49.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                  if ($isTextNode(parentSibling)) {
                                                                                                                    point.key = parentSibling.__key;
                                                                                                                    point.offset = parentSibling.getTextContent().length;
                                                                                                                  }
                                                                                                            Severity: Minor
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 40 mins to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2049..2052

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 48.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                  } else if ($isTextNode(prevSibling)) {
                                                                                                                    point.key = prevSibling.__key;
                                                                                                                    point.offset = prevSibling.getTextContent().length;
                                                                                                                  }
                                                                                                            Severity: Minor
                                                                                                            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 40 mins to fix
                                                                                                            resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2060..2063

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 48.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            There are no issues that match your filters.

                                                                                                            Category
                                                                                                            Status