BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

  for (let i = 0; i < topLevelChildren.length; i++) {
    const topLevelNode = topLevelChildren[i];
    $appendNodesToJSON(editor, selection, topLevelNode, nodes);
  }
Severity: Minor
Found in resources/js/wysiwyg/lexical/clipboard/clipboard.ts and 1 other location - About 40 mins to fix
resources/js/wysiwyg/lexical/html/index.ts on lines 83..86

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

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 (let i = 0; i < topLevelChildren.length; i++) {
    const topLevelNode = topLevelChildren[i];
    $appendNodesToHTML(editor, topLevelNode, container, selection);
  }
Severity: Minor
Found in resources/js/wysiwyg/lexical/html/index.ts and 1 other location - About 40 mins to fix
resources/js/wysiwyg/lexical/clipboard/clipboard.ts on lines 347..350

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

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

  } else if (
    collabNode instanceof CollabTextNode &&
    event instanceof YMapEvent
  ) {
    const {keysChanged} = event;
Severity: Minor
Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.ts and 1 other location - About 40 mins to fix
resources/js/wysiwyg/lexical/yjs/SyncEditorStates.ts on lines 66..78

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

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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $name,
        UserProvider $provider,
        Session $session,
        LdapService $ldapService,
        RegistrationService $registrationService
Severity: Minor
Found in app/Access/Guards/LdapSessionGuard.php - About 35 mins to fix

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

            string $imageData,
            ?int $width,
            ?int $height,
            bool $keepRatio,
            ?string $format = null,
    Severity: Minor
    Found in app/Uploads/ImageResizer.php - 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(string $event, Webhook $webhook, string|Loggable $detail, User $initiator, int $initiatedTime)
        Severity: Minor
        Found in app/Activity/Tools/WebhookFormatter.php - About 35 mins to fix

          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-tinymce/plugin-codeeditor.js - About 35 mins to fix

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

                protected function createJointPermissionData(SimpleEntityData $entity, int $roleId, MassEntityPermissionEvaluator $permissionMap, array $rolePermissionMap, bool $isAdminRole): array
            Severity: Minor
            Found in app/Permissions/JointPermissionBuilder.php - About 35 mins to fix

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

                  public static function getDefault(string $event, Webhook $webhook, $detail, User $initiator, int $initiatedTime): self
              Severity: Minor
              Found in app/Activity/Tools/WebhookFormatter.php - About 35 mins to fix

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

                    protected function sendNotificationToUserIds(string $notification, array $userIds, User $initiator, string|Loggable $detail, Entity $relatedModel): void
                Severity: Minor
                Found in app/Activity/Notifications/Handlers/BaseNotificationHandler.php - About 35 mins to fix

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

                      protected function applyNegatableWhere(EloquentBuilder $query, bool $negated, string $column, string $operator, mixed $value): void
                  Severity: Minor
                  Found in app/Search/SearchRunner.php - About 35 mins to fix

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

                            Connection $db,
                            string $table,
                            string $column,
                            string $oldUrl,
                            string $newUrl
                    Severity: Minor
                    Found in app/Console/Commands/UpdateUrlCommand.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

                        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

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

                          export function buildEditorUI(container: HTMLElement, element: HTMLElement, scrollContainer: HTMLElement, editor: LexicalEditor, options: Record<string, any>): EditorUiContext {
                          Severity: Minor
                          Found in resources/js/wysiwyg/ui/index.ts - 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 __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 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 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language