hisptz/function-analytics

View on GitHub
src/utilities/period-instance.js

Summary

Maintainability
F
1 wk
Test Coverage

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

        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

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

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

                          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

                                          Avoid too many return statements within this function.
                                          Open

                                                  return this._calendar.getCurrentYear();
                                          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 >= 4 ? currentYear : currentYear - 1,
                                                      'FinancialApril'
                                                    );
                                            Severity: Major
                                            Found in src/utilities/period-instance.js - About 30 mins to fix

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

                                                getBiMonthlyPeriods(year) {
                                                  return (chunk(this._monthNames || [], 2) || []).map(
                                                    (biMonths, biMonthIndex) => {
                                                      const id = this.getBiMonthlyPeriodId(year, biMonthIndex + 1);
                                              
                                              
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 7 hrs to fix
                                              src/utilities/period-instance.js on lines 375..407

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

                                              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

                                                getSixMonthlyPeriods(year) {
                                                  return (chunk(this._monthNames || [], 6) || []).map(
                                                    (sixMonths, sixMonthIndex) => {
                                                      const id = this.getSixMonthlyPeriodId(year, sixMonthIndex + 1);
                                              
                                              
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 7 hrs to fix
                                              src/utilities/period-instance.js on lines 341..373

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

                                              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

                                                  return (
                                                    chunk([...months.slice(3), ...months.slice(0, 3)] || [], 6) || []
                                                  ).map((sixMonthApril, sixMonthAprilIndex) => {
                                                    const id = this.getSixMonthlyPeriodId(
                                                      year,
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 5 hrs to fix
                                              src/utilities/period-instance.js on lines 452..492

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

                                              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

                                                  return chunk(
                                                    this.getMonthsByOffset(
                                                      this.getMonthWithYears(this._monthNames, year, -2),
                                                      this._quarterMonthOffset
                                                    ),
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 5 hrs to fix
                                              src/utilities/period-instance.js on lines 412..448

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

                                              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

                                                    case 'RelativeWeek': {
                                                      return [
                                                        { id: 'THIS_WEEK', type, name: 'This Week' },
                                                        { id: 'LAST_WEEK', type, name: 'Last Week' },
                                                        {
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 3 hrs to fix
                                              src/utilities/period-instance.js on lines 164..176

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

                                              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

                                                    case 'RelativeMonth': {
                                                      return [
                                                        { id: 'THIS_MONTH', type, name: 'This Month' },
                                                        { id: 'LAST_MONTH', type, name: 'Last Month' },
                                                        {
                                              Severity: Major
                                              Found in src/utilities/period-instance.js and 1 other location - About 3 hrs to fix
                                              src/utilities/period-instance.js on lines 226..238

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

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

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

                                              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

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

                                              There are no issues that match your filters.

                                              Category
                                              Status