romain-gilliotte/timeslot-dag

View on GitHub
src/timeslot.js

Summary

Maintainability
F
1 wk
Test Coverage
D
60%

File timeslot.js has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const HashLru = require('hashlru');

const instances = HashLru(1e3);

/**
Severity: Minor
Found in src/timeslot.js - About 5 hrs to fix

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

      static _getEpidemiologicWeekEpoch(year, periodicity) {
        var SUNDAY = 0,
          MONDAY = 1,
          TUESDAY = 2,
          WEDNESDAY = 3,
    Severity: Minor
    Found in src/timeslot.js - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function firstDate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      get firstDate() {
        if (!this._firstDate) {
          if (this._periodicity === 'day') this._firstDate = new Date(this._value + 'T00:00:00Z');
          else if (
            this._periodicity === 'month_week_sat' ||
    Severity: Minor
    Found in src/timeslot.js - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function lastDate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      get lastDate() {
        if (!this._lastDate) {
          if (this._periodicity === 'day')
            // last day is current day
            this._lastDate = this.firstDate;
    Severity: Minor
    Found in src/timeslot.js - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

      static fromDate(utcDate, periodicity) {
        if (typeof utcDate === 'string') utcDate = new Date(utcDate);
    
        if (periodicity === 'day') return TimeSlot.fromValue(utcDate.toISOString().substring(0, 10));
        else if (
    Severity: Minor
    Found in src/timeslot.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 _getEpidemiologicWeekEpoch has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static _getEpidemiologicWeekEpoch(year, periodicity) {
        var SUNDAY = 0,
          MONDAY = 1,
          TUESDAY = 2,
          WEDNESDAY = 3,
    Severity: Major
    Found in src/timeslot.js - About 2 hrs to fix

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

        get lastDate() {
          if (!this._lastDate) {
            if (this._periodicity === 'day')
              // last day is current day
              this._lastDate = this.firstDate;
      Severity: Major
      Found in src/timeslot.js - About 2 hrs to fix

        Function firstDate has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          get firstDate() {
            if (!this._firstDate) {
              if (this._periodicity === 'day') this._firstDate = new Date(this._value + 'T00:00:00Z');
              else if (
                this._periodicity === 'month_week_sat' ||
        Severity: Major
        Found in src/timeslot.js - About 2 hrs to fix

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

            static fromDate(utcDate, periodicity) {
              if (typeof utcDate === 'string') utcDate = new Date(utcDate);
          
              if (periodicity === 'day') return TimeSlot.fromValue(utcDate.toISOString().substring(0, 10));
              else if (
          Severity: Major
          Found in src/timeslot.js - About 2 hrs to fix

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

              constructor(value, check = false) {
                this._value = value;
                this._firstDate = null;
                this._lastDate = null;
                this._previous = null;
            Severity: Minor
            Found in src/timeslot.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 constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(value, check = false) {
                this._value = value;
                this._firstDate = null;
                this._lastDate = null;
                this._previous = null;
            Severity: Minor
            Found in src/timeslot.js - About 1 hr to fix

              Function toChildPeriodicity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                toChildPeriodicity(newPeriodicity) {
                  if (!this._children[newPeriodicity]) {
                    if (this._periodicity === 'all')
                      throw new Error('Would yield an infinite amount of children');
              
              
              Severity: Minor
              Found in src/timeslot.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 toParentPeriodicity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                toParentPeriodicity(newPeriodicity) {
                  if (!this._parents[newPeriodicity]) {
                    if (newPeriodicity == this._periodicity) {
                      this._parents[newPeriodicity] = this;
                    } else {
              Severity: Minor
              Found in src/timeslot.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

              Avoid deeply nested control flow statements.
              Open

                    } else if (this._periodicity === 'year')
                      this._firstDate = new Date(this._value + '-01-01T00:00:00Z');
                    else if (this._periodicity === 'all') this._firstDate = new Date(-8640000000000000);
              Severity: Major
              Found in src/timeslot.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        if (month2 < 10) month2 = '0' + month2;
                Severity: Major
                Found in src/timeslot.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return TimeSlot.fromValue(
                          utcDate.getUTCFullYear().toString() +
                            '-Q' +
                            (1 + Math.floor(utcDate.getUTCMonth() / 3)).toString()
                        );
                  Severity: Major
                  Found in src/timeslot.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        else if (periodicity === 'year') return TimeSlot.fromValue(utcDate.getUTCFullYear().toString());
                    Severity: Major
                    Found in src/timeslot.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return TimeSlot.fromValue(utcDate.toISOString().substring(0, 7));
                      Severity: Major
                      Found in src/timeslot.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return TimeSlot.fromValue(
                                utcDate.getUTCFullYear().toString() +
                                  '-S' +
                                  (1 + Math.floor(utcDate.getUTCMonth() / 6)).toString()
                              );
                        Severity: Major
                        Found in src/timeslot.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              else if (periodicity === 'all') return TimeSlot.fromValue('all');
                          Severity: Major
                          Found in src/timeslot.js - About 30 mins to fix

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

                                } else if (periodicity === 'week_sat') {
                                  if (firstDay === SATURDAY)
                                    // Lucky us, first day of year is Saturday
                                    epoch = Date.UTC(year, 0, 1, 0, 0, 0, 0);
                                  else if (firstDay === SUNDAY)
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 1 day to fix
                            src/timeslot.js on lines 120..186
                            src/timeslot.js on lines 164..186

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

                            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

                                } else if (periodicity === 'week_mon') {
                                  if (firstDay === MONDAY)
                                    // Lucky us, first day of year is Sunday
                                    epoch = Date.UTC(year, 0, 1, 0, 0, 0, 0);
                                  else if (firstDay === TUESDAY)
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 1 day to fix
                            src/timeslot.js on lines 120..186
                            src/timeslot.js on lines 142..186

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

                            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

                                if (periodicity === 'week_sun') {
                                  if (firstDay === SUNDAY)
                                    // Lucky us, first day of year is Sunday
                                    epoch = Date.UTC(year, 0, 1, 0, 0, 0, 0);
                                  else if (firstDay === MONDAY)
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 1 day to fix
                            src/timeslot.js on lines 142..186
                            src/timeslot.js on lines 164..186

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

                            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

                              next() {
                                if (!this._next) {
                                  if (this._periodicity === 'all') throw new Error('There is no next slot');
                            
                                  var date = new Date(this.lastDate.valueOf());
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 3 hrs to fix
                            src/timeslot.js on lines 488..498

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

                            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

                              previous() {
                                if (!this._previous) {
                                  if (this._periodicity === 'all') throw new Error('There is no previous slot');
                            
                                  var date = new Date(this.firstDate.valueOf());
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 3 hrs to fix
                            src/timeslot.js on lines 511..521

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

                            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

                                  else if (this._periodicity === 'quarter') {
                                    var month = (this._value.substring(6, 7) - 1) * 3 + 1;
                                    if (month < 10) month = '0' + month;
                            
                                    this._firstDate = new Date(this._value.substring(0, 5) + month + '-01T00:00:00Z');
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 2 hrs to fix
                            src/timeslot.js on lines 322..329

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

                            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

                                  } else if (this._periodicity === 'semester') {
                                    var month2 = (this._value.substring(6, 7) - 1) * 6 + 1;
                                    if (month2 < 10) month2 = '0' + month2;
                            
                                    this._firstDate = new Date(this._value.substring(0, 5) + month2 + '-01T00:00:00Z');
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 2 hrs to fix
                            src/timeslot.js on lines 317..329

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

                            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 (this._periodicity === 'month_week_sat')
                                      firstWeekLength = 7 - ((firstDayOfMonth + 1) % 7);
                                    else if (this._periodicity === 'month_week_sun') firstWeekLength = 7 - firstDayOfMonth;
                                    // 1 if month start on saturday, 2 if friday, 7 if sunday
                                    else firstWeekLength = 7 - ((firstDayOfMonth - 1 + 7) % 7);
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 2 hrs to fix
                            src/timeslot.js on lines 289..293

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

                            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 (this._periodicity === 'month_week_sat')
                                        firstWeekLength = 7 - ((firstDayOfMonth + 1) % 7);
                                      else if (this._periodicity === 'month_week_sun') firstWeekLength = 7 - firstDayOfMonth;
                                      // 1 if month start on saturday, 2 if friday, 7 if sunday
                                      else firstWeekLength = 7 - ((firstDayOfMonth - 1 + 7) % 7);
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 2 hrs to fix
                            src/timeslot.js on lines 357..361

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

                            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

                                  } else if (this._periodicity === 'quarter') {
                                    var quarterDate = new Date(this.firstDate.valueOf());
                                    quarterDate.setUTCMonth(quarterDate.getUTCMonth() + 3); // add three month.
                                    quarterDate.setUTCDate(0); // go to last day of previous month.
                                    this._lastDate = quarterDate;
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 2 hrs to fix
                            src/timeslot.js on lines 387..404
                            src/timeslot.js on lines 397..404

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

                            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

                                  } else if (this._periodicity === 'semester') {
                                    var semesterDate = new Date(this.firstDate.valueOf());
                                    semesterDate.setUTCMonth(semesterDate.getUTCMonth() + 6); // add six month.
                                    semesterDate.setUTCDate(0); // go to last day of previous month.
                                    this._lastDate = semesterDate;
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 2 hrs to fix
                            src/timeslot.js on lines 387..404
                            src/timeslot.js on lines 392..404

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

                            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

                                  } else if (this._periodicity === 'month') {
                                    var monthDate = new Date(this.firstDate.valueOf());
                                    monthDate.setUTCMonth(monthDate.getUTCMonth() + 1); // add one month.
                                    monthDate.setUTCDate(0); // go to last day of previous month.
                                    this._lastDate = monthDate;
                            Severity: Major
                            Found in src/timeslot.js and 2 other locations - About 2 hrs to fix
                            src/timeslot.js on lines 392..404
                            src/timeslot.js on lines 397..404

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

                            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

                                else if (periodicity === 'semester')
                                  return TimeSlot.fromValue(
                                    utcDate.getUTCFullYear().toString() +
                                      '-S' +
                                      (1 + Math.floor(utcDate.getUTCMonth() / 6)).toString()
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 1 hr to fix
                            src/timeslot.js on lines 80..94

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

                            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

                                else if (periodicity === 'quarter')
                                  return TimeSlot.fromValue(
                                    utcDate.getUTCFullYear().toString() +
                                      '-Q' +
                                      (1 + Math.floor(utcDate.getUTCMonth() / 3)).toString()
                            Severity: Major
                            Found in src/timeslot.js and 1 other location - About 1 hr to fix
                            src/timeslot.js on lines 86..94

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

                            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