hisptz/function-analytics

View on GitHub

Showing 44 of 76 total issues

Function _add has 41 lines of code (exceeds 25 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

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

      getSixMonthlyNovemberPeriods(year) {
        return chunk(
          this.getMonthsByOffset(
            this.getMonthWithYears(this._monthNames, year, -2),
            this._quarterMonthOffset
    Severity: Minor
    Found in src/utilities/period-instance.js - About 1 hr to fix

      Function getQuarterlyPeriods has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getQuarterlyPeriods(year) {
          return chunk(
            this.getMonthsByOffset(
              this.getMonthWithYears(
                this._monthNames,
      Severity: Minor
      Found in src/utilities/period-instance.js - About 1 hr to fix

        Function getSixMonthlyAprilPeriods has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getSixMonthlyAprilPeriods(year) {
            const months = this.getMonthWithYears(this._monthNames, year + 1, -9);
        
            return (
              chunk([...months.slice(3), ...months.slice(0, 3)] || [], 6) || []
        Severity: Minor
        Found in src/utilities/period-instance.js - About 1 hr to fix

          Function _fetch has a Cognitive Complexity of 11 (exceeds 5 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: Minor
          Found in src/utilities/runner.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 getYearlyPeriods has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getYearlyPeriods(year, type, idSuffix = '', monthIndex = -1) {
              return range(10)
                .map(yearIndex => {
                  const periodYear = parseInt(year, 10) - yearIndex;
                  const id = this.getYearlyPeriodId(periodYear, idSuffix);
          Severity: Minor
          Found in src/utilities/period-instance.js - About 1 hr to fix

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

              getBiMonthlyPeriods(year) {
                return (chunk(this._monthNames || [], 2) || []).map(
                  (biMonths, biMonthIndex) => {
                    const id = this.getBiMonthlyPeriodId(year, biMonthIndex + 1);
            
            
            Severity: Minor
            Found in src/utilities/period-instance.js - About 1 hr to fix

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

                getSixMonthlyPeriods(year) {
                  return (chunk(this._monthNames || [], 6) || []).map(
                    (sixMonths, sixMonthIndex) => {
                      const id = this.getSixMonthlyPeriodId(year, sixMonthIndex + 1);
              
              
              Severity: Minor
              Found in src/utilities/period-instance.js - About 1 hr to fix

                Function url has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  get url() {
                    var url = this._urlParameters;
                
                    this._filters.forEach(filter => {
                      if (url !== '') {
                Severity: Minor
                Found in src/model/identifiable-object.js - About 1 hr to fix

                  Function getCurrentPeriodId has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getCurrentPeriodId(type) {
                      switch (type) {
                        case 'Monthly': {
                          return this.getMonthPeriodId(
                            this._calendar.getCurrentYear(),
                  Severity: Minor
                  Found in src/utilities/period-instance.js - About 55 mins 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 _correctAdd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _correctAdd(a, b, c, d) {
                      if (!this._hasYearZero && (d === 'y' || d === 'm')) {
                        if (b[0] === 0 || a.year() > 0 !== b[0] > 0) {
                          const e = {
                            y: [1, 1, 'y'],
                  Severity: Minor
                  Found in src/utilities/calendars/base-calendar.js - About 45 mins 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 compareTo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    compareTo(instance) {
                      let comparer = this._year - instance._year;
                  
                      if (this._year === instance._year) {
                        comparer = this._day - instance._day;
                  Severity: Minor
                  Found in src/utilities/calendars/calendar-date.js - About 35 mins 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

                  Avoid too many return statements within this function.
                  Open

                          return [
                            { id: 'THIS_FINANCIAL_YEAR', type, name: 'This Financial Year' },
                            {
                              id: 'LAST_FINANCIAL_YEAR',
                              type,
                  Severity: Major
                  Found in src/utilities/period-instance.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return this.getSixMonthlyPeriodId(
                              this._calendar.getCurrentYear(),
                              this._sixmonthApril,
                              'April'
                            );
                    Severity: Major
                    Found in src/utilities/period-instance.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return [
                                { id: 'THIS_WEEK', type, name: 'This Week' },
                                { id: 'LAST_WEEK', type, name: 'Last Week' },
                                {
                                  id: 'LAST_4_WEEKS',
                      Severity: Major
                      Found in src/utilities/period-instance.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return this.getYearlyPeriodId(
                                  this._month >= 10 ? currentYear : currentYear - 1,
                                  'FinancialOctober'
                                );
                        Severity: Major
                        Found in src/utilities/period-instance.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return [
                                    { id: 'THIS_YEAR', type, name: 'This Year' },
                                    {
                                      id: 'LAST_YEAR',
                                      type,
                          Severity: Major
                          Found in src/utilities/period-instance.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return this.getSixMonthlyPeriodId(
                                      this._calendar.getCurrentYear(),
                                      this._sixMonthNovember,
                                      'Nov'
                                    );
                            Severity: Major
                            Found in src/utilities/period-instance.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return this.getYearlyPeriodId(
                                        this._month >= 7 ? currentYear : currentYear - 1,
                                        'FinancialJuly'
                                      );
                              Severity: Major
                              Found in src/utilities/period-instance.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return this.getYearlyPeriodId(
                                          this._month >= 11 ? currentYear : currentYear - 1,
                                          'FinancialNovember'
                                        );
                                Severity: Major
                                Found in src/utilities/period-instance.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language