BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function focus has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  focus(callbackFn?: () => void, options: EditorFocusOptions = {}): void {
    const rootElement = this._rootElement;

    if (rootElement !== null) {
      // This ensures that iOS does not trigger caps lock upon focus
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 1 hr to fix

    Function importDOM has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        static importDOM(): DOMConversionMap|null {
            return {
                p(node: HTMLElement): DOMConversion|null {
                    if (node.classList.contains('callout')) {
                        return {
    Severity: Minor
    Found in resources/js/wysiwyg/nodes/callout.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 updateIdsRecursively has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateIdsRecursively(DOMNode $element, int $depth, array &$idMap, array &$changeMap): void
        {
            /* @var DOMNode $child */
            foreach ($element->childNodes as $child) {
                if ($child instanceof DOMElement && ($depth === 0 || in_array($child->nodeName, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) || $child->getAttribute('id'))) {
    Severity: Minor
    Found in app/Entities/Tools/PageContent.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 getFieldByName has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected getFieldByName(name: string): EditorFormField|null {
    
            const search = (children: EditorUiElement[]): EditorFormField|null => {
                for (const child of children) {
                    if (child instanceof EditorFormField && child.getName() === name) {
    Severity: Minor
    Found in resources/js/wysiwyg/ui/framework/forms.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 getRangeForCell has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public getRangeForCell(cell: CustomTableCellNode): CellRange|null {
            let range: CellRange|null = null;
            const cellKey = cell.getKey();
    
            for (let y = 0; y < this.rowCount; y++) {
    Severity: Minor
    Found in resources/js/wysiwyg/utils/table-map.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 updateTemplateStatusAndContentFromInput has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateTemplateStatusAndContentFromInput(Page $page, array $input)
        {
            if (isset($input['template']) && userCan('templates-manage')) {
                $page->template = ($input['template'] === 'true');
            }
    Severity: Minor
    Found in app/Entities/Repos/PageRepo.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 setupEditor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected setupEditor(editor: LexicalEditor) {
            // Register our DOM decorate listener with the editor
            const domDecorateListener: DecoratorListener<EditorDecoratorAdapter> = (decorators: Record<NodeKey, EditorDecoratorAdapter>) => {
                editor.getEditorState().read(() => {
                    const keys = Object.keys(decorators);
    Severity: Minor
    Found in resources/js/wysiwyg/ui/framework/manager.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 createDOMRange has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function createDOMRange(
      editor: LexicalEditor,
      anchorNode: LexicalNode,
      _anchorOffset: number,
      focusNode: LexicalNode,
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/selection/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 $syncLocalCursorPosition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function $syncLocalCursorPosition(
      binding: Binding,
      provider: Provider,
    ): void {
      const awareness = provider.awareness;
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.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 collapseAtStart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      collapseAtStart(selection: RangeSelection): true {
        const paragraph = $createParagraphNode();
        const children = this.getChildren();
        children.forEach((child) => paragraph.append(child));
        const listNode = this.getParentOrThrow();
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/list/LexicalListItemNode.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 $forEachTableCell has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function $forEachTableCell(
      grid: TableDOMTable,
      cb: (
        cell: TableDOMCell,
        lexicalNode: LexicalNode,
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 $onCompositionEndImpl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function $onCompositionEndImpl(editor: LexicalEditor, data?: string): void {
      const compositionKey = editor._compositionKey;
      $setCompositionKey(null);
    
      // Handle termination of composition.
    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 $createChildren has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function $createChildren(
      children: Array<NodeKey>,
      element: ElementNode,
      _startIndex: number,
      endIndex: number,
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.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 isOnlyChildInBlockNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function isOnlyChildInBlockNode(node: Node): boolean {
      const parentElement = node.parentElement;
      if (parentElement !== null && isBlockDomNode(parentElement)) {
        const firstChild = parentElement.firstChild!;
        if (
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/nodes/LexicalLineBreakNode.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 $updateSelectedTextFromDOM has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function $updateSelectedTextFromDOM(
      isCompositionEnd: boolean,
      editor: LexicalEditor,
      data?: string,
    ): void {
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalUtils.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 $setCompositionKey has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function $setCompositionKey(compositionKey: null | NodeKey): void {
      errorOnReadOnly();
      const editor = getActiveEditor();
      const previousCompositionKey = editor._compositionKey;
      if (compositionKey !== previousCompositionKey) {
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalUtils.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 select has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      select(_anchorOffset?: number, _focusOffset?: number): RangeSelection {
        errorOnReadOnly();
        let anchorOffset = _anchorOffset;
        let focusOffset = _focusOffset;
        const selection = $getSelection();
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.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 setupBookSortable has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setupBookSortable(bookContainer) {
            const sortElems = Array.from(bookContainer.querySelectorAll('.sort-list, .sortable-page-sublist'));
    
            const bookGroupConfig = {
                name: 'book',
    Severity: Minor
    Found in resources/js/components/book-sort.js - About 1 hr to fix

      Function gatherPlugins has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function gatherPlugins(options) {
          const plugins = [
              'image',
              'table',
              'link',
      Severity: Minor
      Found in resources/js/wysiwyg-tinymce/config.js - About 1 hr to fix

        Method rules has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function rules(int $userId = null): array
            {
                return [
                    'create' => [
                        'name'  => ['required', 'string', 'min:1', 'max:100'],
        Severity: Minor
        Found in app/Users/Controllers/UserApiController.php - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language