BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function getMainEditorFullToolbar has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getMainEditorFullToolbar(context: EditorUiContext): EditorContainerUiElement {

    const inRtlMode = context.manager.getDefaultDirection() === 'rtl';

    return new EditorSimpleClassContainer('editor-toolbar-main', [
Severity: Major
Found in resources/js/wysiwyg/ui/toolbars.ts - About 4 hrs to fix

    Function positionNodeOnRange has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function positionNodeOnRange(
      editor: LexicalEditor,
      range: Range,
      onReposition: (node: Array<HTMLElement>) => void,
    ): () => void {
    Severity: Major
    Found in resources/js/wysiwyg/lexical/utils/positionNodeOnRange.ts - About 4 hrs to fix

      LexicalEditor has 33 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class LexicalEditor {
        ['constructor']!: KlassConstructor<typeof LexicalEditor>;
      
        /** The version with build identifiers for this editor (since 0.17.1) */
        static version: string | undefined;
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 4 hrs to fix

        Function splitText has 104 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          splitText(...splitOffsets: Array<number>): Array<TextNode> {
            errorOnReadOnly();
            const self = this.getLatest();
            const textContent = self.getTextContent();
            const key = self.__key;
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 4 hrs to fix

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

                test('LexicalNode.replace(): directionless', async () => {
                  const {editor} = testEnv;
          
                  expect(testEnv.outerHTML).toBe(
                    '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p><span data-lexical-text="true">foo</span></p></div>',
          resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 1274..1290

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

          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('ListItemNode.constructor', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const listItemNode = new ListItemNode();
          resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalParagraphNode.test.ts on lines 28..38

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

          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('LexicalNode.insertAfter(): directionless', async () => {
                  const {editor} = testEnv;
          
                  expect(testEnv.outerHTML).toBe(
                    '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p><span data-lexical-text="true">foo</span></p></div>',
          resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 1168..1184

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

          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('ParagraphNode.constructor', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const paragraphNode = new ParagraphNode();
          resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 42..54

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

          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 4 locations. Consider refactoring.
          Open

              test('LinkNode.setTitle()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const linkNode = new LinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 124..138
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 182..196
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 105..119

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

          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 4 locations. Consider refactoring.
          Open

              test('AutoLinkNode.setTarget()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 182..196
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 105..119
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 163..177

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

          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 4 locations. Consider refactoring.
          Open

              test('LinkNode.setTarget()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const linkNode = new LinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 124..138
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 182..196
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 163..177

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

          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 4 locations. Consider refactoring.
          Open

              test('AutoLinkNode.setTitle()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 124..138
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 105..119
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 163..177

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

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

          function onKeyDown(event: KeyboardEvent, editor: LexicalEditor): void {
            lastKeyDownTimeStamp = event.timeStamp;
            lastKeyCode = event.key;
            if (editor.isComposing()) {
              return;
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 4 hrs to fix

            File lexical-node.ts has 336 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * Copyright (c) Meta Platforms, Inc. and affiliates.
             *
             * This source code is licensed under the MIT license found in the
             * LICENSE file in the root directory of this source tree.
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

              Function $trimTextContentFromAnchor has 100 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function $trimTextContentFromAnchor(
                editor: LexicalEditor,
                anchor: Point,
                delCount: number,
              ): void {
              Severity: Major
              Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                      if (
                        node.isToken() ||
                        (compositionKey !== null &&
                          nodeKey === compositionKey &&
                          !isComposing) ||
                Severity: Critical
                Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 4 hrs to fix

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

                        setupTestCase((selection, element) => {
                          selection.insertParagraph();
                  
                          expect(selection.anchor).toEqual(
                            expect.objectContaining({
                  resources/js/wysiwyg/lexical/selection/__tests__/unit/LexicalSelectionHelpers.test.ts on lines 1549..1567

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

                  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

                        setupTestCase((selection, element) => {
                          selection.insertParagraph();
                  
                          expect(selection.anchor).toEqual(
                            expect.objectContaining({
                  resources/js/wysiwyg/lexical/selection/__tests__/unit/LexicalSelectionHelpers.test.ts on lines 919..937

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

                  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

                  <?php
                  
                  namespace BookStack\References\ModelResolvers;
                  
                  use BookStack\App\Model;
                  Severity: Major
                  Found in app/References/ModelResolvers/BookshelfLinkModelResolver.php and 1 other location - About 3 hrs to fix
                  app/References/ModelResolvers/BookLinkModelResolver.php on lines 1..32

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language