busy-web/ember-date-time

View on GitHub

Showing 144 of 144 total issues

File ember-date-range-picker.js has 718 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module Components
 *
 */
import $ from 'jquery';
Severity: Major
Found in addon/components/ember-date-range-picker.js - About 1 day to fix

    File date-input.js has 699 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @module components
     *
     */
    import $ from 'jquery';
    Severity: Major
    Found in addon/components/private/date-input.js - About 1 day to fix

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

                  } else if (/^Y{1,4}$/.test(sectionFormat)) {
                      if (isUp && !_time.isDateAfter(_time(val).startOf('year'), get(this, 'max'))) {
                          val = val.date(_time(get(this, 'max')).date());
                          bounds = _time.isDateInBounds(val, get(this, 'min'), get(this, 'max'));
                      } else if (!isUp && !_time.isDateBefore(_time(val).endOf('year'))) {
      Severity: Major
      Found in addon/components/private/date-input.js and 1 other location - About 1 day to fix
      addon/components/private/date-input.js on lines 348..364

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

      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 (/^M(M|o)?$/.test(sectionFormat)) {
                      if (isUp && !_time.isDateAfter(_time(val).startOf('month'), get(this, 'max'))) {
                          val = val.date(_time(get(this, 'max')).date());
                          bounds = _time.isDateInBounds(val, get(this, 'min'), get(this, 'max'));
                      } else if (!isUp && !_time.isDateBefore(_time(val).endOf('month'))) {
      Severity: Major
      Found in addon/components/private/date-input.js and 1 other location - About 1 day to fix
      addon/components/private/date-input.js on lines 356..364

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

      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

      _time.isDateAfter = function(date, maxDate) {
          let isAfter = false;
          if (!isNone(maxDate)) {
              if (typeof maxDate === 'number' && !isNaN(maxDate)) {
                  maxDate = _time(maxDate);
      Severity: Major
      Found in addon/utils/time.js and 1 other location - About 6 hrs to fix
      addon/utils/time.js on lines 189..207

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

      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

      _time.isDateBefore = function(date, minDate) {
          let isBefore = false;
          if (!isNone(minDate)) {
              if (typeof minDate === 'number' && !isNaN(minDate)) {
                  minDate = _time(minDate);
      Severity: Major
      Found in addon/utils/time.js and 1 other location - About 6 hrs to fix
      addon/utils/time.js on lines 209..227

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

      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 setupTime has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          setupTime() {
              let timestamp = get(this, 'timestamp');
              let unix = get(this, 'unix');
              let minDate = get(this, 'minDate');
              let maxDate = get(this, 'maxDate');
      Severity: Minor
      Found in addon/components/ember-date-time-picker.js - About 4 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

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

          isBefore: computed('minDate', 'timestamp', function() {
              let isBefore = false;
              if (!isNone(this.get('timestamp'))) {
                  let date = this.get('date');
                  if (this.get('type') === 'date') {
      Severity: Major
      Found in addon/utils/state.js and 1 other location - About 4 hrs to fix
      addon/utils/state.js on lines 91..101

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

      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

          isAfter: computed('maxDate', 'timestamp', function() {
              let isAfter = false;
              if (!isNone(this.get('timestamp'))) {
                  let date = this.get('date');
                  if (this.get('type') === 'date') {
      Severity: Major
      Found in addon/utils/state.js and 1 other location - About 4 hrs to fix
      addon/utils/state.js on lines 72..82

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

      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 upDownArrows has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          upDownArrows(keyName) {
              const { sectionFormat, start, end } = getMeta(this);
              const type = sectionFormatType(this);
              let _date = get(this, '_date');
      
      
      Severity: Minor
      Found in addon/components/private/date-input.js - About 4 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 getInterval has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          getInterval(direction=0) {
              let { span, type } = get(this, 'selected');
              let start, end;
              if (!isEmpty(type) && !isNone(span)) {
                  start = _time(getStart(this)).valueOf();
      Severity: Minor
      Found in addon/components/ember-date-range-picker.js - About 4 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

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

              if (!get(this, 'changeFired') && (!isNone(this.getAttr('endTime')) || !isNone(this.getAttr('endUnix')))) {
                  setEnd(this, setUserEnd(this, (this.getAttr('endTime') || this.getAttr('endUnix'))));
              } else if (isNone(getEnd(this))) {
                  setEnd(this, _time().timestamp());
              }
      Severity: Major
      Found in addon/components/ember-date-range-picker.js and 1 other location - About 4 hrs to fix
      addon/components/ember-date-range-picker.js on lines 232..236

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

      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 (!get(this, 'changeFired') && (!isNone(this.getAttr('startTime')) || !isNone(this.getAttr('startUnix')))) {
                  setStart(this, setUserStart(this, (this.getAttr('startTime') || this.getAttr('startUnix'))));
              } else if (isNone(getStart(this))) {
                  setStart(this, _time().timestamp());
              }
      Severity: Major
      Found in addon/components/ember-date-range-picker.js and 1 other location - About 4 hrs to fix
      addon/components/ember-date-range-picker.js on lines 238..242

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

      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 buildDaysArrayForMonth has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        buildDaysArrayForMonth: function() {
              const calendarDate = get(this, 'calendarDate');
          const minDate =    get(this, 'stateManager.minDate');
          const maxDate = get(this, 'stateManager.maxDate');
              let [ startRange, endRange ] = (get(this, 'stateManager.range') || []);
      Severity: Minor
      Found in addon/components/private/date-picker.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

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

              focusAction(evt, section) {
                  if (!this.get('stateChangeInProgress')) {
                      this.set('stateChangeInProgress', true);
                      if (section === `m-${HOUR_FLAG}`) {
                          section = HOUR_FLAG;
      Severity: Major
      Found in addon/components/ember-date-time-picker.js and 1 other location - About 3 hrs to fix
      addon/components/ember-date-time-picker.js on lines 394..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 108.

      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

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

              stateChange(section) {
                  if (!this.get('stateChangeInProgress')) {
                      this.set('stateChangeInProgress', true);
                      if (section === `m-${HOUR_FLAG}`) {
                          section = HOUR_FLAG;
      Severity: Major
      Found in addon/components/ember-date-time-picker.js and 1 other location - About 3 hrs to fix
      addon/components/ember-date-time-picker.js on lines 412..422

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

      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 (get(this, 'utc')) {
                          time = _time.utcToLocal(timestamp).timestamp();
                          if (!isNone(minDate)) { min = _time.utcToLocal(minDate).timestamp(); }
                          if (!isNone(maxDate)) { max = _time.utcToLocal(maxDate).timestamp(); }
                      }
      Severity: Major
      Found in addon/components/ember-date-time-picker.js and 1 other location - About 3 hrs to fix
      addon/components/ember-date-time-picker.js on lines 197..201

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

      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 (get(this, 'utc')) {
                          time = _time.utcToLocal(time).timestamp();
                          if (!isNone(minDate)) { min = _time.utcToLocal(min).timestamp(); }
                          if (!isNone(maxDate)) { max = _time.utcToLocal(max).timestamp(); }
                      }
      Severity: Major
      Found in addon/components/ember-date-time-picker.js and 1 other location - About 3 hrs to fix
      addon/components/ember-date-time-picker.js on lines 203..207

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

      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 setup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          setup: on('init', function() {
              const isUnix = !isNone(get(this, 'startUnix')) || !isNone(get(this, 'endUnix'));
              set(this, '_isUnix', isUnix);
      
              // get locale converted format str
      Severity: Minor
      Found in addon/components/ember-date-range-picker.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 setup has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setup: on('init', function() {
              const isUnix = !isNone(get(this, 'startUnix')) || !isNone(get(this, 'endUnix'));
              set(this, '_isUnix', isUnix);
      
              // get locale converted format str
      Severity: Major
      Found in addon/components/ember-date-range-picker.js - About 3 hrs to fix
        Severity
        Category
        Status
        Source
        Language