MatthewCallis/duration-input

View on GitHub
lib/duration-input.js

Summary

Maintainability
F
1 wk
Test Coverage

Function DurationInput has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring.
Open

var DurationInput = (function () {
'use strict';

var asyncGenerator = function () {
  function AwaitValue(value) {
Severity: Minor
Found in lib/duration-input.js - About 2 days 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 DurationInput has 329 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var DurationInput = (function () {
'use strict';

var asyncGenerator = function () {
  function AwaitValue(value) {
Severity: Major
Found in lib/duration-input.js - About 1 day to fix

    Function DurationInput has 210 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var DurationInput = function () {
      function DurationInput(element) {
        var _this = this;
    
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    Severity: Major
    Found in lib/duration-input.js - About 1 day to fix

      Function DurationInput has 149 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function DurationInput(element) {
          var _this = this;
      
          var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
          classCallCheck(this, DurationInput);
      Severity: Major
      Found in lib/duration-input.js - About 5 hrs to fix

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

        var DurationInput = (function () {
        'use strict';
        
        var asyncGenerator = function () {
          function AwaitValue(value) {
        Severity: Minor
        Found in lib/duration-input.js - About 4 hrs to fix

          Function asyncGenerator has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var asyncGenerator = function () {
            function AwaitValue(value) {
              this.value = value;
            }
          
          
          Severity: Major
          Found in lib/duration-input.js - About 3 hrs to fix

            Function AsyncGenerator has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function AsyncGenerator(gen) {
                var front, back;
            
                function send(key, arg) {
                  return new Promise(function (resolve, reject) {
            Severity: Major
            Found in lib/duration-input.js - About 2 hrs to fix

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

                  if (Math.floor(d) !== 0) {
                    type.value = 'days';
                    duration.value = d;
                    duration.style.display = null;
                  } else if (Math.floor(h) !== 0) {
              Severity: Major
              Found in lib/duration-input.js and 1 other location - About 1 day to fix
              src/duration-input.js on lines 89..113

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

              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

                  var defaults$$1 = {
                    duration: 0,
                    debug: false,
                    allowedFields: ['immediately', 'days', 'hours', 'minutes'],
                    minimum: null,
              Severity: Major
              Found in lib/duration-input.js and 1 other location - About 3 hrs to fix
              src/duration-input.js on lines 6..28

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

              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

                  if (!this.settings.debug) {
                    this.element.style.visibility = 'hidden';
                    this.element.style.position = 'absolute';
                    this.element.style.height = 0;
                    this.element.style.width = 0;
              Severity: Major
              Found in lib/duration-input.js and 1 other location - About 3 hrs to fix
              src/duration-input.js on lines 37..42

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

              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 ([190].indexOf(e.which) !== -1 && !(e.currentTarget.value && e.currentTarget.value.match(/\./g))) {
                      return;
                    }
              Severity: Major
              Found in lib/duration-input.js and 1 other location - About 1 hr to fix
              src/duration-input.js on lines 160..160

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

              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 ((e.ctrlKey || e.metaKey) === true && [65, 67, 86, 88, 90].indexOf(e.which) !== -1) {
                      return;
                    }
              Severity: Major
              Found in lib/duration-input.js and 1 other location - About 1 hr to fix
              src/duration-input.js on lines 162..162

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

              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

                  try {
                    for (var _iterator = this.settings.allowedFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
                      var field = _step.value;
              
                      var option = document.createElement('option');
              Severity: Minor
              Found in lib/duration-input.js and 1 other location - About 50 mins to fix
              lib/duration-input.js on lines 342..363

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

              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

                    try {
                      for (var _iterator2 = events[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
                        var event = _step2.value;
              
                        var ev = document.createEvent('HTMLEvents');
              Severity: Minor
              Found in lib/duration-input.js and 1 other location - About 50 mins to fix
              lib/duration-input.js on lines 229..252

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

              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

                  if (this.settings.required) {
                    duration.required = true;
                    duration.setAttribute('data-msg', this.settings.required_text);
                  }
              Severity: Minor
              Found in lib/duration-input.js and 1 other location - About 35 mins to fix
              src/duration-input.js on lines 63..66

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

              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