lib/timeline/Range.js

Summary

Maintainability
F
5 days
Test Coverage

File Range.js has 530 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('../util');
var moment = require('../module/moment');
var Component = require('./component/Component');
var DateUtil = require('./DateUtil');

Severity: Major
Found in lib/timeline/Range.js - About 1 day to fix

    Function _applyRange has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    Range.prototype._applyRange = function(start, end) {
      var newStart = (start != null) ? util.convert(start, 'Date').valueOf() : this.start,
          newEnd   = (end != null)   ? util.convert(end, 'Date').valueOf()   : this.end,
          max = (this.options.max != null) ? util.convert(this.options.max, 'Date').valueOf() : null,
          min = (this.options.min != null) ? util.convert(this.options.min, 'Date').valueOf() : null,
    Severity: Minor
    Found in lib/timeline/Range.js - About 1 day 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 setRange has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
      if (!options) {
        options = {};
      }
      if (options.byUser !== true) {
    Severity: Minor
    Found in lib/timeline/Range.js - About 1 day 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 _applyRange has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Range.prototype._applyRange = function(start, end) {
      var newStart = (start != null) ? util.convert(start, 'Date').valueOf() : this.start,
          newEnd   = (end != null)   ? util.convert(end, 'Date').valueOf()   : this.end,
          max = (this.options.max != null) ? util.convert(this.options.max, 'Date').valueOf() : null,
          min = (this.options.min != null) ? util.convert(this.options.min, 'Date').valueOf() : null,
    Severity: Major
    Found in lib/timeline/Range.js - About 3 hrs to fix

      Function setRange has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
        if (!options) {
          options = {};
        }
        if (options.byUser !== true) {
      Severity: Major
      Found in lib/timeline/Range.js - About 3 hrs to fix

        Function _onMouseWheel has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        Range.prototype._onMouseWheel = function(event) {
          // retrieve delta
          var delta = 0;
          if (event.wheelDelta) { /* IE/Opera. */
            delta = event.wheelDelta / 120;
        Severity: Minor
        Found in lib/timeline/Range.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 Range has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Range(body, options) {
          var now = moment().hours(0).minutes(0).seconds(0).milliseconds(0);
          var start = now.clone().add(-3, 'days').valueOf();
          var end = now.clone().add(3, 'days').valueOf(); 
          this.millisecondsPerPixelCache = undefined;
        Severity: Minor
        Found in lib/timeline/Range.js - About 1 hr to fix

          Function _onDrag has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Range.prototype._onDrag = function (event) {
            if (!event) return;
          
            if (!this.props.touch.dragging) return;
          
          
          Severity: Minor
          Found in lib/timeline/Range.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

              if (!((newStart >= this.start && newStart   <= this.end) || (newEnd   >= this.start && newEnd   <= this.end)) &&
                  !((this.start >= newStart && this.start <= newEnd)   || (this.end >= newStart   && this.end <= newEnd) )) {
                this.body.emitter.emit('checkRangedItems');
              }
            Severity: Critical
            Found in lib/timeline/Range.js - About 1 hr to fix

              Function _onPinch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Range.prototype._onPinch = function (event) {
                // only allow zooming when configured as zoomable and moveable
                if (!(this.options.zoomable && this.options.moveable)) return;
              
                // Disable the browser default handling of this event.
              Severity: Minor
              Found in lib/timeline/Range.js - About 1 hr to fix

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

                Range.prototype._onDrag = function (event) {
                  if (!event) return;
                
                  if (!this.props.touch.dragging) return;
                
                
                Severity: Minor
                Found in lib/timeline/Range.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 next has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var next = function () {
                      if (!me.props.touch.dragging) {
                        var now = new Date().valueOf();
                        var time = now - initTime;
                        var ease = easingFunction(time / duration);
                Severity: Minor
                Found in lib/timeline/Range.js - About 1 hr to fix

                  Function _onMouseWheel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Range.prototype._onMouseWheel = function(event) {
                    // retrieve delta
                    var delta = 0;
                    if (event.wheelDelta) { /* IE/Opera. */
                      delta = event.wheelDelta / 120;
                  Severity: Minor
                  Found in lib/timeline/Range.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (callback) { return callback() }
                    Severity: Major
                    Found in lib/timeline/Range.js - About 45 mins to fix

                      Function setRange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      Range.prototype.setRange = function(start, end, options, callback, frameCallback) {
                      Severity: Minor
                      Found in lib/timeline/Range.js - About 35 mins to fix

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

                        Range.prototype.setOptions = function (options) {
                          if (options) {
                            // copy the options that we know
                            var fields = [
                              'animation', 'direction', 'min', 'max', 'zoomMin', 'zoomMax', 'moveable', 'zoomable',
                        Severity: Minor
                        Found in lib/timeline/Range.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;
                        Severity: Major
                        Found in lib/timeline/Range.js - About 30 mins to fix

                          TODO found
                          Open

                            // TODO: reckon with min and max range
                          Severity: Minor
                          Found in lib/timeline/Range.js by fixme

                          TODO found
                          Open

                            // TODO: this may be redundant in hammerjs2
                          Severity: Minor
                          Found in lib/timeline/Range.js by fixme

                          TODO found
                          Open

                            // TODO: this may be redundant in hammerjs2
                          Severity: Minor
                          Found in lib/timeline/Range.js by fixme

                          There are no issues that match your filters.

                          Category
                          Status