opf/openproject

View on GitHub
frontend/src/app/shared/components/attachments/attachments.component.ts

Summary

Maintainability
C
1 day
Test Coverage

Function ngOnInit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ngOnInit():void {
    if (!(this.resource instanceof HalResource)) {
      // Parse the resource if any exists
      this.resource = this.halResourceService.createHalResource(this.resource, true);
    }

    Function ngOnInit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      ngOnInit():void {
        if (!(this.resource instanceof HalResource)) {
          // Parse the resource if any exists
          this.resource = this.halResourceService.createHalResource(this.resource, true);
        }
    Severity: Minor
    Found in frontend/src/app/shared/components/attachments/attachments.component.ts - About 35 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

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

      ngOnDestroy():void {
        document.body.removeEventListener('dragenter', this.onGlobalDragEnter);
        document.body.removeEventListener('dragleave', this.onGlobalDragLeave);
        document.body.removeEventListener('dragend', this.onGlobalDragEnd);
        document.body.removeEventListener('drop', this.onGlobalDragEnd);
    frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 281..286

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

    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 7 locations. Consider refactoring.
    Open

      public text = {
        attachments: this.I18n.t('js.label_attachments'),
        uploadLabel: this.I18n.t('js.label_add_attachments'),
        dropFiles: this.I18n.t('js.label_drop_files'),
        dropClickFiles: this.I18n.t('js.label_drop_or_click_files'),
    frontend/src/app/features/work-packages/components/wp-card-view/wp-single-card/wp-single-card.component.ts on lines 100..106
    frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/filters-tab.component.ts on lines 18..25
    frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts on lines 103..109
    frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.ts on lines 87..93
    frontend/src/app/shared/components/time_entries/timer/stop-existing-timer-modal.component.ts on lines 74..80
    modules/github_integration/frontend/module/tab-header/tab-header.component.ts on lines 43..49

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

    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

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

      private onGlobalDragLeave:(_event:DragEvent) => void = (_event) => {
        this.dragging = Math.max(this.dragging - 1, 0);
        this.cdRef.detectChanges();
      };
    frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 190..193

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

    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

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

      private onGlobalDragEnter:(_event:DragEvent) => void = (_event) => {
        // When the global drag and drop is active and the dragging happens over the DOM
        // elements, the dragenter and dragleave events are always fired in pairs.
        // On dragenter the this.dragging is set to 2 and on dragleave we deduct it to 1,
        // meaning the drag and drop remains active. When the drag and drop action is canceled
    frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 200..209

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

    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

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

        if (event.dataTransfer !== null && containsFiles(event.dataTransfer)) {
          // eslint-disable-next-line no-param-reassign
          event.dataTransfer.dropEffect = 'copy';
          this.draggingOverDropZone = true;
        }
    frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 566..570

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

    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

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

      private onGlobalDragEnd:(_event:DragEvent) => void = (_event) => {
        this.dragging = 0;
        this.cdRef.detectChanges();
      };
    frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 195..198

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

    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

    There are no issues that match your filters.

    Category
    Status