BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

export const directionRTL: EditorButtonDefinition = {
    label: 'Right to left',
    icon: rtlIcon,
    action(context: EditorUiContext) {
        context.editor.update(() => setDirectionForSelection(context, 'rtl'));
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/alignments.ts and 5 other locations - About 2 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 53..62
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 64..73
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 75..84
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 86..95
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 97..106

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

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

export const alignRight: EditorButtonDefinition = {
    label: 'Align right',
    icon: alignRightIcon,
    action(context: EditorUiContext) {
        context.editor.update(() => setAlignmentForSelection(context, 'right'));
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/alignments.ts and 5 other locations - About 2 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 53..62
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 64..73
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 86..95
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 97..106
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 108..117

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

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

export const alignCenter: EditorButtonDefinition = {
    label: 'Align center',
    icon: alignCenterIcon,
    action(context: EditorUiContext) {
        context.editor.update(() => setAlignmentForSelection(context, 'center'));
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/alignments.ts and 5 other locations - About 2 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 53..62
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 75..84
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 86..95
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 97..106
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 108..117

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

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

export const directionLTR: EditorButtonDefinition = {
    label: 'Left to right',
    icon: ltrIcon,
    action(context: EditorUiContext) {
        context.editor.update(() => setDirectionForSelection(context, 'ltr'));
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/alignments.ts and 5 other locations - About 2 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 53..62
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 64..73
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 75..84
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 86..95
resources/js/wysiwyg/ui/defaults/buttons/alignments.ts on lines 108..117

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

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.getEditorState().read(() => {
          expect(node.isSelected()).toBe(false);
          expect(textNode.isSelected()).toBe(false);
          expect(paragraphNode.isSelected()).toBe(false);
        });
resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 243..247

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

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 function removeClassNamesFromElement(
  element: HTMLElement,
  ...classNames: Array<typeof undefined | boolean | null | string>
): void {
  const classesToRemove = normalizeClassNames(...classNames);
Severity: Major
Found in resources/js/wysiwyg/lexical/utils/index.ts and 1 other location - About 2 hrs to fix
resources/js/wysiwyg/lexical/utils/index.ts on lines 79..87

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

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.getEditorState().read(() => {
          expect(node.isAttached()).toBe(false);
          expect(textNode.isAttached()).toBe(true);
          expect(paragraphNode.isAttached()).toBe(true);
        });
resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 260..264

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

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 function addClassNamesToElement(
  element: HTMLElement,
  ...classNames: Array<typeof undefined | boolean | null | string>
): void {
  const classesToAdd = normalizeClassNames(...classNames);
Severity: Major
Found in resources/js/wysiwyg/lexical/utils/index.ts and 1 other location - About 2 hrs to fix
resources/js/wysiwyg/lexical/utils/index.ts on lines 97..105

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

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 LdapService.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BookStack\Access;

use BookStack\Exceptions\JsonDebugException;
Severity: Minor
Found in app/Access/LdapService.php - About 2 hrs to fix

    Function insertList has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function insertList(editor: LexicalEditor, listType: ListType): void {
      editor.update(() => {
        const selection = $getSelection();
    
        if (selection !== null) {
    Severity: Major
    Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 2 hrs to fix

      Function $deleteTableRow__EXPERIMENTAL has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function $deleteTableRow__EXPERIMENTAL(): void {
        const selection = $getSelection();
        invariant(
          $isRangeSelection(selection) || $isTableSelection(selection),
          'Expected a RangeSelection or TableSelection',
      Severity: Major
      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 2 hrs to fix

        Function onInput has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function onInput(event: InputEvent, editor: LexicalEditor): void {
          // We don't want the onInput to bubble, in the case of nested editors.
          event.stopPropagation();
          updateEditor(editor, () => {
            const selection = $getSelection();
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 2 hrs to fix

          Function syncPropertiesFromYjs has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          export function syncPropertiesFromYjs(
            binding: Binding,
            sharedType: XmlText | YMap<unknown> | XmlElement,
            lexicalNode: LexicalNode,
            keysChanged: null | Set<string>,
          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 $computeTableMapSkipCellCheck has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          export function $computeTableMapSkipCellCheck(
            grid: TableNode,
            cellA: null | TableCellNode,
            cellB: null | TableCellNode,
          ): [TableMapType, TableMapValueType | null, TableMapValueType | null] {
          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 $setListItemThemeClassNames has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function $setListItemThemeClassNames(
            dom: HTMLElement,
            editorThemeClasses: EditorThemeClasses,
            node: ListItemNode,
          ): void {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/list/LexicalListItemNode.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 function showImageManager(callback: (image: EditorImageData) => any) {
              const imageManager: ImageManager = window.$components.first('image-manager') as ImageManager;
              imageManager.show((image: EditorImageData) => {
                  callback(image);
              }, 'gallery');
          Severity: Major
          Found in resources/js/wysiwyg/utils/images.ts and 1 other location - About 2 hrs to fix
          resources/js/wysiwyg/utils/diagrams.ts on lines 75..80

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

          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 function showDiagramManager(callback: (image: EditorImageData) => any) {
              const imageManager: ImageManager = window.$components.first('image-manager') as ImageManager;
              imageManager.show((image: EditorImageData) => {
                  callback(image);
              }, 'drawio');
          Severity: Major
          Found in resources/js/wysiwyg/utils/diagrams.ts and 1 other location - About 2 hrs to fix
          resources/js/wysiwyg/utils/images.ts on lines 12..17

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

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

          function register(editor) {
              editor.ui.registry.addIcon('tableclearformatting', '<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 24 24"><path d="M15.53088 4.64727v-.82364c0-.453-.37063-.82363-.82363-.82363H4.82363C4.37063 3 4 3.37064 4 3.82363v3.29454c0 .453.37064.82364.82363.82364h9.88362c.453 0 .82363-.37064.82363-.82364v-.82363h.82364v3.29454H8.11817v7.4127c0 .453.37064.82364.82364.82364h1.64727c.453 0 .82363-.37064.82363-.82364v-5.76544h6.58907V4.64727Z"/><path d="m18.42672 19.51563-1.54687-1.54688-1.54688 1.54688c-.26751.2675-.70124.2675-.96875 0-.26751-.26752-.26751-.70124 0-.96876L15.9111 17l-1.54688-1.54688c-.26751-.2675-.26751-.70123 0-.96875.26751-.2675.70124-.2675.96875 0l1.54688 1.54688 1.54687-1.54688c.26751-.2675.70124-.2675.96875 0 .26751.26752.26751.70124 0 .96875L17.8486 17l1.54687 1.54688c.26751.2675.26751.70123 0 .96874-.26751.26752-.70124.26752-.96875 0z"/></svg>');
          
              const tableFirstRowContextSpec = {
                  items: ' | tablerowheader',
          Severity: Major
          Found in resources/js/wysiwyg-tinymce/plugins-table-additions.js - About 2 hrs to fix

            Function $createNode has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function $createNode(
              key: NodeKey,
              parentDOM: null | HTMLElement,
              insertDOM: null | Node,
            ): HTMLElement {
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 2 hrs to fix

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

                  test('AutoLinkNode.getRel()', async () => {
                    const {editor} = testEnv;
              
                    await editor.update(() => {
                      const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
              resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 121..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 89.

              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