BookStackApp/BookStack

View on GitHub

Showing 288 of 288 total issues

Function showPopup has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function showPopup(editor, code, language, direction, callback) {
Severity: Minor
Found in resources/js/wysiwyg/plugin-codeeditor.js - About 35 mins to fix

    Method resizeToThumbnailUrl has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            Image $image,
            ?int $width,
            ?int $height,
            bool $keepRatio = false,
            bool $shouldCreate = false
    Severity: Minor
    Found in app/Uploads/ImageResizer.php - About 35 mins to fix

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct(int $id, int $sort, ?int $parentChapterId, string $type, int $parentBookId)
      Severity: Minor
      Found in app/Entities/Tools/BookSortMapItem.php - About 35 mins to fix

        Method isSortChangePermissible has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function isSortChangePermissible(BookSortMapItem $sortMapItem, BookChild $model, ?Entity $currentParent, ?Entity $newBook, ?Entity $newChapter): bool
        Severity: Minor
        Found in app/Entities/Tools/BookContents.php - About 35 mins to fix

          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  protected ShelfContext $shelfContext,
                  protected BookRepo $bookRepo,
                  protected BookQueries $queries,
                  protected BookshelfQueries $shelfQueries,
                  protected ReferenceFetcher $referenceFetcher,
          Severity: Minor
          Found in app/Entities/Controllers/BookController.php - About 35 mins to fix

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    public BookshelfQueries $shelves,
                    public BookQueries $books,
                    public ChapterQueries $chapters,
                    public PageQueries $pages,
                    public PageRevisionQueries $revisions,
            Severity: Minor
            Found in app/Entities/Queries/EntityQueries.php - About 35 mins to fix

              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      protected BookshelfRepo $shelfRepo,
                      protected BookshelfQueries $queries,
                      protected BookQueries $bookQueries,
                      protected ShelfContext $shelfContext,
                      protected ReferenceFetcher $referenceFetcher,
              Severity: Minor
              Found in app/Entities/Controllers/BookshelfController.php - About 35 mins to fix

                Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        protected TagRepo $tagRepo,
                        protected ImageRepo $imageRepo,
                        protected ReferenceUpdater $referenceUpdater,
                        protected ReferenceStore $referenceStore,
                        protected PageQueries $pageQueries,
                Severity: Minor
                Found in app/Entities/Repos/BaseRepo.php - About 35 mins to fix

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

                      public function pageToContainedHtml(Page $page): string
                      {
                          $page->html = (new PageContent($page))->render();
                          $pageHtml = view('exports.page', [
                              'page'       => $page,
                  Severity: Minor
                  Found in app/Entities/Tools/ExportFormatter.php and 1 other location - About 35 mins to fix
                  app/Entities/Tools/ExportFormatter.php on lines 90..101

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

                  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 pageToPdf(Page $page): string
                      {
                          $page->html = (new PageContent($page))->render();
                          $html = view('exports.page', [
                              'page'   => $page,
                  Severity: Minor
                  Found in app/Entities/Tools/ExportFormatter.php and 1 other location - About 35 mins to fix
                  app/Entities/Tools/ExportFormatter.php on lines 31..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 92.

                  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 updateContent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  async function updateContent(pngData) {
                      const loadingImage = window.baseUrl('/loading.gif');
                  
                      const handleUploadError = error => {
                          if (error.status === 413) {
                  Severity: Minor
                  Found in resources/js/wysiwyg/plugin-drawio.js - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function handleLoginCallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleLoginCallback(string $socialDriver, SocialUser $socialUser)
                      {
                          $socialDriver = trim(strtolower($socialDriver));
                          $socialId = $socialUser->getId();
                  
                  
                  Severity: Minor
                  Found in app/Access/SocialAuthService.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function index(
                          Request $request,
                          ActivityQueries $activities,
                          QueryRecentlyViewed $recentlyViewed,
                          QueryTopFavourites $topFavourites,
                  Severity: Minor
                  Found in app/App/HomeController.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function selectItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      selectItem(item) {
                          const isDblClick = this.isDoubleClick();
                          const type = item.getAttribute('data-entity-type');
                          const id = item.getAttribute('data-entity-id');
                          const isSelected = (!item.classList.contains('selected') || isDblClick);
                  Severity: Minor
                  Found in resources/js/components/entity-selector.js - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function outputAndClose has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function outputAndClose(): void
                      {
                          // End & flush the output buffer, if we're in one, otherwise we still use memory.
                          // Output buffer may or may not exist depending on PHP `output_buffering` setting.
                          // Ignore in testing since output buffers are used to gather a response.
                  Severity: Minor
                  Found in app/Http/RangeSupportedStream.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function rebuildForEntity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function rebuildForEntity(Entity $entity)
                      {
                          $entities = [$entity];
                          if ($entity instanceof Book) {
                              $books = $this->bookFetchQuery()->where('id', '=', $entity->id)->get();
                  Severity: Minor
                  Found in app/Permissions/JointPermissionBuilder.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function registerUser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function registerUser(array $userData, ?SocialAccount $socialAccount = null, bool $emailConfirmed = false): User
                      {
                          $userEmail = $userData['email'];
                          $authSystem = $socialAccount ? $socialAccount->driver : auth()->getDefaultDriver();
                  
                  
                  Severity: Minor
                  Found in app/Access/RegistrationService.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function filterElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected static function filterElement(DOMElement $element): void
                      {
                          $elType = strtolower($element->tagName);
                          $allowedAttrs = static::$allowedAttrsByElements[$elType] ?? null;
                          if (is_null($allowedAttrs)) {
                  Severity: Minor
                  Found in app/Util/HtmlDescriptionFilter.php - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function parseRefs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parseRefs(name, element) {
                      const refs = {};
                      const manyRefs = {};
                  
                      const prefix = `${name}@`;
                  Severity: Minor
                  Found in resources/js/services/components.js - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function createManyJointPermissions has a Cognitive Complexity of 7 (exceeds 5 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 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language