opf/openproject

View on GitHub
frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts

Summary

Maintainability
C
1 day
Test Coverage

Function initializeDatepicker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private initializeDatepicker(minimalDate?:Date|null) {
    this.datePickerInstance?.destroy();
    this.datePickerInstance = new DatePicker(
      this.injector,
      '#flatpickr-input',

    Function updateDate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      updateDate(val:string|null):void {
        // Expected minimal format YYYY-M-D => 8 characters OR empty
        if (val !== null && (val.length >= 8 || val.length === 0)) {
          if (validDate(val) && this.datePickerInstance) {
            const dateValue = parseDate(val) || undefined;

    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

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

      constructor(
        readonly configurationService:ConfigurationService,
        readonly apiV3Service:ApiV3Service,
        readonly cdRef:ChangeDetectorRef,
        readonly injector:Injector,
    frontend/src/app/features/boards/board/board-filter/board-filter.component.ts on lines 27..37
    frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts on lines 85..95

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

    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

      text = {
        save: this.I18n.t('js.button_save'),
        cancel: this.I18n.t('js.button_cancel'),
        date: this.I18n.t('js.work_packages.properties.date'),
        placeholder: this.I18n.t('js.placeholders.default'),
    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/attachments/attachments.component.ts on lines 93..99
    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

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

            onDayCreate: async (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {
              onDayCreate(
                dayElem,
                this.ignoreNonWorkingDays,
                await this.datePickerInstance?.isNonWorkingDay(dayElem.dateObj),
    frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts on lines 321..328

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

    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

      isDayDisabled(dayElement:DayElement, minimalDate?:Date|null):boolean {
        return !this.isSchedulable || (!this.scheduleManually && !!minimalDate && dayElement.dateObj <= minimalDate);
      }
    frontend/src/app/shared/components/datepicker/services/date-modal-scheduling.service.ts on lines 58..60

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

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

            onReady: (_date:Date[], _datestr:string, instance:flatpickr.Instance) => {
              instance.calendarContainer.classList.add('op-datepicker-modal--flatpickr-instance');
            },
    frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts on lines 181..183
    frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts on lines 165..167
    frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts on lines 246..248

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

    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