BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function collectBuildInformation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function collectBuildInformation(): string {
  let compatibleEditors = 0;
  const incompatibleEditors = new Set<string>();
  const thisVersion = LexicalEditor.version;
  if (typeof window !== 'undefined') {
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.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

Method addOptionsFromString has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function addOptionsFromString(string $searchString): void
    {
        /** @var array<string, SearchOption[]> $terms */
        $terms = [
            'exacts'   => [],
Severity: Minor
Found in app/Search/SearchOptions.php - About 1 hr to fix

    Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run()
        {
            // Create an editor user
            $editorUser = User::factory()->create();
            $editorRole = Role::getRole('editor');
    Severity: Minor
    Found in database/seeders/DummyContentSeeder.php - About 1 hr to fix

      Function removeList has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function removeList(editor: LexicalEditor): void {
        editor.update(() => {
          const selection = $getSelection();
      
          if ($isRangeSelection(selection)) {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 1 hr to fix

        Function setRootElement has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          setRootElement(nextRootElement: null | HTMLElement): void {
            const prevRootElement = this._rootElement;
        
            if (nextRootElement !== prevRootElement) {
              const classNames = getCachedClassNameArray(this._config.theme, 'root');
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 1 hr to fix

          Function handleTableCellRangeEvents has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function handleTableCellRangeEvents(editor) {
              /** @var {HTMLTableCellElement[]} * */
              let selectedCells = [];
          
              editor.on('TableSelectionChange', event => {
          Severity: Minor
          Found in resources/js/wysiwyg-tinymce/fixes.js - About 1 hr to fix

            Function handleEmbedAlignmentChanges has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function handleEmbedAlignmentChanges(editor) {
                function updateClassesForPreview(previewElem) {
                    const mediaTarget = previewElem.querySelector('iframe, video');
                    if (!mediaTarget) {
                        return;
            Severity: Minor
            Found in resources/js/wysiwyg-tinymce/fixes.js - About 1 hr to fix

              Method isSortChangePermissible has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function isSortChangePermissible(BookSortMapItem $sortMapItem, BookChild $model, ?Entity $currentParent, ?Entity $newBook, ?Entity $newChapter): bool
                  {
                      // Stop if we can't see the current parent or new book.
                      if (!$currentParent || !$newBook) {
                          return false;
              Severity: Minor
              Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

                Function $getSelectionStyleValueForProperty has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function $getSelectionStyleValueForProperty(
                  selection: RangeSelection | TableSelection,
                  styleProperty: string,
                  defaultValue = '',
                ): string {
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/selection/range-selection.ts - About 1 hr to fix

                  Function select has 38 lines of code (exceeds 25 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

                    Function handleMediaInsert has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function handleMediaInsert(data: DataTransfer, context: EditorUiContext): boolean {
                        const clipboard = new Clipboard(data);
                        let handled = false;
                    
                        // Don't handle the event ourselves if no items exist of contains table-looking data
                    Severity: Minor
                    Found in resources/js/wysiwyg/services/drop-paste-handling.ts - About 1 hr to fix

                      Function setupTestCase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            const setupTestCase = (
                              cb: (selection: RangeSelection, el: ElementNode) => void,
                            ) => {
                              const editor = createTestEditor();
                      
                      

                        Function setupTestCase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              const setupTestCase = (
                                cb: (selection: RangeSelection, el: ElementNode) => void,
                              ) => {
                                const editor = createTestEditor();
                        
                        

                          Function _syncChildFromLexical has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _syncChildFromLexical(
                              binding: Binding,
                              index: number,
                              key: NodeKey,
                              prevNodeMap: null | NodeMap,
                          Severity: Minor
                          Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.ts - About 1 hr to fix

                            Function setupTestCase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  const setupTestCase = (
                                    cb: (selection: RangeSelection, el: ElementNode) => void,
                                  ) => {
                                    const editor = createTestEditor();
                            
                            

                              Function $sliceSelectedTextNodeContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function $sliceSelectedTextNodeContent(
                                selection: BaseSelection,
                                textNode: TextNode,
                              ): LexicalNode {
                                const anchorAndFocus = selection.getStartEndPoints();
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 1 hr to fix

                                Function replace has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  replace<N extends LexicalNode>(
                                    replaceWithNode: N,
                                    includeChildren?: boolean,
                                  ): N {
                                    if ($isListItemNode(replaceWithNode)) {
                                Severity: Minor
                                Found in resources/js/wysiwyg/lexical/list/LexicalListItemNode.ts - About 1 hr to fix

                                  Function setup has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                        const setup = async (
                                          mode: 'start-of-paragraph' | 'mid-paragraph' | 'end-of-paragraph',
                                        ) => {
                                          const {container, editor} = testEnv;
                                  
                                  

                                    Function mergeAction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        const mergeAction = (() => {
                                          const isSameEditor =
                                            currentHistoryEntry === null || currentHistoryEntry.editor === editor;
                                          const shouldPushHistory = tags.has('history-push');
                                          const shouldMergeHistory =
                                    Severity: Minor
                                    Found in resources/js/wysiwyg/lexical/history/index.ts - About 1 hr to fix

                                      Function $normalizeTextNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      export function $normalizeTextNode(textNode: TextNode): void {
                                        let node = textNode;
                                      
                                        if (node.__text === '' && node.isSimpleText() && !node.isUnmergeable()) {
                                          node.remove();
                                      Severity: Minor
                                      Found in resources/js/wysiwyg/lexical/core/LexicalNormalization.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language