BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

File LexicalUpdates.ts has 848 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/LexicalUpdates.ts - About 2 days to fix

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

            test(`paragraph to text nodes${reversedStr}`, async () => {
              const {editor} = testEnv;
              editor.update(() => {
                const root = $getRoot();
                const paragraph = $createParagraphNode();
    resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNormalization.test.ts on lines 116..142

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

    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

            test(`text + text node${reversedStr}`, async () => {
              const {editor} = testEnv;
              editor.update(() => {
                const root = $getRoot();
                const paragraph = $createParagraphNode();
    resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNormalization.test.ts on lines 32..58

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

    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

            test(`paragraph to text node + decorator${reversedStr}`, async () => {
              const {editor} = testEnv;
              editor.update(() => {
                const root = $getRoot();
                const paragraph = $createParagraphNode();
    resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNormalization.test.ts on lines 60..86

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

    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

            test(`paragraph to text node + element${reversedStr}`, async () => {
              const {editor} = testEnv;
              editor.update(() => {
                const root = $getRoot();
                const paragraph = $createParagraphNode();
    resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNormalization.test.ts on lines 88..114

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

    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

    File LexicalTableUtils.ts has 790 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/table/LexicalTableUtils.ts - About 1 day to fix

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

        Selection.prototype.modify = function (alter, direction, granularity) {
          // This is not a thorough implementation, it was more to get tests working
          // given the refactor to use this selection method.
          const symbol = Object.getOwnPropertySymbols(this)[0];
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.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

      File index.ts has 780 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/selection/__tests__/utils/index.ts - About 1 day to fix

        File LexicalTextNode.test.ts has 771 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.

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

                  describe('Mid-paragraph inline elements', () => {
                    const insertText = async ({
                      container,
                      editor,
                      method,
          resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 174..212

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

          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

                  describe('End-of-paragraph inline elements', () => {
                    const insertText = async ({
                      container,
                      editor,
                      method,
          resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 134..172

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

          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

          File LexicalReconciler.ts has 678 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/LexicalReconciler.ts - About 1 day to fix

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

                    describe('End-of-paragraph inline elements', () => {
                      const insertText = async ({
                        container,
                        editor,
                        method,
            resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 92..132

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

            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

                    describe('Start-of-paragraph inline elements', () => {
                      const insertText = async ({
                        container,
                        editor,
                        method,
            resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 298..338

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

            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

                    describe('Start-of-paragraph inline elements', () => {
                      const insertText = async ({
                        container,
                        editor,
                        method,
            resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 257..296

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

            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

                    describe('Mid-paragraph inline elements', () => {
                      const insertText = async ({
                        container,
                        editor,
                        method,
            resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalSelection.test.ts on lines 216..255

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

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

            export function $wrapNodesImpl(
              selection: BaseSelection,
              nodes: LexicalNode[],
              nodesLength: number,
              createElement: () => ElementNode,
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/selection/range-selection.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 applyTableHandlers has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
            Open

            export function applyTableHandlers(
              tableNode: TableNode,
              tableElement: HTMLTableElementWithWithTableSelectionState,
              editor: LexicalEditor,
              hasTabHandler: boolean,
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 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

              modeMap has 76 functions (exceeds 20 allowed). Consider refactoring.
              Open

              const modeMap = {
                  bash: () => legacyLoad('shell'),
                  c: () => legacyLoad('c'),
                  css: async () => css(),
                  'c++': () => legacyLoad('cpp'),
              Severity: Major
              Found in resources/js/code/languages.js - About 1 day to fix
                Severity
                Category
                Status
                Source
                Language