hisptz/ngx-dhis2-period-filter

View on GitHub

Showing 6 of 6 total issues

Function getPeriodType has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

export function getPeriodType(selectedPeriod: any) {
  let periodType = 'Monthly';
  if (selectedPeriod) {
    const periodId = selectedPeriod.id;

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

export function getPeriodType(selectedPeriod: any) {
  let periodType = 'Monthly';
  if (selectedPeriod) {
    const periodId = selectedPeriod.id;

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

    export function getPeriodName(
      id: string,
      type: string,
      periodConfig: PeriodFilterConfig,
      calendar: string

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

      export function getPeriodName(
        id: string,
        type: string,
        periodConfig: PeriodFilterConfig,
        calendar: string

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

        private _setPeriodProperties(selectedPeriodType) {
          this.httpClient.systemInfo().subscribe((systemInfo: SystemInfo) => {
            this.selectedPeriods = getSanitizedPeriods(
              this.selectedPeriods,
              this.periodFilterConfig,

        Avoid deeply nested control flow statements.
        Open

                if (periodId.indexOf('FINANCIAL_YEAR') !== -1) {
                  periodType = 'RelativeFinancialYear';
                } else {
                  periodType = 'RelativeYear';
                }
          Severity
          Category
          Status
          Source
          Language