BookStackApp/BookStack

View on GitHub

Showing 203 of 288 total issues

Method handle has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle(UserRepo $userRepo): int
    {
        $details = $this->snakeCaseOptions();

        if (empty($details['email'])) {
Severity: Minor
Found in app/Console/Commands/CreateAdminCommand.php - About 1 hr to fix

    Method applySortUpdates has 32 lines of code (exceeds 25 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

      Method build has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function build(): array
          {
              $page = clone $this->page;
              $isDraft = boolval($this->page->draft);
              $templates = $this->queries->pages->visibleTemplates()
      Severity: Minor
      Found in app/Entities/Tools/PageEditorData.php - About 1 hr to fix

        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 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/config.js - About 1 hr to fix

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

            function getSetupCallback(options) {
                return function setupCallback(editor) {
                    function editorChange() {
                        if (options.darkMode) {
                            editor.contentDocument.documentElement.classList.add('dark-mode');
            Severity: Minor
            Found in resources/js/wysiwyg/config.js - About 1 hr to fix

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

                  protected function loadModelsFromSortMap(BookSortMap $sortMap): array
                  {
                      $modelMap = [];
                      $ids = [
                          'chapter' => [],
              Severity: Minor
              Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

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

                    public function show(string $bookSlug, string $pageSlug)
                    {
                        try {
                            $page = $this->queries->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
                        } catch (NotFoundException $e) {
                Severity: Minor
                Found in app/Entities/Controllers/PageController.php - About 1 hr to fix

                  Function setupListeners has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      setupListeners() {
                          const keyboardNavHandler = new KeyboardNavigationHandler(this.container, event => {
                              this.hide();
                              this.toggle.focus();
                              if (!this.bubbleEscapes) {
                  Severity: Minor
                  Found in resources/js/components/dropdown.js - About 1 hr to fix

                    Method handle has 30 lines of code (exceeds 25 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

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

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

                        Function setupListeners has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            setupListeners() {
                                // Copy on copy button click
                                this.includeButton.addEventListener('click', () => copyTextToClipboard(this.includeInput.value));
                                this.linkButton.addEventListener('click', () => copyTextToClipboard(this.linkInput.value));
                        
                        
                        Severity: Minor
                        Found in resources/js/components/pointer.js - About 1 hr to fix

                          Method orientImageToOriginalExif has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function orientImageToOriginalExif(InterventionImage $image, string $originalData): void
                              {
                                  if (!extension_loaded('exif')) {
                                      return;
                                  }
                          Severity: Minor
                          Found in app/Uploads/ImageResizer.php - About 1 hr to fix

                            Function detailsDialog has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function detailsDialog(editor) {
                                return {
                                    title: 'Edit collapsible block',
                                    body: {
                                        type: 'panel',
                            Severity: Minor
                            Found in resources/js/wysiwyg/plugins-details.js - About 1 hr to fix

                              Method handleLoginCallback has 29 lines of code (exceeds 25 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 1 hr to fix

                                Method registerUser has 29 lines of code (exceeds 25 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 1 hr to fix

                                  Function setupCallback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      return function setupCallback(editor) {
                                          function editorChange() {
                                              if (options.darkMode) {
                                                  editor.contentDocument.documentElement.classList.add('dark-mode');
                                              }
                                  Severity: Minor
                                  Found in resources/js/wysiwyg/config.js - About 1 hr to fix

                                    Method searchEntities has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function searchEntities(SearchOptions $searchOpts, string $entityType = 'all', int $page = 1, int $count = 20): array
                                        {
                                            $entityTypes = array_keys($this->entityProvider->all());
                                            $entityTypesToSearch = $entityTypes;
                                    
                                    
                                    Severity: Minor
                                    Found in app/Search/SearchRunner.php - About 1 hr to fix

                                      Method update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function update(Request $request, int $id)
                                          {
                                              $this->preventAccessInDemoMode();
                                              $this->checkPermission('users-manage');
                                      
                                      
                                      Severity: Minor
                                      Found in app/Users/Controllers/UserController.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language