hisptz/function-analytics

View on GitHub

Showing 44 of 76 total issues

File period-instance.js has 663 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { chunk, head, last, range } from 'lodash';

import { Calendar } from './calendars/calendar';

export class PeriodInstance {
Severity: Major
Found in src/utilities/period-instance.js - About 1 day to fix

    Function deducePeriodType has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      static deducePeriodType(periodId) {
        let periodType;
    
        const numberLikePeriod = parseInt(periodId, 10);
    
    
    Severity: Minor
    Found in src/utilities/period-util.js - About 3 hrs 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

    Function getChildrenPeriods has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getChildrenPeriods(parentId, parentType, childrenType, preferences) {
        let periods = [];
    
        switch (parentType) {
          case 'Yearly': {
    Severity: Major
    Found in src/utilities/period-instance.js - About 3 hrs to fix

      Function getRelativePeriods has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getRelativePeriods(type) {
          switch (type) {
            case 'RelativeBiMonth': {
              return [
                { id: 'THIS_BIMONTH', type, name: 'This Bi-month' },
      Severity: Major
      Found in src/utilities/period-instance.js - About 3 hrs to fix

        CalendarDate has 27 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class CalendarDate {
          constructor(calendar, year, month, day) {
            this._calendar = calendar;
            this._year = year;
            this._month = month;
        Severity: Minor
        Found in src/utilities/calendars/calendar-date.js - About 3 hrs to fix

          PeriodInstance has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class PeriodInstance {
            constructor(calendarId, type, preferences, year) {
              this._calendarId = calendarId || 'gregorian';
              this._type = type;
              this._preferences = preferences;
          Severity: Minor
          Found in src/utilities/period-instance.js - About 3 hrs to fix

            File base-calendar.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import {
              CalendarDate
            } from './calendar-date';
            
            export class BaseCalender {
            Severity: Minor
            Found in src/utilities/calendars/base-calendar.js - About 3 hrs to fix

              Function getCurrentPeriodId has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getCurrentPeriodId(type) {
                  switch (type) {
                    case 'Monthly': {
                      return this.getMonthPeriodId(
                        this._calendar.getCurrentYear(),
              Severity: Major
              Found in src/utilities/period-instance.js - About 2 hrs to fix

                Function getSanitizedAnalyticsMetadata has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  getSanitizedAnalyticsMetadata(analyticMetadata, version) {
                    let sanitizedMetadata = {};
                
                    if (analyticMetadata) {
                      if (analyticMetadata.ouHierarchy) {
                Severity: Minor
                Found in src/model/analytics.js - About 2 hrs 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

                Function getChildrenPeriods has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  getChildrenPeriods(parentId, parentType, childrenType, preferences) {
                    let periods = [];
                
                    switch (parentType) {
                      case 'Yearly': {
                Severity: Minor
                Found in src/utilities/period-instance.js - About 2 hrs 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

                BaseCalender has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class BaseCalender {
                  constructor() {
                    this._validateLevel = 0;
                    this._name = '';
                    this._hasYearZero = false;
                Severity: Minor
                Found in src/utilities/calendars/base-calendar.js - About 2 hrs to fix

                  Function getPeriods has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    getPeriods(type, year, offset = 0) {
                      let periods;
                  
                      switch (type) {
                        case 'Monthly': {
                  Severity: Major
                  Found in src/utilities/period-instance.js - About 2 hrs to fix

                    Function _fetch has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _fetch(fetcher, resolve, reject) {
                        if (!_instance) {
                          let error =
                            'Configuration not set please configure function ' +
                            'analytics eg {baseUrl:"dhis_base_url", username:"username", ' +
                    Severity: Major
                    Found in src/utilities/runner.js - About 2 hrs to fix

                      Function constructor has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        constructor() {
                          super();
                          this._name = 'Ethiopian';
                          this._jdEpoch = 1723856;
                          this._gregorianEpoch = 1721426;
                      Severity: Major
                      Found in src/utilities/calendars/ethiopian-calender.js - About 2 hrs to fix

                        Function constructor has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          constructor() {
                            super();
                            this._name = 'Gregorian';
                            this._jdEpoch = 1721425.5;
                            this._daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
                        Severity: Major
                        Found in src/utilities/calendars/gregorian-calendar.js - About 2 hrs to fix

                          Function standardizeAnalytics has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            standardizeAnalytics(analyticsObject, version = 25) {
                              if (typeof version === 'boolean') {
                                if (version) {
                                  version = 25;
                                } else {
                          Severity: Major
                          Found in src/model/analytics.js - About 2 hrs to fix

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

                              standardizeAnalytics(analyticsObject, version = 25) {
                                if (typeof version === 'boolean') {
                                  if (version) {
                                    version = 25;
                                  } else {
                            Severity: Minor
                            Found in src/model/analytics.js - About 1 hr 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

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

                              _add(yearOrDate, month, day) {
                                this._validateLevel++;
                                if (day === 'd' || day === 'w') {
                                  const d = yearOrDate.fromJD(
                                    yearOrDate.toJD() + month * (day === 'w' ? this.daysInWeek() : 1)
                            Severity: Minor
                            Found in src/utilities/calendars/base-calendar.js - About 1 hr 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

                            Function deducePeriodType has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static deducePeriodType(periodId) {
                                let periodType;
                            
                                const numberLikePeriod = parseInt(periodId, 10);
                            
                            
                            Severity: Minor
                            Found in src/utilities/period-util.js - About 1 hr to fix

                              Function getSanitizedAnalyticsMetadata has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                getSanitizedAnalyticsMetadata(analyticMetadata, version) {
                                  let sanitizedMetadata = {};
                              
                                  if (analyticMetadata) {
                                    if (analyticMetadata.ouHierarchy) {
                              Severity: Minor
                              Found in src/model/analytics.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language