BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    async put(url: string, data: null|Record<string, any> = null): Promise<FormattedResponse> {
        return this.dataRequest('PUT', url, data);
    }
Severity: Major
Found in resources/js/services/http.ts and 3 other locations - About 1 hr to fix
resources/js/services/http.ts on lines 169..171
resources/js/services/http.ts on lines 183..185
resources/js/services/http.ts on lines 190..192

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    async post(url: string, data: null|Record<string, any> = null): Promise<FormattedResponse> {
        return this.dataRequest('POST', url, data);
    }
Severity: Major
Found in resources/js/services/http.ts and 3 other locations - About 1 hr to fix
resources/js/services/http.ts on lines 176..178
resources/js/services/http.ts on lines 183..185
resources/js/services/http.ts on lines 190..192

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    async delete(url: string, data: null|Record<string, any> = null): Promise<FormattedResponse> {
        return this.dataRequest('DELETE', url, data);
    }
Severity: Major
Found in resources/js/services/http.ts and 3 other locations - About 1 hr to fix
resources/js/services/http.ts on lines 169..171
resources/js/services/http.ts on lines 176..178
resources/js/services/http.ts on lines 183..185

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        const withinBounds = event.clientX <= bounds.right
            && event.clientX >= bounds.left
            && event.clientY >= bounds.top
            && event.clientY <= bounds.bottom;
resources/js/wysiwyg/nodes/_common.ts on lines 86..89

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      this.isCollapsed() &&
      startOffset === firstNodeTextLength &&
      (firstNode.isSegmented() ||
        firstNode.isToken() ||
        !firstNode.canInsertTextAfter() ||
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 787..793

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  const testCases: Array<{
    _: string;
    expectedHtml: string;
    initialHtml: string;
    splitPath: Array<number>;
resources/js/wysiwyg/lexical/utils/__tests__/unit/LexlcaiUtilsInsertNodeToNearestRoot.test.ts on lines 38..135

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    return nodeA.__id !== nodeB.__id ||
        nodeA.__alignment !== nodeB.__alignment ||
        nodeA.__inset !== nodeB.__inset ||
        nodeA.__dir !== nodeB.__dir;
Severity: Major
Found in resources/js/wysiwyg/nodes/_common.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/ui/framework/helpers/task-list-handler.ts on lines 29..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      this.isCollapsed() &&
      startOffset === 0 &&
      (firstNode.isSegmented() ||
        firstNode.isToken() ||
        !firstNode.canInsertTextBefore() ||
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 757..763

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  const testCases: Array<{
    _: string;
    expectedHtml: string;
    initialHtml: string;
    selectionPath: Array<number>;
resources/js/wysiwyg/lexical/utils/__tests__/unit/LexicalUtilsSplitNode.test.ts on lines 30..100

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

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

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

                      build() {
                          return new EditorFormTabs([
                              {
                                  label: 'General',
                                  contents: [
          Severity: Minor
          Found in resources/js/wysiwyg/ui/defaults/forms/objects.ts - About 1 hr to fix

            Method applySortUpdates has 32 lines of code (exceeds 25 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

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

                  protected function build(): array
                  {
                      $page = clone $this->page;
                      $isDraft = boolval($this->page->draft);
                      $templates = $this->queries->pages->visibleTemplates()
              Severity: Minor
              Found in app/Entities/Tools/PageEditorData.php - About 1 hr to fix

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

                function $onCompositionEndImpl(editor: LexicalEditor, data?: string): void {
                  const compositionKey = editor._compositionKey;
                  $setCompositionKey(null);
                
                  // Handle termination of composition.
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr to fix

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

                  function findTextInLine(text: Text, forward: boolean): null | Text {
                    let node: Node = text;
                    // eslint-disable-next-line no-constant-condition
                    while (true) {
                      let sibling: null | Node;
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 1 hr to fix

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

                      focus(callbackFn?: () => void, options: EditorFocusOptions = {}): void {
                        const rootElement = this._rootElement;
                    
                        if (rootElement !== null) {
                          // This ensures that iOS does not trigger caps lock upon focus
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 1 hr to fix

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

                          static importDOM(): DOMConversionMap|null {
                              return {
                                  p(node: HTMLElement): DOMConversion|null {
                                      if (node.classList.contains('callout')) {
                                          return {
                      Severity: Minor
                      Found in resources/js/wysiwyg/nodes/callout.ts - 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

                      Severity
                      Category
                      Status
                      Source
                      Language