BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

    render(context: EditorUiContext, element: HTMLElement): void {
        if (this.completedSetup) {
            this.update();
        } else {
            this.setup(context, element);
Severity: Major
Found in resources/js/wysiwyg/ui/decorators/code-block.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/ui/decorators/diagram.ts on lines 42..48

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

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

    render(context: EditorUiContext, element: HTMLElement): void {
        if (this.completedSetup) {
            this.update();
        } else {
            this.setup(context, element);
Severity: Major
Found in resources/js/wysiwyg/ui/decorators/diagram.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/ui/decorators/code-block.ts on lines 92..98

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

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

        editor.ui.registry.addMenuItem('tableclearformatting', {
            icon: 'tableclearformatting',
            text: 'Clear table formatting',
            onSetup: exitingButtons.tableprops.onSetup,
            onAction() {
Severity: Major
Found in resources/js/wysiwyg-tinymce/plugins-table-additions.js and 1 other location - About 1 hr to fix
resources/js/wysiwyg-tinymce/plugins-table-additions.js on lines 72..79

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

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 paragraph = $createParagraphNode();
        const text = $createTextNode('foo');
        paragraph.append(text);
        $getRoot().append(paragraph);
resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalEditorState.test.ts on lines 36..41

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

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

    static importJSON(serializedNode: SerializedDiagramNode): DiagramNode {
        const node = $createDiagramNode(serializedNode.drawingId, serializedNode.drawingUrl);
        node.setId(serializedNode.id || '');
        return node;
    }
Severity: Major
Found in resources/js/wysiwyg/nodes/diagram.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/nodes/code-block.ts on lines 166..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 63.

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

    static importJSON(serializedNode: SerializedCodeBlockNode): CodeBlockNode {
        const node = $createCodeBlockNode(serializedNode.language, serializedNode.code);
        node.setId(serializedNode.id || '');
        return node;
    }
Severity: Major
Found in resources/js/wysiwyg/nodes/code-block.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/nodes/diagram.ts on lines 146..150

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

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

Method processUsers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function processUsers(array $users, UserAvatars $userAvatar): int
    {
        $dryRun = !$this->option('force');
        $this->info(count($users) . " user(s) found to update avatars for.");

Severity: Minor
Found in app/Console/Commands/RefreshAvatarCommand.php - About 1 hr to fix

    Function setupDropTargetHandlers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setupDropTargetHandlers() {
            let depth = 0;
    
            const reset = () => {
                this.hideOverlay();
    Severity: Minor
    Found in resources/js/components/dropzone.js - About 1 hr to fix

      Function setupListeners has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setupListeners() {
              this.elem.addEventListener('click', this.onClick.bind(this));
      
              let lastSearch = 0;
              this.searchInput.addEventListener('input', () => {
      Severity: Minor
      Found in resources/js/components/entity-selector.js - About 1 hr to fix

        Function createUploadFromFile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            createUploadFromFile(file) {
                const {
                    dom, status, progress, dismiss,
                } = this.createDomForFile(file);
                this.statusArea.append(dom);
        Severity: Minor
        Found in resources/js/components/dropzone.js - About 1 hr to fix

          Method fromRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function fromRequest(Request $request): self
              {
                  if (!$request->has('search') && !$request->has('term')) {
                      return static::fromString('');
                  }
          Severity: Minor
          Found in app/Search/SearchOptions.php - About 1 hr to fix

            Function setupTestCase has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  const setupTestCase = (
                    cb: (selection: RangeSelection, el: ElementNode) => void,
                  ) => {
                    const editor = createTestEditor();
            
            

              Function createRelativePosition has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function createRelativePosition(
                point: Point,
                binding: Binding,
              ): null | RelativePosition {
                const collabNodeMap = binding.collabNodeMap;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

                Function setupTestCase has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      const setupTestCase = (
                        cb: (selection: RangeSelection, el: ElementNode) => void,
                      ) => {
                        const editor = createTestEditor();
                
                

                  Function setupTestCase has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        const setupTestCase = (
                          cb: (selection: RangeSelection, node: ElementNode) => void,
                        ) => {
                          const editor = createTestEditor();
                  
                  

                    Function $shouldPreventDefaultAndInsertText has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function $shouldPreventDefaultAndInsertText(
                      selection: RangeSelection,
                      domTargetRange: null | StaticRange,
                      text: string,
                      timeStamp: number,
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr to fix

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

                            } else {
                              // anchor is on higher Grid level than focus
                              const focusCellParent = focusCellGrid.getParent();
                              invariant(
                                focusCellParent != null,
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 1 hr to fix
                      resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 213..218

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

                      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

                        updateDOM(
                          prevNode: AutoLinkNode,
                          anchor: LinkHTMLElementType,
                          config: EditorConfig,
                        ): boolean {
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/link/index.ts and 1 other location - About 1 hr to fix
                      resources/js/wysiwyg/nodes/custom-list.ts on lines 53..56

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

                      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

                          updateDOM(prevNode: ListNode, dom: HTMLElement, config: EditorConfig): boolean {
                              return super.updateDOM(prevNode, dom, config) ||
                                  prevNode.__dir !== this.__dir;
                          }
                      Severity: Major
                      Found in resources/js/wysiwyg/nodes/custom-list.ts and 1 other location - About 1 hr to fix
                      resources/js/wysiwyg/lexical/link/index.ts on lines 387..396

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

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

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

                            if (!tableNode.isParentOf(focusCell)) {
                              // focus is on higher Grid level than anchor
                              const gridParent = tableNode.getParent();
                              invariant(gridParent != null, 'Expected gridParent to have a parent');
                              this.set(this.tableKey, gridParent.getKey(), focusCell.getKey());
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 1 hr to fix
                      resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 218..226

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

                      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