hisptz/function-analytics

View on GitHub

Showing 76 of 76 total issues

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 _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 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

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

                get rows() {
                  let rows = [];
              
                  this._data.rows.forEach((row) => {
                    rows.push(new Row(row, this.headers, this.metaData));
              Severity: Major
              Found in src/result/analytics-result.js and 1 other location - About 1 hr to fix
              src/result/analytics-result.js on lines 152..159

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

              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

                get rows() {
                  let rows = [];
              
                  this._data.rows.forEach((row) => {
                    rows.push(new Row(row, this.headers, this.metaData));
              Severity: Major
              Found in src/result/analytics-result.js and 1 other location - About 1 hr to fix
              src/result/analytics-result.js on lines 121..128

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

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

                            periods = (monthPeriods || [])
                              .filter(({}, periodIndex) => {
                                const max = sixMonthlyNumber * 6;
                                const min = max - 6;
              
              
              Severity: Major
              Found in src/utilities/period-instance.js and 2 other locations - About 1 hr to fix
              src/utilities/period-instance.js on lines 686..693
              src/utilities/period-instance.js on lines 715..722

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

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

                            periods = (monthPeriods || [])
                              .filter(({}, periodIndex) => {
                                const max = biMonthlyNumber * 2;
                                const min = max - 2;
              
              
              Severity: Major
              Found in src/utilities/period-instance.js and 2 other locations - About 1 hr to fix
              src/utilities/period-instance.js on lines 686..693
              src/utilities/period-instance.js on lines 744..751

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

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

                            periods = (monthPeriods || [])
                              .filter(({}, periodIndex) => {
                                const max = quarterNumber * 3;
                                const min = max - 3;
              
              
              Severity: Major
              Found in src/utilities/period-instance.js and 2 other locations - About 1 hr to fix
              src/utilities/period-instance.js on lines 715..722
              src/utilities/period-instance.js on lines 744..751

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

              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

              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

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

                        } else if (periodId.indexOf('July') !== -1) {
                          periodType = 'FinancialJuly';
                        } else if (periodId.indexOf('Oct') !== -1) {
                          periodType = 'FinancialOctober';
                        } else {
                  Severity: Major
                  Found in src/utilities/period-util.js and 1 other location - About 1 hr to fix
                  src/utilities/period-util.js on lines 36..42

                  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

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

                          if (periodId.indexOf('BIMONTH') !== -1) {
                            periodType = 'RelativeBiMonth';
                          } else if (periodId.indexOf('SIX_MONTH') !== -1) {
                            periodType = 'RelativeSixMonth';
                          } else {
                  Severity: Major
                  Found in src/utilities/period-util.js and 1 other location - About 1 hr to fix
                  src/utilities/period-util.js on lines 23..29

                  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

                  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
                    Severity
                    Category
                    Status
                    Source
                    Language