BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

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

function $parseSerializedNodeImpl<
  SerializedNode extends InternalSerializedNode,
>(
  serializedNode: SerializedNode,
  registeredNodes: RegisteredNodes,
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 1 hr to fix

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

    export function $reconcileRoot(
      prevEditorState: EditorState,
      nextEditorState: EditorState,
      editor: LexicalEditor,
      dirtyType: 0 | 1 | 2,
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if ($model instanceof Chapter) {
                  $hasPermission = userCan('book-update', $currentParent)
                      && userCan('book-update', $newBook)
                      && userCan('chapter-update', $model)
                      && (!$hasNewParent || userCan('chapter-create', $newBook))
      Severity: Major
      Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

        Function syncLexicalUpdateToYjs has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          binding: Binding,
          provider: Provider,
          prevEditorState: EditorState,
          currEditorState: EditorState,
          dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>,
        Severity: Major
        Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.ts - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                isLineBreakNode ||
                ($isDecoratorNode(node) && node.isInline()) ||
                ($isElementNode(node) && node.isInline()) ||
                $isTextNode(node) ||
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (
                  this.isCollapsed() &&
                  startOffset === firstNodeTextLength &&
                  (firstNode.isSegmented() ||
                    firstNode.isToken() ||
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  } else if (
                    this.isCollapsed() &&
                    startOffset === 0 &&
                    (firstNode.isSegmented() ||
                      firstNode.isToken() ||
              Severity: Major
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (
                      !isBackward &&
                      // Delete forward handle case
                      ((anchor.type === 'element' &&
                        $isElementNode(anchorNode) &&
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                  Function validateTokenClaims has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function validateTokenClaims(string $clientId): void
                      {
                          // 1. The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery)
                          // MUST exactly match the value of the iss (issuer) Claim.
                          // Already done in parent.
                  Severity: Minor
                  Found in app/Access/Oidc/OidcIdToken.php - About 55 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 collapseAndCategorisePermissions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function collapseAndCategorisePermissions(array $typeIdChain, array $permissionMapByTypeId): array
                      {
                          $permitsByType = ['fallback' => [], 'role' => []];
                  
                          foreach ($typeIdChain as $typeId) {
                  Severity: Minor
                  Found in app/Permissions/EntityPermissionEvaluator.php - About 55 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 handle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle(Activity $activity, Loggable|string $detail, User $user): void
                      {
                          if (!($detail instanceof Page)) {
                              throw new \InvalidArgumentException("Detail for page update notifications must be a page");
                          }
                  Severity: Minor
                  Found in app/Activity/Notifications/Handlers/PageUpdateNotificationHandler.php - About 55 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 getPermissionsMapByTypeId has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function getPermissionsMapByTypeId(array $typeIdChain, array $filterRoleIds): array
                      {
                          $idsByType = [];
                          foreach ($typeIdChain as $typeId) {
                              [$type, $id] = explode(':', $typeId);
                  Severity: Minor
                  Found in app/Permissions/EntityPermissionEvaluator.php - About 55 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 orientImageToOriginalExif has a Cognitive Complexity of 9 (exceeds 5 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 55 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 ensureDetailsWrappedInEditable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function ensureDetailsWrappedInEditable(detailsEl) {
                      unwrapDetailsEditable(detailsEl);
                  
                      detailsEl.attr('contenteditable', 'false');
                      const rootWrap = window.tinymce.html.Node.create('doc-root', {contenteditable: 'true'});
                  Severity: Minor
                  Found in resources/js/wysiwyg-tinymce/plugins-details.js - About 55 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 highlightTagsContainingTerms has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function highlightTagsContainingTerms(array $tags, array $terms): void
                      {
                          foreach ($tags as $tag) {
                              $tagName = mb_strtolower($tag->name);
                              $tagValue = mb_strtolower($tag->value);
                  Severity: Minor
                  Found in app/Search/SearchResultsFormatter.php - About 55 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 handle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle(Activity $activity, Loggable|string $detail, User $user): void
                      {
                          if (!($detail instanceof Comment)) {
                              throw new \InvalidArgumentException("Detail for comment creation notifications must be a comment");
                          }

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

                      sortLanguageList() {
                          const sortedParents = this.languageButtons.sort((a, b) => {
                              const aFav = a.dataset.favourite === 'true';
                              const bFav = b.dataset.favourite === 'true';
                  
                  
                  Severity: Minor
                  Found in resources/js/components/code-editor.js - About 55 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 handle has a Cognitive Complexity of 9 (exceeds 5 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 55 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 handleDropdown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function handleDropdown(options: HandleDropdownParams) {
                      const {menu, toggle, onClose, onOpen, showOnHover} = options;
                      let clickListener: Function|null = null;
                  
                      const hide = () => {
                  Severity: Minor
                  Found in resources/js/wysiwyg/ui/framework/helpers/dropdowns.ts - About 55 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 validateColumnsToCopy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function validateColumnsToCopy(columns: CustomTableCellNode[][]): void {
                      let commonColSize: number|null = null;
                  
                      for (const cells of columns) {
                          let colSize = 0;
                  Severity: Minor
                  Found in resources/js/wysiwyg/utils/table-copy-paste.ts - About 55 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