opf/openproject

View on GitHub
frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts

Summary

Maintainability
D
2 days
Test Coverage

File timeline-cell-renderer.ts has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as moment from 'moment';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { DisplayFieldRenderer } from 'core-app/shared/components/fields/display/display-field-renderer';
import { Injector } from '@angular/core';
import { Highlighting } from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';

    TimelineCellRenderer has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class TimelineCellRenderer {
      @InjectField() wpTableTimeline:WorkPackageViewTimelineService;
    
      @InjectField() weekdayService:WeekdayService;
    
    

      Function onDaysMoved has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        public onDaysMoved(change:WorkPackageChangeset,
          dayUnderCursor:Moment,
          delta:number,
          direction:MouseDirection):CellDateMovement {
          const initialStartDate = change.pristineResource.startDate;

      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 checkForSpecialDisplaySituations has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        checkForSpecialDisplaySituations(renderInfo:RenderInfo, bar:HTMLElement) {
          const wp = renderInfo.workPackage;
          const row = bar.parentElement!.parentElement!;
          const selectionMode = renderInfo.viewParams.activeSelectionMode;
      
      

        Function onMouseDown has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public onMouseDown(ev:MouseEvent,
            dateForCreate:string|null,
            renderInfo:RenderInfo,
            labels:WorkPackageCellLabels):MouseDirection {
            // check for active selection mode

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

            checkForSpecialDisplaySituations(renderInfo:RenderInfo, bar:HTMLElement) {
              const wp = renderInfo.workPackage;
              const row = bar.parentElement!.parentElement!;
              const selectionMode = renderInfo.viewParams.activeSelectionMode;
          
          

          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 onDaysMoved has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public onDaysMoved(change:WorkPackageChangeset,
              dayUnderCursor:Moment,
              delta:number,
              direction:MouseDirection):CellDateMovement {
              const initialStartDate = change.pristineResource.startDate;

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

              public onMouseDown(ev:MouseEvent,
                dateForCreate:string|null,
                renderInfo:RenderInfo,
                labels:WorkPackageCellLabels):MouseDirection {
                // check for active selection mode

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

              protected displayDurationForDate(renderInfo:RenderInfo, date:Moment):number {
                const { workPackage } = renderInfo;
                let duration = Number(moment.duration(workPackage.duration || 'P1D').asDays().toFixed(0));
            
                if (workPackage.ignoreNonWorkingDays) {

            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 6 (exceeds 5 allowed). Consider refactoring.
            Open

              public update(element:HTMLDivElement, labels:WorkPackageCellLabels|null, renderInfo:RenderInfo):boolean {
                const { change } = renderInfo;
                const bar = element.querySelector(`.${timelineBackgroundElementClass}`) as HTMLElement;
                let start = moment(change.projectedResource.startDate);
                let due = moment(change.projectedResource.dueDate);

            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

            There are no issues that match your filters.

            Category
            Status