BookStackApp/BookStack

View on GitHub

Showing 205 of 290 total issues

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/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 request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function request(url, options = {}) {
          let requestUrl = url;
      
          if (!requestUrl.startsWith('http')) {
              requestUrl = window.baseUrl(requestUrl);
      Severity: Minor
      Found in resources/js/services/http.js - About 1 hr to fix

        Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function init(editor) {
            const Code = await window.importVersioned('code');
        
            /**
             * @param {ViewUpdate} v
        Severity: Minor
        Found in resources/js/markdown/codemirror.js - 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 formatSingle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function formatSingle(Entity $entity): array
            {
                $result = [];
                $values = (clone $entity)->toArray();
        
        
        Severity: Minor
        Found in app/Api/ApiEntityListFormatter.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 getConnection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getConnection()
            {
                if ($this->ldapConnection !== null) {
                    return $this->ldapConnection;
                }
        Severity: Minor
        Found in app/Access/LdapService.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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function parse(): int
            {
                $nodesAdded = 0;
                $tags = $this->locateAndIsolateIncludeTags();
        
        
        Severity: Minor
        Found in app/Entities/Tools/PageIncludeParser.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 ensureDeletable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function ensureDeletable(Entity $entity): void
            {
                $customHomeId = intval(explode(':', setting('app-homepage', '0:'))[0]);
                $customHomeActive = setting('app-homepage-type') === 'page';
                $removeCustomHome = false;
        Severity: Minor
        Found in app/Entities/Tools/TrashCan.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

        Method getConnection has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getConnection()
            {
                if ($this->ldapConnection !== null) {
                    return $this->ldapConnection;
                }
        Severity: Minor
        Found in app/Access/LdapService.php - About 1 hr to fix

          Function buildForInput has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function buildForInput(options) {
              // Set language
              window.tinymce.addI18n(options.language, options.translationMap);
          
              // BookStack Version
          Severity: Minor
          Found in resources/js/wysiwyg/config.js - About 1 hr to fix

            Function createUploadFromFile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                createUploadFromFile(file) {
                    const {
                        dom, status, progress, dismiss,
                    } = this.createDomForFile(file);
                    this.statusArea.append(dom);
            Severity: Minor
            Found in resources/js/components/dropzone.js - About 1 hr to fix

              Method processUsers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function processUsers(array $users, UserAvatars $userAvatar): int
                  {
                      $dryRun = !$this->option('force');
                      $this->info(count($users) . " user(s) found to update avatars for.");
              
              
              Severity: Minor
              Found in app/Console/Commands/RefreshAvatarCommand.php - About 1 hr to fix

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

                    setupListeners() {
                        this.elem.addEventListener('click', this.onClick.bind(this));
                
                        let lastSearch = 0;
                        this.searchInput.addEventListener('input', () => {
                Severity: Minor
                Found in resources/js/components/entity-selector.js - About 1 hr to fix

                  Function setupDropTargetHandlers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      setupDropTargetHandlers() {
                          let depth = 0;
                  
                          const reset = () => {
                              this.hideOverlay();
                  Severity: Minor
                  Found in resources/js/components/dropzone.js - About 1 hr to fix

                    Method decode has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected static function decode(string $searchString): array
                        {
                            $terms = [
                                'searches' => [],
                                'exacts'   => [],
                    Severity: Minor
                    Found in app/Search/SearchOptions.php - About 1 hr to fix

                      Method getConverterEnvironment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function getConverterEnvironment(): Environment
                          {
                              $environment = new Environment([
                                  'header_style'            => 'atx', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2
                                  'suppress_errors'         => true, // Set to false to show warnings when loading malformed HTML
                      Severity: Minor
                      Found in app/Entities/Tools/Markdown/HtmlToMarkdown.php - About 1 hr to fix

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

                            public function saveNew(string $imageName, string $imageData, string $type, int $uploadedTo = 0): Image
                            {
                                $disk = $this->storage->getDisk($type);
                                $secureUploads = setting('app-secure-images');
                                $fileName = $this->storage->cleanImageFileName($imageName);
                        Severity: Minor
                        Found in app/Uploads/ImageService.php - About 1 hr to fix

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

                              public function queryWithTotals(SimpleListOptions $listOptions, string $nameFilter): Builder
                              {
                                  $searchTerm = $listOptions->getSearch();
                                  $sort = $listOptions->getSort();
                                  if ($sort === 'name' && $nameFilter) {
                          Severity: Minor
                          Found in app/Activity/TagRepo.php - About 1 hr to fix

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

                                setup() {
                                    this.elem = this.$el;
                            
                                    this.pageId = this.$opts.pageId;
                                    this.textDirection = this.$opts.textDirection;
                            Severity: Minor
                            Found in resources/js/components/markdown-editor.js - About 1 hr to fix

                              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
                                Severity
                                Category
                                Status
                                Source
                                Language