romain-gilliotte/timeslot-dag

View on GitHub

Showing 41 of 41 total issues

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

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

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

    const PERIODICITIES = {
      day: 'Jour',
      month_week_sat: 'Semaines (samedi à vendredi / coupées par mois)',
      month_week_sun: 'Semaines (dimanche à samedi / coupées par mois)',
      month_week_mon: 'Semaines (lundi à dimanche / coupées par mois)',
    Severity: Major
    Found in src/locale/fr.js and 2 other locations - About 1 hr to fix
    src/locale/en.js on lines 16..29
    src/locale/es.js on lines 20..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    const PERIODICITIES = {
      day: 'Día',
      month_week_sat: 'Semana (sábado a viernes / cortado por mes)',
      month_week_sun: 'Semana (domingo a sábado / cortado por mes)',
      month_week_mon: 'Semana (lunes a domingo / cortado por mes)',
    Severity: Major
    Found in src/locale/es.js and 2 other locations - About 1 hr to fix
    src/locale/en.js on lines 16..29
    src/locale/fr.js on lines 20..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    const PERIODICITIES = {
      day: 'Day',
      month_week_sat: 'Week (saturday to friday / split by month)',
      month_week_sun: 'Week (sunday to saturday / split by month)',
      month_week_mon: 'Week (monday to sunday / split by month)',
    Severity: Major
    Found in src/locale/en.js and 2 other locations - About 1 hr to fix
    src/locale/es.js on lines 20..33
    src/locale/fr.js on lines 20..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function 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

      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

      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

      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

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

        humanizeValue(periodicity, value) {
          const year = value.substring(0, 4);
      
          switch (periodicity) {
            case 'all':
      Severity: Minor
      Found in src/locale/fr.js - About 1 hr to fix

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

          humanizeValue(periodicity, value) {
            const year = value.substring(0, 4);
        
            switch (periodicity) {
              case 'all':
        Severity: Minor
        Found in src/locale/es.js - About 1 hr 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 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 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

                      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

                      else if (periodicity === 'all') return TimeSlot.fromValue('all');
                  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
                      Severity
                      Category
                      Status
                      Source
                      Language