lib/timeline/component/ItemSet.js

Summary

Maintainability
F
2 wks
Test Coverage

File ItemSet.js has 1554 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Hammer = require('../../module/hammer');
var util = require('../../util');
var DataSet = require('../../DataSet');
var DataView = require('../../DataView');
var TimeStep = require('../TimeStep');
Severity: Major
Found in lib/timeline/component/ItemSet.js - About 4 days to fix

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

    ItemSet.prototype.setOptions = function(options) {
      if (options) {
        // copy all options that we know
        var fields = [
          'type', 'rtl', 'align', 'order', 'stack', 'stackSubgroups', 'selectable', 'multiselect',
    Severity: Minor
    Found in lib/timeline/component/ItemSet.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 _onMultiSelectItem has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    ItemSet.prototype._onMultiSelectItem = function (event) {
      if (!this.options.selectable) return;
    
      var item = this.itemFromTarget(event);
    
    
    Severity: Minor
    Found in lib/timeline/component/ItemSet.js - About 7 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 _onGroupDrag has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

    ItemSet.prototype._onGroupDrag = function (event) {
        if (this.options.groupEditable.order && this.groupTouchParams.group) {
            event.stopPropagation();
            
        var groupsData = this.groupsData;
    Severity: Minor
    Found in lib/timeline/component/ItemSet.js - About 7 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 ItemSet has 142 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function ItemSet(body, options) {
      this.body = body;
      this.defaultOptions = {
        type: null,  // 'box', 'point', 'range', 'background'
        orientation: {
    Severity: Major
    Found in lib/timeline/component/ItemSet.js - About 5 hrs to fix

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

      ItemSet.prototype._onDrag = function (event) {
        if (this.touchParams.itemProps) {
          event.stopPropagation();
      
          var me = this;
      Severity: Major
      Found in lib/timeline/component/ItemSet.js - About 4 hrs to fix

        Function _onAddItem has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        ItemSet.prototype._onAddItem = function (event) {
          if (!this.options.selectable) return;
          if (!this.options.editable.add) return;
        
          var me = this;
        Severity: Minor
        Found in lib/timeline/component/ItemSet.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 getVisibleItems has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        ItemSet.prototype.getVisibleItems = function() {
          var range = this.body.range.getRange();
          var right, left;
        
          if (this.options.rtl) { 
        Severity: Minor
        Found in lib/timeline/component/ItemSet.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 _onDragStart has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        ItemSet.prototype._onDragStart = function (event) {
          if (this.touchParams.itemIsDragging) { return; }
          var item = this.touchParams.item || null;
          var me = this;
          var props;
        Severity: Minor
        Found in lib/timeline/component/ItemSet.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 setOptions has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ItemSet.prototype.setOptions = function(options) {
          if (options) {
            // copy all options that we know
            var fields = [
              'type', 'rtl', 'align', 'order', 'stack', 'stackSubgroups', 'selectable', 'multiselect',
        Severity: Major
        Found in lib/timeline/component/ItemSet.js - About 3 hrs to fix

          Function redraw has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ItemSet.prototype.redraw = function() {
            var margin = this.options.margin,
                range = this.body.range,
                asSize = util.option.asSize,
                options = this.options,
          Severity: Major
          Found in lib/timeline/component/ItemSet.js - About 3 hrs to fix

            Function _updateUngrouped has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            ItemSet.prototype._updateUngrouped = function() {
              var ungrouped = this.groups[UNGROUPED];
              var item, itemId;
            
              if (this.groupsData) {
            Severity: Minor
            Found in lib/timeline/component/ItemSet.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 _onGroupDrag has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ItemSet.prototype._onGroupDrag = function (event) {
                if (this.options.groupEditable.order && this.groupTouchParams.group) {
                    event.stopPropagation();
                    
                var groupsData = this.groupsData;
            Severity: Major
            Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                if (this.touchParams.itemProps) {
                  event.stopPropagation();
              
                  var me = this;
                  var snap = this.options.snap || null;
              Severity: Critical
              Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

                Function _onDragStart has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ItemSet.prototype._onDragStart = function (event) {
                  if (this.touchParams.itemIsDragging) { return; }
                  var item = this.touchParams.item || null;
                  var me = this;
                  var props;
                Severity: Major
                Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

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

                  ItemSet.prototype._onDrag = function (event) {
                    if (this.touchParams.itemProps) {
                      event.stopPropagation();
                  
                      var me = this;
                  Severity: Minor
                  Found in lib/timeline/component/ItemSet.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 _onAddItem has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ItemSet.prototype._onAddItem = function (event) {
                    if (!this.options.selectable) return;
                    if (!this.options.editable.add) return;
                  
                    var me = this;
                  Severity: Major
                  Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

                    Function _create has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ItemSet.prototype._create = function(){
                      var frame = document.createElement('div');
                      frame.className = 'vis-itemset';
                      frame['timeline-itemset'] = this;
                      this.dom.frame = frame;
                    Severity: Major
                    Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

                      Function _onMultiSelectItem has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ItemSet.prototype._onMultiSelectItem = function (event) {
                        if (!this.options.selectable) return;
                      
                        var item = this.itemFromTarget(event);
                      
                      
                      Severity: Major
                      Found in lib/timeline/component/ItemSet.js - About 2 hrs to fix

                        Function setGroups has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ItemSet.prototype.setGroups = function(groups) {
                          var me = this,
                              ids;
                        
                          // unsubscribe from current dataset
                        Severity: Minor
                        Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                          Function _onDragStartAddItem has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ItemSet.prototype._onDragStartAddItem = function (event) {
                            var xAbs;
                            var x;
                            var snap = this.options.snap || null;
                          
                          
                          Severity: Minor
                          Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                            Function groupFromTarget has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            ItemSet.prototype.groupFromTarget = function(event) {
                              var clientY = event.center ? event.center.y : event.clientY;
                              var groupIds = this.groupIds;
                              
                              if (groupIds.length <= 0 && this.groupsData) {
                            Severity: Minor
                            Found in lib/timeline/component/ItemSet.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 _onGroupDragEnd has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ItemSet.prototype._onGroupDragEnd = function (event) {
                              if (this.options.groupEditable.order && this.groupTouchParams.group) {
                                event.stopPropagation();
                                    
                                // update existing group
                            Severity: Minor
                            Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                              Function _onUpdate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              ItemSet.prototype._onUpdate = function(ids) {
                                var me = this;
                              
                                ids.forEach(function (id) {
                                  var itemData = me.itemsData.get(id, me.itemOptions);
                              Severity: Minor
                              Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                Function _onDragEnd has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                ItemSet.prototype._onDragEnd = function (event) {
                                  this.touchParams.itemIsDragging = false;
                                  if (this.touchParams.itemProps) {
                                    event.stopPropagation();
                                
                                
                                Severity: Minor
                                Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                  Function _updateUngrouped has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  ItemSet.prototype._updateUngrouped = function() {
                                    var ungrouped = this.groups[UNGROUPED];
                                    var item, itemId;
                                  
                                    if (this.groupsData) {
                                  Severity: Minor
                                  Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                    Function _onAddGroups has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    ItemSet.prototype._onAddGroups = function(ids) {
                                      var me = this;
                                    
                                      ids.forEach(function (id) {
                                        var groupData = me.groupsData.get(id);
                                    Severity: Minor
                                    Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                      Function setItems has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      ItemSet.prototype.setItems = function(items) {
                                        var me = this,
                                            ids,
                                            oldItemsData = this.itemsData;
                                      
                                      
                                      Severity: Minor
                                      Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                        Function getVisibleItems has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                        ItemSet.prototype.getVisibleItems = function() {
                                          var range = this.body.range.getRange();
                                          var right, left;
                                        
                                          if (this.options.rtl) { 
                                        Severity: Minor
                                        Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

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

                                          ItemSet.prototype._onMouseOver = function (event) {
                                            var item = this.itemFromTarget(event);
                                            if (!item) return;
                                          
                                            // Item we just left
                                          Severity: Minor
                                          Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                            Function _onMouseOver has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                            ItemSet.prototype._onMouseOver = function (event) {
                                              var item = this.itemFromTarget(event);
                                              if (!item) return;
                                            
                                              // Item we just left
                                            Severity: Minor
                                            Found in lib/timeline/component/ItemSet.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 groupFromTarget has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                            ItemSet.prototype.groupFromTarget = function(event) {
                                              var clientY = event.center ? event.center.y : event.clientY;
                                              var groupIds = this.groupIds;
                                              
                                              if (groupIds.length <= 0 && this.groupsData) {
                                            Severity: Minor
                                            Found in lib/timeline/component/ItemSet.js - About 1 hr to fix

                                              Function redraw has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                              ItemSet.prototype.redraw = function() {
                                                var margin = this.options.margin,
                                                    range = this.body.range,
                                                    asSize = util.option.asSize,
                                                    options = this.options,
                                              Severity: Minor
                                              Found in lib/timeline/component/ItemSet.js - About 55 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 deeply nested control flow statements.
                                              Open

                                                          if (itemData.end != undefined) {
                                                            initialEnd = util.convert(props.data.end, 'Date');
                                                            end = new Date(initialEnd.valueOf() + offset);
                                                            // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                            itemData.end = snap ? snap(end, scale, step) : end;
                                              Severity: Major
                                              Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                    while ((curPos+newOffset) < numGroups 
                                                                        && (curPos+orgOffset) < numGroups 
                                                                        && newOrder[curPos+newOffset] == origOrder[curPos+orgOffset]) {
                                                                        curPos++;
                                                                    }
                                                Severity: Major
                                                Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                              if (curPos >= numGroups) {
                                                                break;
                                                              }
                                                  Severity: Major
                                                  Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                              if (itemData.start != undefined) {
                                                    
                                                                initialStart = util.convert(props.data.start, 'Date').valueOf();
                                                                start = new Date(initialStart + offset);
                                                    
                                                    
                                                    Severity: Major
                                                    Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                if (this.items.hasOwnProperty(id)) {
                                                                  var _item = this.items[id];
                                                                  var start = _item.data.start;
                                                                  var end = (_item.data.end !== undefined) ? _item.data.end : start;
                                                      
                                                      
                                                      Severity: Major
                                                      Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                    while (curPos < numGroups && newOrder[curPos] == origOrder[curPos]) {
                                                                      curPos++;
                                                                    }
                                                        Severity: Major
                                                        Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                          Avoid deeply nested control flow statements.
                                                          Open

                                                                    if (typeof options.margin.item === 'number') {
                                                                      this.options.margin.item.horizontal = options.margin.item;
                                                                      this.options.margin.item.vertical = options.margin.item;
                                                                    }
                                                                    else if (typeof options.margin.item === 'object') {
                                                          Severity: Major
                                                          Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                if (curPos+newOffset >= numGroups) {
                                                                                    break;
                                                                                }
                                                            Severity: Major
                                                            Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                                  if (newOrder[curPos+newOffset] == draggedId) {
                                                                                      newOffset = 1;
                                                              
                                                                                  }
                                                                                  // if dragged group was move downwards everything above should have an offset
                                                              Severity: Major
                                                              Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

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

                                                                ItemSet.prototype.setSelection = function(ids) {
                                                                  var i, ii, id, item;
                                                                
                                                                  if (ids == undefined) ids = [];
                                                                  if (!Array.isArray(ids)) ids = [ids];
                                                                Severity: Minor
                                                                Found in lib/timeline/component/ItemSet.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

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                          if ((item.right < left) && (item.right + item.width > right)) {
                                                                            ids.push(item.id);
                                                                          }
                                                                Severity: Major
                                                                Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                            if (this.options.rtl) {
                                                                              if (itemData.start != undefined) {
                                                                                initialStart = util.convert(props.data.start, 'Date');
                                                                                start = new Date(initialStart.valueOf() + offset);
                                                                                // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                  Severity: Major
                                                                  Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                              if ((item.left < right) && (item.left + item.width > left)) {
                                                                                ids.push(item.id);
                                                                              }
                                                                    Severity: Major
                                                                    Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                  if (itemData.start != undefined) {
                                                                                    initialStart = util.convert(props.data.start, 'Date');
                                                                                    start = new Date(initialStart.valueOf() + offset);
                                                                                    // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                                    itemData.start = snap ? snap(start, scale, step) : start;
                                                                      Severity: Major
                                                                      Found in lib/timeline/component/ItemSet.js - About 45 mins to fix

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

                                                                        ItemSet.prototype._onMouseMove = function (event) {
                                                                          var item = this.itemFromTarget(event);
                                                                          if (!item) return;
                                                                        
                                                                          if (this.options.showTooltips && this.options.tooltip.followMouse) {
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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 setGroups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                        ItemSet.prototype.setGroups = function(groups) {
                                                                          var me = this,
                                                                              ids;
                                                                        
                                                                          // unsubscribe from current dataset
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

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

                                                                        ItemSet.prototype._onGroupClick = function (event) {
                                                                          var group = this.groupFromTarget(event);
                                                                        
                                                                          if (!group || !group.nestedGroups) return;
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

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

                                                                        ItemSet.prototype._onSelectItem = function (event) {
                                                                          if (!this.options.selectable) return;
                                                                        
                                                                          var ctrlKey  = event.srcEvent && (event.srcEvent.ctrlKey || event.srcEvent.metaKey);
                                                                          var shiftKey = event.srcEvent && event.srcEvent.shiftKey;
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

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

                                                                        ItemSet.prototype.show = function() {
                                                                          // show frame containing the items
                                                                          if (!this.dom.frame.parentNode) {
                                                                            this.body.dom.center.appendChild(this.dom.frame);
                                                                          }
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

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

                                                                        ItemSet.prototype._onDragStartAddItem = function (event) {
                                                                          var xAbs;
                                                                          var x;
                                                                          var snap = this.options.snap || null;
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

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

                                                                        ItemSet.prototype._cloneItemData = function (itemData, type) {
                                                                          var clone = util.extend({}, itemData);
                                                                        
                                                                          if (!type) {
                                                                            // convert start and end date to the type (Date, Moment, ...) configured in the DataSet
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.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

                                                                        TODO found
                                                                        Open

                                                                              // TODO: need to trigger a redraw?
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                // TODO: deprecated since version 2.1.0 (or 3.0.0?). cleanup some day
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                item.id = id; // TODO: not so nice setting id afterwards
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                          // TODO: would be nicer to get this as a trigger from Range
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                          // TODO: optimization: only reorder groups affected by the changed items
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                          newItem.id = id; // TODO: not so nice setting id afterwards
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                // TODO: also check whether visible vertically
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        TODO found
                                                                        Open

                                                                                      // TODO: pass a Moment instead of a Date to snap(). (Breaking change)
                                                                        Severity: Minor
                                                                        Found in lib/timeline/component/ItemSet.js by fixme

                                                                        There are no issues that match your filters.

                                                                        Category
                                                                        Status