BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function createDropListener has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createDropListener(context: EditorUiContext): (event: DragEvent) => boolean {
    const editor = context.editor;
    return (event: DragEvent): boolean => {
        // Template handling
        const templateId = event.dataTransfer?.getData('bookstack/template') || '';
Severity: Minor
Found in resources/js/wysiwyg/services/drop-paste-handling.ts - About 1 hr to fix

    Function buildDOM has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected buildDOM(): HTMLElement {
            const controls: HTMLElement[] = [];
            const contents: HTMLElement[] = [];
    
            const selectTab = (tabIndex: number) => {
    Severity: Minor
    Found in resources/js/wysiwyg/ui/framework/forms.ts - About 1 hr to fix

      Function $createCollabNodeFromLexicalNode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function $createCollabNodeFromLexicalNode(
        binding: Binding,
        lexicalNode: LexicalNode,
        parent: CollabElementNode,
      ):
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/yjs/Utils.ts - About 1 hr to fix

        Function $dfs has 29 lines of code (exceeds 25 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 1 hr to fix

          Function restart has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function restart(): void {
              const currentRootDOMNode = editor.getRootElement();
              if (currentRootDOMNode === null) {
                return stop();
              }
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/utils/positionNodeOnRange.ts - About 1 hr to fix

            Function $getNodeTriplet has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function $getNodeTriplet(
              source: PointType | LexicalNode | TableCellNode,
            ): [TableCellNode, TableRowNode, TableNode] {
              let cell: TableCellNode;
              if (source instanceof TableCellNode) {
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 1 hr to fix

              Function $createTableNodeWithDimensions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function $createTableNodeWithDimensions(
                rowCount: number,
                columnCount: number,
                includeHeaders: InsertTableCommandPayloadHeaders = true,
              ): TableNode {
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 1 hr to fix

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

                      await editor.update(() => {
                        const thirdParagraph = $getRoot().getLastChild<ElementNode>()!;
                        thirdParagraph.append($createTextNode('third line'));
                      });
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 199..203
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 213..217

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

                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 registerNodeResizer(context: EditorUiContext): (() => void) {
                    const resizer = new NodeResizer(context);
                
                    return () => {
                        resizer.teardown();
                Severity: Major
                Found in resources/js/wysiwyg/ui/framework/helpers/node-resizer.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/ui/framework/helpers/table-selection-handler.ts on lines 73..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 58.

                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

                const $isHeaderNodeOfTag = (node: LexicalNode | null | undefined, tag: HeadingTagType) => {
                    return $isCustomHeadingNode(node) && (node as HeadingNode).getTag() === tag;
                };
                Severity: Major
                Found in resources/js/wysiwyg/utils/formats.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/ui/defaults/buttons/block-formats.ts on lines 40..42

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

                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

                const isHeaderNodeOfTag = (node: LexicalNode | null | undefined, tag: HeadingTagType) => {
                    return $isHeadingNode(node) && (node as HeadingNode).getTag() === tag;
                };
                Severity: Major
                Found in resources/js/wysiwyg/ui/defaults/buttons/block-formats.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/utils/formats.ts on lines 19..21

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

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

                      await editor.update(() => {
                        const secondParagraph = $getRoot().getLastChild<ElementNode>()!;
                
                        secondParagraph.append($createTextNode('second line'));
                      });
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 199..203
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 227..230

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

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

                      await editor.update(() => {
                        const firstParagraph = $getRoot().getFirstChild<ElementNode>()!;
                
                        firstParagraph.append($createTextNode('first line'));
                      });
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 213..217
                resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalRootNode.test.ts on lines 227..230

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

                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 registerTableSelectionHandler(editor: LexicalEditor): (() => void) {
                    const resizer = new TableSelectionHandler(editor);
                
                    return () => {
                        resizer.teardown();
                resources/js/wysiwyg/ui/framework/helpers/node-resizer.ts on lines 178..184

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

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

                    async saveDraft() {
                        const data = {name: this.titleElem.value.trim()};
                
                        const editorContent = await this.getEditorComponent().getContent();
                        Object.assign(data, editorContent);
                Severity: Minor
                Found in resources/js/components/page-editor.js - About 1 hr to fix

                  Method processLoginCallback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function processLoginCallback(string $samlID, array $samlAttributes): User
                      {
                          $userDetails = $this->getUserDetails($samlID, $samlAttributes);
                          $isLoggedIn = auth()->check();
                  
                  
                  Severity: Minor
                  Found in app/Access/Saml2Service.php - About 1 hr to fix

                    Method getUserDetailsFromToken has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function getUserDetailsFromToken(OidcIdToken $idToken, OidcAccessToken $accessToken, OidcProviderSettings $settings): OidcUserDetails
                        {
                            $userDetails = new OidcUserDetails();
                            $userDetails->populate(
                                $idToken,
                    Severity: Minor
                    Found in app/Access/Oidc/OidcService.php - About 1 hr to fix

                      Method update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function update(Request $request, int $id)
                          {
                              $this->preventAccessInDemoMode();
                              $this->checkPermission('users-manage');
                      
                      
                      Severity: Minor
                      Found in app/Users/Controllers/UserController.php - About 1 hr to fix

                        Method loadSettingsFromIssuerDiscovery has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function loadSettingsFromIssuerDiscovery(ClientInterface $httpClient): array
                            {
                                $issuerUrl = rtrim($this->issuer, '/') . '/.well-known/openid-configuration';
                                $request = new Request('GET', $issuerUrl);
                                $response = $httpClient->sendRequest($request);
                        Severity: Minor
                        Found in app/Access/Oidc/OidcProviderSettings.php - About 1 hr to fix

                          Function $setInsetForSelection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function $setInsetForSelection(editor: LexicalEditor, change: number): void {
                              const selection = $getSelection();
                              const listItemsInSelection = getListItemsForSelection(selection);
                              const isListSelection = listItemsInSelection.length > 0 && !listItemsInSelection.includes(null);
                          
                          
                          Severity: Minor
                          Found in resources/js/wysiwyg/utils/lists.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language