BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

      await editor.update(() => {
        const root = $getRoot();
        const paragraph = $createParagraphNode();
        root.append(paragraph);
        const text = $createTextNode('Hello');
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 163..170

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

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

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

      await editor.update(() => {
        const root = $getRoot();
        const paragraph = $createParagraphNode();
        root.append(paragraph);
        const text = $createTextNode('Hello');
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 133..140

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

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

      await editor.update(() => {
        const node = $createRootNode();

        // If you broke this test, you changed the public interface of a
        // serialized Lexical Core Node. Please ensure the correct adapter
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalElementNode.test.ts on lines 76..92

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

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

      await update(() => {
        const node = $createTestElementNode();

        // If you broke this test, you changed the public interface of a
        // serialized Lexical Core Node. Please ensure the correct adapter
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 70..85

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

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

            build() {
                const generalFields: EditorFormFieldDefinition[] = [
                    {
                        label: 'Width', // Colgroup width
                        name: 'width',
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/forms/tables.ts - About 2 hrs to fix

    File PageContent.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace BookStack\Entities\Tools;
    
    use BookStack\Entities\Models\Page;
    Severity: Minor
    Found in app/Entities/Tools/PageContent.php - About 2 hrs to fix

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

          protected function isSortChangePermissible(BookSortMapItem $sortMapItem, BookChild $model, ?Entity $currentParent, ?Entity $newBook, ?Entity $newChapter): bool
          {
              // Stop if we can't see the current parent or new book.
              if (!$currentParent || !$newBook) {
                  return false;
      Severity: Minor
      Found in app/Entities/Tools/BookContents.php - 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 $dfs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $dfs(
        startingNode?: LexicalNode,
        endingNode?: LexicalNode,
      ): Array<DFSNode> {
        const nodes = [];
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/utils/index.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 syncPropertiesFromLexical has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function syncPropertiesFromLexical(
        binding: Binding,
        sharedType: XmlText | YMap<unknown> | XmlElement,
        prevLexicalNode: null | LexicalNode,
        nextLexicalNode: LexicalNode,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/yjs/Utils.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 $insertTableColumn has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $insertTableColumn(
        tableNode: TableNode,
        targetIndex: number,
        shouldInsertAfter = true,
        columnCount: number,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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 $getTableCellNodeRect has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $getTableCellNodeRect(tableCellNode: TableCellNode): {
        rowIndex: number;
        columnIndex: number;
        rowSpan: number;
        colSpan: number;
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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 getTable has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function getTable(tableElement: HTMLElement): TableDOMTable {
        const domRows: TableDOMRows = [];
        const grid = {
          columns: 0,
          domRows,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 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

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

      export const insertColumnBefore: EditorButtonDefinition = {
          label: 'Insert column before',
          icon: insertColumnBeforeIcon,
          action(context: EditorUiContext) {
              context.editor.update(() => {
      Severity: Major
      Found in resources/js/wysiwyg/ui/defaults/buttons/tables.ts and 1 other location - About 2 hrs to fix
      resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 322..333

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

      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 const insertColumnAfter: EditorButtonDefinition = {
          label: 'Insert column after',
          icon: insertColumnAfterIcon,
          action(context: EditorUiContext) {
              context.editor.update(() => {
      Severity: Major
      Found in resources/js/wysiwyg/ui/defaults/buttons/tables.ts and 1 other location - About 2 hrs to fix
      resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 309..320

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

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

        updateDOM(
          prevNode: TextNode,
          dom: HTMLElement,
          config: EditorConfig,
        ): boolean {
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 2 hrs to fix

        Function setupTracker has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            setupTracker(container: HTMLElement, node: NodeHasSize, nodeDOM: HTMLElement): MouseDragTracker {
                let startingWidth: number = 0;
                let startingHeight: number = 0;
                let startingRatio: number = 0;
                let hasHeight = false;
        Severity: Major
        Found in resources/js/wysiwyg/ui/framework/helpers/node-resizer.ts - About 2 hrs to fix

          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

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

                  test('last list item', async () => {
                    const {editor} = testEnv;
            
                    await editor.update(() => {
                      listItemNode3.insertNewAfter($createRangeSelection());
            resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 1105..1134
            resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 1167..1196

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

            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

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

                    await editor.getEditorState().read(() => {
                      const rootNode = $getRoot();
                      expect(textNode.getParent()).toBe(paragraphNode);
                      expect(paragraphNode.getParent()).toBe(rootNode);
                    });
            resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 571..575

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

            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