BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

      export function $setInsetForSelection(editor: LexicalEditor, change: number): void {
          const selection = $getSelection();
          const listItemsInSelection = getListItemsForSelection(selection);
          const isListSelection = listItemsInSelection.length > 0 && !listItemsInSelection.includes(null);
      
      
      Severity: Minor
      Found in resources/js/wysiwyg/utils/lists.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 updateContextToolbars has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected updateContextToolbars(update: EditorUiStateUpdate): void {
              for (let i = this.activeContextToolbars.length - 1; i >= 0; i--) {
                  const toolbar = this.activeContextToolbars[i];
                  toolbar.destroy();
                  this.activeContextToolbars.splice(i, 1);
      Severity: Minor
      Found in resources/js/wysiwyg/ui/framework/manager.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 containHtml has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function containHtml(string $htmlContent): string
          {
              $imageTagsOutput = [];
              preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);
      
      
      Severity: Minor
      Found in app/Entities/Tools/ExportFormatter.php - 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 updateState has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          updateState(state: EditorUiStateUpdate) {
              super.updateState(state);
      
              for (const child of this.children) {
                  if (child instanceof EditorButton && child.isActive()) {
      Severity: Minor
      Found in resources/js/wysiwyg/ui/framework/blocks/format-menu.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 getLastTextNode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function getLastTextNode(startingNode: Node) {
        let node = startingNode;
      
        mainLoop: while (node !== null) {
          if (node !== startingNode && node.nodeType === 3) {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.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 $handleNormalizationMergeConflicts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function $handleNormalizationMergeConflicts(
        binding: Binding,
        normalizedNodes: Set<NodeKey>,
      ): void {
        // We handle the merge operations here
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.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 $syncEvent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function $syncEvent(binding: Binding, event: any): void {
        const {target} = event;
        const collabNode = $getOrInitCollabNodeFromSharedType(binding, target);
      
        if (collabNode instanceof CollabElementNode && event instanceof YTextEvent) {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.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 $insertTableRow__EXPERIMENTAL has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $insertTableRow__EXPERIMENTAL(insertAfter = true): void {
        const selection = $getSelection();
        invariant(
          $isRangeSelection(selection) || $isTableSelection(selection),
          'Expected a RangeSelection or TableSelection',
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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 registerHistory has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      export function registerHistory(
        editor: LexicalEditor,
        historyState: HistoryState,
        delay: number,
      ): () => void {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/history/index.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 $shouldPreventDefaultAndInsertText has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function $shouldPreventDefaultAndInsertText(
        selection: RangeSelection,
        domTargetRange: null | StaticRange,
        text: string,
        timeStamp: number,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalEvents.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 updateDOM has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        updateDOM(
          prevNode: TextNode,
          dom: HTMLElement,
          config: EditorConfig,
        ): boolean {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.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 setTextContent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function setTextContent(
        nextText: string,
        dom: HTMLElement,
        node: TextNode,
      ): void {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.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

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

                if (
                  !event.shiftKey &&
                  $isDecoratorNode(possibleNode) &&
                  !possibleNode.isIsolated() &&
                  !possibleNode.isInline()
      Severity: Major
      Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 1 other location - About 1 hr to fix
      resources/js/wysiwyg/lexical/rich-text/index.ts on lines 733..742

      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 70.

      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

        setFormat(format: TextFormatType | number): this {
          const self = this.getWritable();
          self.__format =
            typeof format === 'string' ? TEXT_TYPE_TO_FORMAT[format] : format;
          return self;
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts and 1 other location - About 1 hr to fix
      resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts on lines 718..723

      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 70.

      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

        setDetail(detail: TextDetailType | number): this {
          const self = this.getWritable();
          self.__detail =
            typeof detail === 'string' ? DETAIL_TYPE_TO_DETAIL[detail] : detail;
          return self;
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts and 1 other location - About 1 hr to fix
      resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts on lines 700..705

      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 70.

      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 (
                  !event.shiftKey &&
                  $isDecoratorNode(possibleNode) &&
                  !possibleNode.isIsolated() &&
                  !possibleNode.isInline()
      Severity: Major
      Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 1 other location - About 1 hr to fix
      resources/js/wysiwyg/lexical/rich-text/index.ts on lines 766..775

      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 70.

      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

      Function drop has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function drop(editor, options, event) {
          const {dom} = editor;
          const rng = window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(
              event.clientX,
              event.clientY,
      Severity: Minor
      Found in resources/js/wysiwyg-tinymce/drop-paste-handling.js - About 1 hr to fix

        Function buildDOM has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildDOM(): HTMLElement {
                const size = 10;
                const rows: HTMLElement[] = [];
                const cells: HTMLElement[] = [];
        
        
        Severity: Minor
        Found in resources/js/wysiwyg/ui/framework/blocks/table-creator.ts - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language