BookStackApp/BookStack

View on GitHub

Showing 288 of 288 total issues

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

        this.elem.addEventListener('click', event => {
            if (event.target.closest('[data-sort-dir]') !== null) {
                this.sortDirectionClick(event);
            }
        });
Severity: Major
Found in resources/js/components/list-sort-control.js and 1 other location - About 1 hr to fix
resources/js/components/list-sort-control.js on lines 21..25

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

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

        this.menu.addEventListener('click', event => {
            if (event.target.closest('[data-sort-value]') !== null) {
                this.sortOptionClick(event);
            }
        });
Severity: Major
Found in resources/js/components/list-sort-control.js and 1 other location - About 1 hr to fix
resources/js/components/list-sort-control.js on lines 27..31

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

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

    protected function validateTokenClaims(string $clientId): void
    {
        // 1. The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery)
        // MUST exactly match the value of the iss (issuer) Claim.
        // Already done in parent.
Severity: Minor
Found in app/Access/Oidc/OidcIdToken.php - About 1 hr to fix

    Function setup has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setup() {
            // Options
            this.uploadedTo = this.$opts.uploadedTo;
    
            // Element References
    Severity: Minor
    Found in resources/js/components/image-manager.js - About 1 hr to fix

      Function paste has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function paste(editor, options, event) {
          const clipboard = new Clipboard(event.clipboardData || event.dataTransfer);
      
          // Don't handle the event ourselves if no items exist of contains table-looking data
          if (!clipboard.hasItems() || clipboard.containsTabularData()) {
      Severity: Minor
      Found in resources/js/wysiwyg/drop-paste-handling.js - About 1 hr to fix

        Method createManyJointPermissions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function createManyJointPermissions(array $originalEntities, array $roles)
            {
                $entities = $this->entitiesToSimpleEntities($originalEntities);
                $jointPermissions = [];
        
        
        Severity: Minor
        Found in app/Permissions/JointPermissionBuilder.php - About 1 hr to fix

          Function createDomForFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              createDomForFile(file) {
                  const image = elem('img', {src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"});
                  const status = elem('div', {class: 'dropzone-file-item-status'}, []);
                  const progress = elem('div', {class: 'dropzone-file-item-progress'});
                  const imageWrap = elem('div', {class: 'dropzone-file-item-image-wrap'}, [image]);
          Severity: Minor
          Found in resources/js/components/dropzone.js - About 1 hr to fix

            Function parsePlural has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                parsePlural(translation, count, replacements) {
                    const splitText = translation.split('|');
                    const exactCountRegex = /^{([0-9]+)}/;
                    const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
                    let result = null;
            Severity: Minor
            Found in resources/js/services/translations.js - About 1 hr to fix

              Method attempt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function attempt(array $credentials = [], $remember = false)
                  {
                      $username = $credentials['username'];
                      $userDetails = $this->ldapService->getUserDetails($username);
              
              
              Severity: Minor
              Found in app/Access/Guards/LdapSessionGuard.php - About 1 hr to fix

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

                    setupListeners() {
                        const navHandler = new KeyboardNavigationHandler(
                            this.list,
                            () => {
                                this.input.focus();
                Severity: Minor
                Found in resources/js/components/auto-suggest.js - About 1 hr to fix

                  Method show has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function show(Request $request, ActivityQueries $activities, string $slug)
                      {
                          $shelf = $this->queries->findVisibleBySlugOrFail($slug);
                          $this->checkOwnablePermission('bookshelf-view', $shelf);
                  
                  
                  Severity: Minor
                  Found in app/Entities/Controllers/BookshelfController.php - About 1 hr to fix

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

                        public function showDelete(string $bookSlug, string $chapterSlug)
                        {
                            $chapter = $this->queries->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
                            $this->checkOwnablePermission('chapter-delete', $chapter);
                    
                    
                    Severity: Major
                    Found in app/Entities/Controllers/ChapterController.php and 1 other location - About 1 hr to fix
                    app/Entities/Controllers/ChapterController.php on lines 105..113

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

                    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

                        public function edit(string $bookSlug, string $chapterSlug)
                        {
                            $chapter = $this->queries->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
                            $this->checkOwnablePermission('chapter-update', $chapter);
                    
                    
                    Severity: Major
                    Found in app/Entities/Controllers/ChapterController.php and 1 other location - About 1 hr to fix
                    app/Entities/Controllers/ChapterController.php on lines 142..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 101.

                    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

                        created(a, b) {
                            const aTime = Number(a.getAttribute('data-created'));
                            const bTime = Number(b.getAttribute('data-created'));
                            return bTime - aTime;
                        },
                    Severity: Major
                    Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
                    resources/js/components/book-sort.js on lines 17..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 55.

                    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

                        open() {
                            this.container.classList.add('open');
                            this.trigger.setAttribute('aria-expanded', 'true');
                            slideDown(this.content, 300);
                        }
                    Severity: Major
                    Found in resources/js/components/collapsible.js and 1 other location - About 1 hr to fix
                    resources/js/components/collapsible.js on lines 27..31

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

                    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

                        close() {
                            this.container.classList.remove('open');
                            this.trigger.setAttribute('aria-expanded', 'false');
                            slideUp(this.content, 300);
                        }
                    Severity: Major
                    Found in resources/js/components/collapsible.js and 1 other location - About 1 hr to fix
                    resources/js/components/collapsible.js on lines 21..25

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

                    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

                    Consider simplifying this complex logical expression.
                    Open

                            if ($model instanceof Chapter) {
                                $hasPermission = userCan('book-update', $currentParent)
                                    && userCan('book-update', $newBook)
                                    && userCan('chapter-update', $model)
                                    && (!$hasNewParent || userCan('chapter-create', $newBook))
                    Severity: Major
                    Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

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

                          updated(a, b) {
                              const aTime = Number(a.getAttribute('data-updated'));
                              const bTime = Number(b.getAttribute('data-updated'));
                              return bTime - aTime;
                          },
                      Severity: Major
                      Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
                      resources/js/components/book-sort.js on lines 12..16

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

                      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

                              for (const toggleAllElem of (this.$manyRefs.toggleAll || [])) {
                                  toggleAllElem.addEventListener('click', this.toggleAllClick.bind(this));
                              }
                      Severity: Minor
                      Found in resources/js/components/permissions-table.js and 1 other location - About 55 mins to fix
                      resources/js/components/permissions-table.js on lines 16..18

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

                      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

                              for (const toggleRowElem of (this.$manyRefs.toggleRow || [])) {
                                  toggleRowElem.addEventListener('click', this.toggleRowClick.bind(this));
                              }
                      Severity: Minor
                      Found in resources/js/components/permissions-table.js and 1 other location - About 55 mins to fix
                      resources/js/components/permissions-table.js on lines 11..13

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

                      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