busy-web/ember-date-time

View on GitHub
addon/components/private/date-input.js

Summary

Maintainability
F
6 days
Test Coverage

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

    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 upDownArrows has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        upDownArrows(keyName) {
            const { sectionFormat, start, end } = getMeta(this);
            const type = sectionFormatType(this);
            let _date = get(this, '_date');
    
    
    Severity: Major
    Found in addon/components/private/date-input.js - About 2 hrs to fix

      `` has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default TextField.extend({
          classNames: ['busyweb', 'emberdatetime', 'p-date-input'],
          classNameBindings: ['isDateInRange::invalid', 'active'],
      
          type: 'text',
      Severity: Minor
      Found in addon/components/private/date-input.js - About 2 hrs to fix

        Function keyDown has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            keyDown(event) {
                if (isModifierKeyActive(this, event)) {
                    return true;
                }
        
        
        Severity: Minor
        Found in addon/components/private/date-input.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 handleCursor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function handleCursor(target, action='', triggerChange=true) {
            return new EmberPromise(resolve => {
                later(() => {
                    const { format, selection } = getMeta(target);
                    const value = getValue(target);
        Severity: Minor
        Found in addon/components/private/date-input.js - About 1 hr to fix

          Function sectionBounds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function sectionBounds(target) {
              let type = sectionFormatType(target);
              let max, min = 1;
              if (type === DAY_FLAG) {
                  const date = _time(get(target, '_date'));
          Severity: Minor
          Found in addon/components/private/date-input.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 didInsertElement has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              didInsertElement(...args) {
                  this._super(...args);
          
                  const target = this.$().get(0);
          
          
          Severity: Minor
          Found in addon/components/private/date-input.js - About 1 hr to fix

            Function keyDown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                keyDown(event) {
                    if (isModifierKeyActive(this, event)) {
                        return true;
                    }
            
            
            Severity: Minor
            Found in addon/components/private/date-input.js - About 1 hr to fix

              Function getInBoundsDate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function getInBoundsDate(date, min, max) {
                  const adjustTime = (d1, d2) => {
                      if (d1.hours() < d2.hours()) d2.hours(d1.hours());
                      if (d1.minutes() < d2.minutes()) d2.minutes(d1.minutes());
                      if (d1.seconds() < d2.seconds()) d2.seconds(d1.seconds());
              Severity: Minor
              Found in addon/components/private/date-input.js - About 45 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function setDateSection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  setDateSection(valueSection, position) {
                      let { sectionFormat, start, end } = getMeta(this);
                      let { min, max } = sectionBounds(this);
              
                      // moves the start ahead on position when the valueSection
              Severity: Minor
              Found in addon/components/private/date-input.js - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Avoid too many return statements within this function.
              Open

                                      return this.sendAction('ontabkey', event, handler);
              Severity: Major
              Found in addon/components/private/date-input.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return this.handleDeleteKey(event, handler);
                Severity: Major
                Found in addon/components/private/date-input.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return false;
                  Severity: Major
                  Found in addon/components/private/date-input.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return handler.preventDefault();
                    Severity: Major
                    Found in addon/components/private/date-input.js - About 30 mins to fix

                      Function isDateInRange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          isDateInRange: computed('value', function() {
                              // before render the position has not been set so
                              // resume calculations as if position were 0
                              let position = 0;
                              if (this.$() && this.$().length && !isEmpty(getData(this.$(), 'format'))) {
                      Severity: Minor
                      Found in addon/components/private/date-input.js - About 25 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

                      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

                                  } 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

                              max = isNone(get(target, 'max')) ? _time().add(100, 'years').endOf('year').year() : _time(get(target, 'max')).endOf('year').year();
                      Severity: Major
                      Found in addon/components/private/date-input.js and 1 other location - About 1 hr to fix
                      addon/components/private/date-input.js on lines 605..605

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

                      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

                              min = isNone(get(target, 'min')) ? _time().subtract(100, 'years').startOf('year').year() : _time(get(target, 'min')).startOf('year').year();
                      Severity: Major
                      Found in addon/components/private/date-input.js and 1 other location - About 1 hr to fix
                      addon/components/private/date-input.js on lines 604..604

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

                      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

                              bind(
                                  target,
                                  'click',
                                  `ember-date-time.date-input.${this.get('elementId')}`,
                                  (...args) => this.clickEvent(...args),
                      Severity: Major
                      Found in addon/components/private/date-input.js and 2 other locations - About 1 hr to fix
                      addon/components/private/date-input.js on lines 121..127
                      addon/components/private/date-input.js on lines 129..135

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 55.

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

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

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

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

                      Refactorings

                      Further Reading

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

                              bind(
                                  target,
                                  'focusout',
                                  `ember-date-time.date-input.${this.get('elementId')}`,
                                  (...args) => this.focusOutEvent(...args),
                      Severity: Major
                      Found in addon/components/private/date-input.js and 2 other locations - About 1 hr to fix
                      addon/components/private/date-input.js on lines 113..119
                      addon/components/private/date-input.js on lines 121..127

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 55.

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

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

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

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

                      Refactorings

                      Further Reading

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

                              bind(
                                  target,
                                  'focusin',
                                  `ember-date-time.date-input.${this.get('elementId')}`,
                                  (...args) => this.focusInEvent(...args),
                      Severity: Major
                      Found in addon/components/private/date-input.js and 2 other locations - About 1 hr to fix
                      addon/components/private/date-input.js on lines 113..119
                      addon/components/private/date-input.js on lines 129..135

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 55.

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

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

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

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

                      Refactorings

                      Further Reading

                      There are no issues that match your filters.

                      Category
                      Status