BookStackApp/BookStack

View on GitHub

Showing 203 of 288 total issues

Function createTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function createTree(array $comments): array
    {
        $byId = [];
        foreach ($comments as $comment) {
            $byId[$comment->local_id] = $comment;
Severity: Minor
Found in app/Activity/Tools/CommentTree.php - About 45 mins 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 getEntityFiltered has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $type,
        ?string $filterType,
        int $page,
        int $pageSize,
        int $uploadedTo,
Severity: Minor
Found in app/Uploads/ImageRepo.php - About 45 mins to fix

    Function setActiveTab has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        setActiveTab(tabName, openToolbox = false) {
            // Set button visibility
            for (const button of this.buttons) {
                button.classList.remove('active');
                const bName = button.dataset.tab;
    Severity: Minor
    Found in resources/js/components/editor-toolbox.js - About 45 mins 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 drawReceive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function drawReceive(event) {
        if (!event.data || event.data.length < 1) return;
        if (event.origin !== lastApprovedOrigin) return;
    
        const message = JSON.parse(event.data);
    Severity: Minor
    Found in resources/js/services/drawio.js - About 45 mins 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 processAccessTokenCallback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function processAccessTokenCallback(OidcAccessToken $accessToken, OidcProviderSettings $settings): User
        {
            $idTokenText = $accessToken->getIdToken();
            $idToken = new OidcIdToken(
                $idTokenText,
    Severity: Minor
    Found in app/Access/Oidc/OidcService.php - About 45 mins 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function update(User $user, array $data, bool $manageUsersAllowed): User
        {
            if (!empty($data['name'])) {
                $user->name = $data['name'];
                $user->refreshSlug();
    Severity: Minor
    Found in app/Users/UserRepo.php - About 45 mins 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 getProviderSettings has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 saveNew has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function saveNew(UploadedFile $uploadFile, string $type, int $uploadedTo = 0, int $resizeWidth = null, int $resizeHeight = null, bool $keepRatio = true): Image
    Severity: Minor
    Found in app/Uploads/ImageRepo.php - About 45 mins to fix

      Function loadSettingsFromIssuerDiscovery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function loadSettingsFromIssuerDiscovery(ClientInterface $httpClient): array
          {
              $issuerUrl = rtrim($this->issuer, '/') . '/.well-known/openid-configuration';
              $request = new Request('GET', $issuerUrl);
              $response = $httpClient->sendRequest($request);
      Severity: Minor
      Found in app/Access/Oidc/OidcProviderSettings.php - About 45 mins 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 sortUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function sortUrl(string $path, array $data, array $overrideData = []): string
      {
          $queryStringSections = [];
          $queryData = array_merge($data, $overrideData);
      
      
      Severity: Minor
      Found in app/App/helpers.php - About 45 mins 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 imageUrlToBase64 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function imageUrlToBase64(string $url): ?string
          {
              $storagePath = $this->storage->urlToPath($url);
              if (empty($url) || is_null($storagePath)) {
                  return null;
      Severity: Minor
      Found in app/Uploads/ImageService.php - About 45 mins 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 getPermissionMapByTypeIdAndRoleForAllInvolved has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getPermissionMapByTypeIdAndRoleForAllInvolved(): array
          {
              if (isset($this->permissionMapCache)) {
                  return $this->permissionMapCache;
              }
      Severity: Minor
      Found in app/Permissions/MassEntityPermissionEvaluator.php - About 45 mins 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 saveNewFromUpload has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              UploadedFile $uploadedFile,
              string $type,
              int $uploadedTo = 0,
              int $resizeWidth = null,
              int $resizeHeight = null,
      Severity: Minor
      Found in app/Uploads/ImageService.php - About 45 mins to fix

        Function elem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function elem(tagName, attrs = {}, children = []) {
            const el = document.createElement(tagName);
        
            for (const [key, val] of Object.entries(attrs)) {
                if (val === null) {
        Severity: Minor
        Found in resources/js/services/dom.js - About 45 mins 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 getPaginatedByType has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                string $type,
                int $page = 0,
                int $pageSize = 24,
                int $uploadedTo = null,
                string $search = null,
        Severity: Minor
        Found in app/Uploads/ImageRepo.php - About 45 mins to fix

          Function updateTemplateStatusAndContentFromInput has a Cognitive Complexity of 8 (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 45 mins 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 searchEntities has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  protected BaseRepo $baseRepo,
                  protected RevisionRepo $revisionRepo,
                  protected EntityQueries $entityQueries,
                  protected ReferenceStore $referenceStore,
                  protected ReferenceUpdater $referenceUpdater,
          Severity: Minor
          Found in app/Entities/Repos/PageRepo.php - About 45 mins to fix

            Function decodeEscapes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected static function decodeEscapes(string $input): string
                {
                    $decoded = "";
                    $escaping = false;
            
            
            Severity: Minor
            Found in app/Search/SearchOptions.php - About 45 mins 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 loadModelsFromSortMap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function loadModelsFromSortMap(BookSortMap $sortMap): array
                {
                    $modelMap = [];
                    $ids = [
                        'chapter' => [],
            Severity: Minor
            Found in app/Entities/Tools/BookContents.php - About 45 mins 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

            Severity
            Category
            Status
            Source
            Language