BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/lexical/list/LexicalListNode.ts

Summary

Maintainability
C
1 day
Test Coverage

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

function $setListThemeClassNames(
  dom: HTMLElement,
  editorThemeClasses: EditorThemeClasses,
  node: ListNode,
): void {
Severity: Minor
Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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

File LexicalListNode.ts has 286 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: Minor
Found in resources/js/wysiwyg/lexical/list/LexicalListNode.ts - About 2 hrs to fix

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

    function $setListThemeClassNames(
      dom: HTMLElement,
      editorThemeClasses: EditorThemeClasses,
      node: ListNode,
    ): void {
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/list/LexicalListNode.ts - About 1 hr to fix

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

        append(...nodesToAppend: LexicalNode[]): this {
          for (let i = 0; i < nodesToAppend.length; i++) {
            const currentNode = nodesToAppend[i];
      
            if ($isListItemNode(currentNode)) {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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 $normalizeChildren has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function $normalizeChildren(nodes: Array<LexicalNode>): Array<ListItemNode> {
        const normalizedListItems: Array<ListItemNode> = [];
        for (let i = 0; i < nodes.length; i++) {
          const node = nodes[i];
          if ($isListItemNode(node)) {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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

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

      function isDomChecklist(domNode: HTMLElement) {
        if (
          domNode.getAttribute('__lexicallisttype') === 'check' ||
          // is github checklist
          domNode.classList.contains('contains-task-list')
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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 exportDOM has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        exportDOM(editor: LexicalEditor): DOMExportOutput {
          const {element} = super.exportDOM(editor);
          if (element && isHTMLElement(element)) {
            if (this.__start !== 1) {
              element.setAttribute('start', String(this.__start));
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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

      There are no issues that match your filters.

      Category
      Status