BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

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

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

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

    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 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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          show(event = null) {
              this.hideAll();
      
              this.menu.style.display = 'block';
              this.menu.classList.add('anim', 'menuIn');
      Severity: Minor
      Found in resources/js/components/dropdown.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 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 getConversionFunction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function getConversionFunction(
        domNode: Node,
        editor: LexicalEditor,
      ): DOMConversionFn | null {
        const {nodeName} = domNode;
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/html/index.ts - 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 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

        Function $createNodesFromDOM has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          node: Node,
          editor: LexicalEditor,
          allArtificialNodes: Array<ArtificialNode__DO_NOT_USE>,
          hasBlockAncestorLexicalNode: boolean,
          forChildMap: Map<string, DOMChildConversion> = new Map(),
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/html/index.ts - About 45 mins to fix

          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

          Avoid deeply nested control flow statements.
          Open

                                  while (cellFilled(x, y)) {
                                      targetColIndex += 1;
                                      x += 1;
                                  }
          Severity: Major
          Found in resources/js/wysiwyg/utils/table-map.ts - About 45 mins to fix

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

                static importDOM(): DOMConversionMap|null {
                    return {
                        pre(node: HTMLElement): DOMConversion|null {
                            return {
                                conversion: (element: HTMLElement): DOMConversionOutput|null => {
            Severity: Minor
            Found in resources/js/wysiwyg/nodes/code-block.ts - 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 onSelectionChange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                onSelectionChange(selection: BaseSelection|null) {
                    const nodes = selection?.getNodes() || [];
                    if (this.activeSelection) {
                        this.hide();
                    }
            Severity: Minor
            Found in resources/js/wysiwyg/ui/framework/helpers/node-resizer.ts - 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 buildDOM has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected buildDOM(): HTMLElement {
                    const controls: HTMLElement[] = [];
                    const contents: HTMLElement[] = [];
            
                    const selectTab = (tabIndex: number) => {
            Severity: Minor
            Found in resources/js/wysiwyg/ui/framework/forms.ts - 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 validateRowsToPaste has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function validateRowsToPaste(rows: CustomTableRowNode[], targetTable: CustomTableNode): void {
                const tableColCount = (new TableMap(targetTable)).columnCount;
                for (const row of rows) {
                    const cells = row.getChildren().filter(n => $isCustomTableCellNode(n));
                    let rowSize = 0;
            Severity: Minor
            Found in resources/js/wysiwyg/utils/table-copy-paste.ts - 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