BookStackApp/BookStack

View on GitHub

Showing 288 of 288 total issues

modeMap has 74 functions (exceeds 20 allowed). Consider refactoring.
Open

const modeMap = {
    bash: () => legacyLoad('shell'),
    c: () => legacyLoad('c'),
    css: async () => css(),
    'c++': () => legacyLoad('cpp'),
Severity: Major
Found in resources/js/code/languages.js - About 1 day to fix

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

    <?php
    
    namespace BookStack\Entities\Controllers;
    
    use BookStack\Entities\Queries\BookQueries;
    Severity: Major
    Found in app/Entities/Controllers/BookExportApiController.php and 2 other locations - About 1 day to fix
    app/Entities/Controllers/ChapterExportApiController.php on lines 1..66
    app/Entities/Controllers/PageExportApiController.php on lines 1..66

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

    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

    <?php
    
    namespace BookStack\Entities\Controllers;
    
    use BookStack\Entities\Queries\PageQueries;
    Severity: Major
    Found in app/Entities/Controllers/PageExportApiController.php and 2 other locations - About 1 day to fix
    app/Entities/Controllers/BookExportApiController.php on lines 1..66
    app/Entities/Controllers/ChapterExportApiController.php on lines 1..66

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

    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

    <?php
    
    namespace BookStack\Entities\Controllers;
    
    use BookStack\Entities\Queries\ChapterQueries;
    Severity: Major
    Found in app/Entities/Controllers/ChapterExportApiController.php and 2 other locations - About 1 day to fix
    app/Entities/Controllers/BookExportApiController.php on lines 1..66
    app/Entities/Controllers/PageExportApiController.php on lines 1..66

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

    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 list(Request $request, ImageResizer $resizer)
        {
            $page = $request->get('page', 1);
            $searchTerm = $request->get('search', null);
            $uploadedToFilter = $request->get('uploaded_to', null);
    Severity: Major
    Found in app/Uploads/Controllers/GalleryImageController.php and 1 other location - About 7 hrs to fix
    app/Uploads/Controllers/DrawioImageController.php on lines 24..46

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

    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 list(Request $request, ImageResizer $resizer)
        {
            $page = $request->get('page', 1);
            $searchTerm = $request->get('search', null);
            $uploadedToFilter = $request->get('uploaded_to', null);
    Severity: Major
    Found in app/Uploads/Controllers/DrawioImageController.php and 1 other location - About 7 hrs to fix
    app/Uploads/Controllers/GalleryImageController.php on lines 24..46

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

    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 move(Request $request, string $bookSlug, string $chapterSlug)
        {
            $chapter = $this->queries->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
            $this->checkOwnablePermission('chapter-update', $chapter);
            $this->checkOwnablePermission('chapter-delete', $chapter);
    Severity: Major
    Found in app/Entities/Controllers/ChapterController.php and 1 other location - About 5 hrs to fix
    app/Entities/Controllers/PageController.php on lines 401..423

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

    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 move(Request $request, string $bookSlug, string $pageSlug)
        {
            $page = $this->queries->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
            $this->checkOwnablePermission('page-update', $page);
            $this->checkOwnablePermission('page-delete', $page);
    Severity: Major
    Found in app/Entities/Controllers/PageController.php and 1 other location - About 5 hrs to fix
    app/Entities/Controllers/ChapterController.php on lines 191..213

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

    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

    <?php
    
    namespace BookStack\References\ModelResolvers;
    
    use BookStack\App\Model;
    Severity: Major
    Found in app/References/ModelResolvers/PageLinkModelResolver.php and 1 other location - About 4 hrs to fix
    app/References/ModelResolvers/ChapterLinkModelResolver.php on lines 1..33

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

    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

    <?php
    
    namespace BookStack\References\ModelResolvers;
    
    use BookStack\App\Model;
    Severity: Major
    Found in app/References/ModelResolvers/ChapterLinkModelResolver.php and 1 other location - About 4 hrs to fix
    app/References/ModelResolvers/PageLinkModelResolver.php on lines 1..33

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

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

    <?php
    
    namespace BookStack\Search;
    
    use BookStack\Entities\EntityProvider;
    Severity: Minor
    Found in app/Search/SearchRunner.php - About 4 hrs to fix

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

      <?php
      
      namespace BookStack\References\ModelResolvers;
      
      use BookStack\App\Model;
      Severity: Major
      Found in app/References/ModelResolvers/BookLinkModelResolver.php and 1 other location - About 3 hrs to fix
      app/References/ModelResolvers/BookshelfLinkModelResolver.php on lines 1..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 161.

      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

      <?php
      
      namespace BookStack\References\ModelResolvers;
      
      use BookStack\App\Model;
      Severity: Major
      Found in app/References/ModelResolvers/BookshelfLinkModelResolver.php and 1 other location - About 3 hrs to fix
      app/References/ModelResolvers/BookLinkModelResolver.php on lines 1..32

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

      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

          setup() {
              this.container = this.$el;
              this.list = this.$refs.list;
      
              this.searchInput = this.$refs.searchInput;
      Severity: Major
      Found in resources/js/components/template-manager.js and 2 other locations - About 3 hrs to fix
      resources/js/components/entity-permissions.js on lines 6..15
      resources/js/components/list-sort-control.js on lines 9..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 109.

      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

          setup() {
              this.elem = this.$el;
              this.menu = this.$refs.menu;
      
              this.sortInput = this.$refs.sort;
      Severity: Major
      Found in resources/js/components/list-sort-control.js and 2 other locations - About 3 hrs to fix
      resources/js/components/entity-permissions.js on lines 6..15
      resources/js/components/template-manager.js on lines 6..15

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

      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

          setup() {
              this.container = this.$el;
              this.entityType = this.$opts.entityType;
      
              this.everyoneInheritToggle = this.$refs.everyoneInherit;
      Severity: Major
      Found in resources/js/components/entity-permissions.js and 2 other locations - About 3 hrs to fix
      resources/js/components/list-sort-control.js on lines 9..18
      resources/js/components/template-manager.js on lines 6..15

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

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

      function register(editor) {
          editor.ui.registry.addIcon('codeblock', '<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>');
      
          editor.ui.registry.addButton('codeeditor', {
              tooltip: 'Insert code block',
      Severity: Major
      Found in resources/js/wysiwyg/plugin-codeeditor.js - About 3 hrs to fix

        Entity has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class Entity extends Model implements Sluggable, Favouritable, Viewable, Deletable, Loggable
        {
            use SoftDeletes;
            use HasCreatorAndUpdater;
            use HasOwner;
        Severity: Minor
        Found in app/Entities/Models/Entity.php - About 3 hrs to fix

          Function defineCodeBlockCustomElement has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function defineCodeBlockCustomElement(editor) {
              const doc = editor.getDoc();
              const win = doc.defaultView;
          
              class CodeBlockElement extends win.HTMLElement {
          Severity: Major
          Found in resources/js/wysiwyg/plugin-codeeditor.js - About 3 hrs to fix

            SearchRunner has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class SearchRunner
            {
                /**
                 * Acceptable operators to be used in a query.
                 *
            Severity: Minor
            Found in app/Search/SearchRunner.php - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language