hisptz/function-analytics

View on GitHub

Showing 76 of 76 total issues

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

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

              case 'RelativeBiMonth': {
                return [
                  { id: 'THIS_BIMONTH', type, name: 'This Bi-month' },
                  {
                    id: 'LAST_BIMONTH',
        Severity: Major
        Found in src/utilities/period-instance.js and 4 other locations - About 1 hr to fix
        src/utilities/period-instance.js on lines 178..188
        src/utilities/period-instance.js on lines 190..200
        src/utilities/period-instance.js on lines 202..212
        src/utilities/period-instance.js on lines 214..224

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

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

              case 'RelativeQuarter': {
                return [
                  { id: 'THIS_QUARTER', type, name: 'This Quarter' },
                  {
                    id: 'LAST_QUARTER',
        Severity: Major
        Found in src/utilities/period-instance.js and 4 other locations - About 1 hr to fix
        src/utilities/period-instance.js on lines 152..162
        src/utilities/period-instance.js on lines 190..200
        src/utilities/period-instance.js on lines 202..212
        src/utilities/period-instance.js on lines 214..224

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

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

              case 'RelativeFinancialYear': {
                return [
                  { id: 'THIS_FINANCIAL_YEAR', type, name: 'This Financial Year' },
                  {
                    id: 'LAST_FINANCIAL_YEAR',
        Severity: Major
        Found in src/utilities/period-instance.js and 4 other locations - About 1 hr to fix
        src/utilities/period-instance.js on lines 152..162
        src/utilities/period-instance.js on lines 178..188
        src/utilities/period-instance.js on lines 190..200
        src/utilities/period-instance.js on lines 202..212

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

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

              case 'RelativeYear': {
                return [
                  { id: 'THIS_YEAR', type, name: 'This Year' },
                  {
                    id: 'LAST_YEAR',
        Severity: Major
        Found in src/utilities/period-instance.js and 4 other locations - About 1 hr to fix
        src/utilities/period-instance.js on lines 152..162
        src/utilities/period-instance.js on lines 178..188
        src/utilities/period-instance.js on lines 190..200
        src/utilities/period-instance.js on lines 214..224

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

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

              case 'RelativeSixMonth': {
                return [
                  { id: 'THIS_SIX_MONTH', type, name: 'This Six-month' },
                  {
                    id: 'LAST_SIX_MONTH',
        Severity: Major
        Found in src/utilities/period-instance.js and 4 other locations - About 1 hr to fix
        src/utilities/period-instance.js on lines 152..162
        src/utilities/period-instance.js on lines 178..188
        src/utilities/period-instance.js on lines 202..212
        src/utilities/period-instance.js on lines 214..224

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

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

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

                      case 'FinancialJuly': {
                        const currentYear = this._calendar.getCurrentYear();
                
                        return this.getYearlyPeriodId(
                          this._month >= 7 ? currentYear : currentYear - 1,
                Severity: Major
                Found in src/utilities/period-instance.js and 3 other locations - About 1 hr to fix
                src/utilities/period-instance.js on lines 583..590
                src/utilities/period-instance.js on lines 601..608
                src/utilities/period-instance.js on lines 610..617

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

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

                      case 'FinancialNovember': {
                        const currentYear = this._calendar.getCurrentYear();
                
                        return this.getYearlyPeriodId(
                          this._month >= 11 ? currentYear : currentYear - 1,
                Severity: Major
                Found in src/utilities/period-instance.js and 3 other locations - About 1 hr to fix
                src/utilities/period-instance.js on lines 583..590
                src/utilities/period-instance.js on lines 592..599
                src/utilities/period-instance.js on lines 601..608

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

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

                      case 'FinancialApril': {
                        const currentYear = this._calendar.getCurrentYear();
                
                        return this.getYearlyPeriodId(
                          this._month >= 4 ? currentYear : currentYear - 1,
                Severity: Major
                Found in src/utilities/period-instance.js and 3 other locations - About 1 hr to fix
                src/utilities/period-instance.js on lines 592..599
                src/utilities/period-instance.js on lines 601..608
                src/utilities/period-instance.js on lines 610..617

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

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

                      case 'FinancialOctober': {
                        const currentYear = this._calendar.getCurrentYear();
                
                        return this.getYearlyPeriodId(
                          this._month >= 10 ? currentYear : currentYear - 1,
                Severity: Major
                Found in src/utilities/period-instance.js and 3 other locations - About 1 hr to fix
                src/utilities/period-instance.js on lines 583..590
                src/utilities/period-instance.js on lines 592..599
                src/utilities/period-instance.js on lines 610..617

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

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

                Severity
                Category
                Status
                Source
                Language