opf/openproject

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

Summary

Maintainability
F
3 days
Test Coverage

File storage.component.ts has 475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2024 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or

    StorageComponent has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'op-storage',
      templateUrl: './storage.component.html',
      changeDetection: ChangeDetectionStrategy.OnPush,
      providers: [{ provide: OpUploadService, useClass: StorageUploadService }],

      Function uploadAndCreateFileLink has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private uploadAndCreateFileLink(data:UploadData):void {
          let isUploadError = false;
      
          this.storage
            .pipe(

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

          ngOnInit():void {
            this.storage = this.storagesResourceService.requireEntity(this.projectStorage._links.storage.href);
        
            this.fileLinks = this.collectionKey()
              .pipe(

          Function handleUploadError has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private handleUploadError(error:HttpErrorResponse, fileName:string):void {
              if (error.status === 500 && (error.error as IHalErrorBase).errorIdentifier === v3ErrorIdentifierMissingEnterpriseToken) {
                this.toastService.addError(error);
                return;
              }

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

              constructor(
                private readonly i18n:I18nService,
                private readonly cdRef:ChangeDetectorRef,
                private readonly toastService:ToastService,
                private readonly uploadService:OpUploadService,
            frontend/src/app/core/global_search/global-search-work-packages.component.ts on lines 73..87
            frontend/src/app/features/boards/board/board-partitioned-page/board-partitioned-page.component.ts on lines 143..157
            frontend/src/app/features/team-planner/team-planner/add-work-packages/add-existing-pane.component.ts on lines 114..128

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

            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

              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/attachments/attachments.component.ts on lines 202..207

            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

            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/attachments/attachments.component.ts on lines 110..113

            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 hasFileLinkViewErrors(fileLinks:IFileLink[]):boolean {
                return fileLinks.filter((fileLink) => fileLink._links.status?.href === fileLinkStatusError).length > 0;
              }
            frontend/src/app/shared/components/storages/storage-information/storage-information.service.ts on lines 123..125

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

            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/attachments/attachments.component.ts on lines 120..129

            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/attachments/attachments.component.ts on lines 234..238

            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/attachments/attachments.component.ts on lines 115..118

            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

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

                  linkingAfterUploadFailed:
                    (fileName:string, workPackageId:string):string => this.i18n.t(
                      'js.storages.file_links.link_uploaded_file_error',
                      {
                        fileName,
            frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts on lines 64..67
            frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 152..159

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

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

                  uploadFailedSizeLimit:
                    (fileName:string, storageType:string):string => this.i18n.t(
                      'js.storages.file_links.upload_error.413',
                      {
                        fileName,
            frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts on lines 64..67
            frontend/src/app/shared/components/storages/storage/storage.component.ts on lines 161..168

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

            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