BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

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

function $normalizePoint(point: PointType): void {
  while (point.type === 'element') {
    const node = point.getNode();
    const offset = point.offset;
    let nextNode;
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalNormalization.ts - About 1 hr to fix

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

    function $wrapInlineNodes(nodes: LexicalNode[]) {
      // We temporarily insert the topLevelNodes into an arbitrary ElementNode,
      // since insertAfter does not work on nodes that have no parent (TO-DO: fix that).
      const virtualRoot = $createParagraphNode();
    
    
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

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

      export function triggerCommandListeners<
        TCommand extends LexicalCommand<unknown>,
      >(
        editor: LexicalEditor,
        type: TCommand,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 1 hr to fix

        Function handle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handle(Connection $db): int
            {
                $oldUrl = str_replace("'", '', $this->argument('oldUrl'));
                $newUrl = str_replace("'", '', $this->argument('newUrl'));
        
        
        Severity: Minor
        Found in app/Console/Commands/UpdateUrlCommand.php - About 1 hr 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 sendNotificationToUserIds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function sendNotificationToUserIds(string $notification, array $userIds, User $initiator, string|Loggable $detail, Entity $relatedModel): void
            {
                $users = User::query()->whereIn('id', array_unique($userIds))->get();
        
                foreach ($users as $user) {
        Severity: Minor
        Found in app/Activity/Notifications/Handlers/BaseNotificationHandler.php - About 1 hr 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 handle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handle(PermissionsUpdater $permissionsUpdater, BookshelfQueries $queries): int
            {
                $shelfSlug = $this->option('slug');
                $cascadeAll = $this->option('all');
                $shelves = null;
        Severity: Minor
        Found in app/Console/Commands/CopyShelfPermissionsCommand.php - About 1 hr 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 callback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function callback(Request $request, string $socialDriver)
            {
                if (!session()->has('social-callback')) {
                    throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
                }
        Severity: Minor
        Found in app/Access/Controllers/SocialController.php - About 1 hr 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 cloneBook has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function cloneBook(Book $original, string $newName): Book
            {
                $bookDetails = $this->entityToInputData($original);
                $bookDetails['name'] = $newName;
        
        
        Severity: Minor
        Found in app/Entities/Tools/Cloner.php - About 1 hr 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 init has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected init() {
                this.unregisterMutationListener = this.editor.registerMutationListener(CustomTableNode, (mutations) => {
                    for (const [nodeKey, mutation] of mutations) {
                        if (mutation === 'created') {
                            this.editor.getEditorState().read(() => {

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

            public function fetch(string $entityType, int $entityId): Collection
            {
                $entity = (new EntityProvider())->get($entityType)->visible()->findOrFail($entityId);
                $entities = [];
        
        
        Severity: Minor
        Found in app/Entities/Tools/SiblingFetcher.php - About 1 hr 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 fromRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function fromRequest(Request $request): self
            {
                if (!$request->has('search') && !$request->has('term')) {
                    return static::fromString('');
                }
        Severity: Minor
        Found in app/Search/SearchOptions.php - About 1 hr 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 applySortUpdates has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function applySortUpdates(BookSortMapItem $sortMapItem, array $modelMap): void
            {
                /** @var BookChild $model */
                $model = $modelMap[$sortMapItem->type . ':' . $sortMapItem->id] ?? null;
                if (!$model) {
        Severity: Minor
        Found in app/Entities/Tools/BookContents.php - About 1 hr 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 updateDOM has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            updateDOM(prevNode: MediaNode, dom: HTMLElement): boolean {
                if (prevNode.__tag !== this.__tag) {
                    return true;
                }
        
        
        Severity: Minor
        Found in resources/js/wysiwyg/nodes/media.ts - About 1 hr 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 getListItemsForSelection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function getListItemsForSelection(selection: BaseSelection|null): (CustomListItemNode|null)[] {
            const nodes = selection?.getNodes() || [];
            const listItemNodes = [];
        
            outer: for (const node of nodes) {
        Severity: Minor
        Found in resources/js/wysiwyg/utils/lists.ts - About 1 hr 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 validateRowsToCopy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export function validateRowsToCopy(rows: CustomTableRowNode[]): void {
            let commonRowSize: number|null = null;
        
            for (const row of rows) {
                const cells = row.getChildren().filter(n => $isCustomTableCellNode(n));
        Severity: Minor
        Found in resources/js/wysiwyg/utils/table-copy-paste.ts - About 1 hr 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 registerCommonNodeMutationListeners has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export function registerCommonNodeMutationListeners(context: EditorUiContext): void {
            const decorated = [ImageNode, CodeBlockNode, DiagramNode];
        
            const decorationDestroyListener = (mutations: Map<string, NodeMutation>): void => {
                for (let [nodeKey, mutation] of mutations) {
        Severity: Minor
        Found in resources/js/wysiwyg/nodes/index.ts - About 1 hr 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 isExcludedProperty has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function isExcludedProperty(
          name: string,
          node: LexicalNode,
          binding: Binding,
        ): boolean {
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/yjs/Utils.ts - About 1 hr 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 $handleListInsertParagraph has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export function $handleListInsertParagraph(): boolean {
          const selection = $getSelection();
        
          if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
            return false;
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 1 hr 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 onDocumentSelectionChange has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function onDocumentSelectionChange(event: Event): void {
          const target = event.target as null | Element | Document;
          const targetWindow =
            target == null
              ? null
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr 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 forwardDeletion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          forwardDeletion(
            anchor: PointType,
            anchorNode: TextNode | ElementNode,
            isBackward: boolean,
          ): boolean {
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr 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