BookStackApp/BookStack

View on GitHub

Showing 203 of 288 total issues

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

    async saveDraft() {
        const data = {name: this.titleElem.value.trim()};

        const editorContent = this.getEditorComponent().getContent();
        Object.assign(data, editorContent);
Severity: Minor
Found in resources/js/components/page-editor.js - About 1 hr to fix

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

        public function processLoginCallback(string $samlID, array $samlAttributes): User
        {
            $userDetails = $this->getUserDetails($samlID, $samlAttributes);
            $isLoggedIn = auth()->check();
    
    
    Severity: Minor
    Found in app/Access/Saml2Service.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

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

            protected function getUserDetailsFromToken(OidcIdToken $idToken, OidcAccessToken $accessToken, OidcProviderSettings $settings): OidcUserDetails
            {
                $userDetails = new OidcUserDetails();
                $userDetails->populate(
                    $idToken,
        Severity: Minor
        Found in app/Access/Oidc/OidcService.php - About 1 hr to fix

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

              protected function containHtml(string $htmlContent): string
              {
                  $imageTagsOutput = [];
                  preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);
          
          
          Severity: Minor
          Found in app/Entities/Tools/ExportFormatter.php - About 1 hr to fix

            Function request has a Cognitive Complexity of 10 (exceeds 5 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

            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 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 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 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 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

            Method loadFromJwkArray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function loadFromJwkArray(array $jwk)
                {
                    // 'alg' is optional for a JWK, but we will still attempt to validate if
                    // it exists otherwise presume it will be compatible.
                    $alg = $jwk['alg'] ?? null;
            Severity: Minor
            Found in app/Access/Oidc/OidcJwtSigningKey.php - About 1 hr to fix

              Method checkUserHasAccessToRelationOfImageAtPath has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function checkUserHasAccessToRelationOfImageAtPath(string $path): bool
                  {
                      if (str_starts_with($path, 'uploads/images/')) {
                          $path = substr($path, 15);
                      }
              Severity: Minor
              Found in app/Uploads/ImageService.php - About 1 hr to fix

                Method getProviderSettings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function getProviderSettings(): OidcProviderSettings
                    {
                        $config = $this->config();
                        $settings = new OidcProviderSettings([
                            'issuer'                => $config['issuer'],
                Severity: Minor
                Found in app/Access/Oidc/OidcService.php - About 1 hr to fix

                  Method createManyJointPermissions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function createManyJointPermissions(array $originalEntities, array $roles)
                      {
                          $entities = $this->entitiesToSimpleEntities($originalEntities);
                          $jointPermissions = [];
                  
                  
                  Severity: Minor
                  Found in app/Permissions/JointPermissionBuilder.php - About 1 hr to fix

                    Method attempt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function attempt(array $credentials = [], $remember = false)
                        {
                            $username = $credentials['username'];
                            $userDetails = $this->ldapService->getUserDetails($username);
                    
                    
                    Severity: Minor
                    Found in app/Access/Guards/LdapSessionGuard.php - About 1 hr to fix

                      Function parsePlural has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          parsePlural(translation, count, replacements) {
                              const splitText = translation.split('|');
                              const exactCountRegex = /^{([0-9]+)}/;
                              const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
                              let result = null;
                      Severity: Minor
                      Found in resources/js/services/translations.js - About 1 hr to fix

                        Function paste has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function paste(editor, options, event) {
                            const clipboard = new Clipboard(event.clipboardData || event.dataTransfer);
                        
                            // Don't handle the event ourselves if no items exist of contains table-looking data
                            if (!clipboard.hasItems() || clipboard.containsTabularData()) {
                        Severity: Minor
                        Found in resources/js/wysiwyg/drop-paste-handling.js - About 1 hr to fix

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

                              setup() {
                                  // Options
                                  this.uploadedTo = this.$opts.uploadedTo;
                          
                                  // Element References
                          Severity: Minor
                          Found in resources/js/components/image-manager.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language