romain-gilliotte/timeslot-dag

View on GitHub

Showing 22 of 41 total issues

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

              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

                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

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