lib/timeline/component/Group.js

Summary

Maintainability
F
6 days
Test Coverage

File Group.js has 659 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('../../util');
var stack = require('../Stack');

/**
 * @param {number | string} groupId
Severity: Major
Found in lib/timeline/component/Group.js - About 1 day to fix

    Function setData has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    Group.prototype.setData = function(data) {
      // update contents
      var content;
      var templateFunction;
    
    
    Severity: Minor
    Found in lib/timeline/component/Group.js - About 6 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 _redrawItems has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, range) {
      var restack = forceRestack || this.stackDirty || this.isVisible && !lastIsVisible;
    
      // if restacking, reposition visible items vertically
      if (restack) {
    Severity: Minor
    Found in lib/timeline/component/Group.js - About 5 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 setData has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Group.prototype.setData = function(data) {
      // update contents
      var content;
      var templateFunction;
    
    
    Severity: Major
    Found in lib/timeline/component/Group.js - About 3 hrs to fix

      Function _traceVisible has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      Group.prototype._traceVisible = function (initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
        if (initialPos != -1) {
          var i, item;
          for (i = initialPos; i >= 0; i--) {
            item = items[i];
      Severity: Minor
      Found in lib/timeline/component/Group.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 _updateItemsInRange has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      Group.prototype._updateItemsInRange = function(orderedItems, oldVisibleItems, range) {
        var visibleItems = [];
        var visibleItemsLookup = {}; // we keep this to quickly look up if an item already exists in the list without using indexOf on visibleItems
      
        var interval = (range.end - range.start) / 4;
      Severity: Minor
      Found in lib/timeline/component/Group.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 _redrawItems has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, range) {
        var restack = forceRestack || this.stackDirty || this.isVisible && !lastIsVisible;
      
        // if restacking, reposition visible items vertically
        if (restack) {
      Severity: Major
      Found in lib/timeline/component/Group.js - About 2 hrs to fix

        Function _updateItemsInRange has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Group.prototype._updateItemsInRange = function(orderedItems, oldVisibleItems, range) {
          var visibleItems = [];
          var visibleItemsLookup = {}; // we keep this to quickly look up if an item already exists in the list without using indexOf on visibleItems
        
          var interval = (range.end - range.start) / 4;
        Severity: Major
        Found in lib/timeline/component/Group.js - About 2 hrs to fix

          Function Group has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function Group (groupId, data, itemSet) {
            this.groupId = groupId;
            this.subgroups = {};
            this.subgroupStack = {};
            this.subgroupStackAll = false;
          Severity: Major
          Found in lib/timeline/component/Group.js - About 2 hrs to fix

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

            Group.prototype.orderSubgroups = function() {
              if (this.subgroupOrderer !== undefined) {
                var sortArray = [];
                var subgroup;
                if (typeof this.subgroupOrderer == 'string') {
            Severity: Minor
            Found in lib/timeline/component/Group.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 redraw has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Group.prototype.redraw = function(range, margin, forceRestack, returnQueue) {
              var resized = false;
              var lastIsVisible = this.isVisible;
              var height;
            
            
            Severity: Minor
            Found in lib/timeline/component/Group.js - About 1 hr to fix

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

              function Group (groupId, data, itemSet) {
                this.groupId = groupId;
                this.subgroups = {};
                this.subgroupStack = {};
                this.subgroupStackAll = false;
              Severity: Minor
              Found in lib/timeline/component/Group.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 _removeFromSubgroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              Group.prototype._removeFromSubgroup = function(item, subgroupId) {
                subgroupId = subgroupId || item.data.subgroup;
                if (subgroupId != undefined) {
                  var subgroup = this.subgroups[subgroupId];
                  if (subgroup){
              Severity: Minor
              Found in lib/timeline/component/Group.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 _traceVisible has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Group.prototype._traceVisible = function (initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
                if (initialPos != -1) {
                  var i, item;
                  for (i = initialPos; i >= 0; i--) {
                    item = items[i];
              Severity: Minor
              Found in lib/timeline/component/Group.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                          for(subgroup in this.subgroups) {            
                            visibleSubgroups[subgroup] = this.subgroups[subgroup].items;
                          }
                Severity: Major
                Found in lib/timeline/component/Group.js - About 45 mins to fix

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

                  Group.prototype._traceVisible = function (initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
                  Severity: Minor
                  Found in lib/timeline/component/Group.js - About 35 mins to fix

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

                    Group.prototype._updateItemsVerticalPosition = function(margin) {
                      for (var i = 0, ii = this.visibleItems.length; i < ii; i++) {
                        var item = this.visibleItems[i];
                        item.repositionY(margin);
                        if (!this.isVisible && this.groupId != "__background__") {
                    Severity: Minor
                    Found in lib/timeline/component/Group.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 _didMarkerHeightChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Group.prototype._didMarkerHeightChange = function() {
                      var markerHeight = this.dom.marker.clientHeight;
                      if (markerHeight != this.lastMarkerHeight) {
                        this.lastMarkerHeight = markerHeight;
                        var redrawQueue = {};
                    Severity: Minor
                    Found in lib/timeline/component/Group.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 _addToSubgroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Group.prototype._addToSubgroup = function(item, subgroupId) {
                      subgroupId = subgroupId || item.data.subgroup;
                      if (subgroupId != undefined && this.subgroups[subgroupId] === undefined) {
                        this.subgroups[subgroupId] = {
                          height:0,
                    Severity: Minor
                    Found in lib/timeline/component/Group.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 _checkIfVisibleWithReference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Group.prototype._checkIfVisibleWithReference = function(item, visibleItems, visibleItemsLookup, range) {
                      if (item.isVisible(range)) {
                        if (visibleItemsLookup[item.id] === undefined) {
                          visibleItemsLookup[item.id] = true;
                          visibleItems.push(item);
                    Severity: Minor
                    Found in lib/timeline/component/Group.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 _checkIfVisible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Group.prototype._checkIfVisible = function(item, visibleItems, range) {
                        if (item.isVisible(range)) {
                          if (!item.displayed) item.show();
                          // reposition item horizontally
                          item.repositionX();
                    Severity: Minor
                    Found in lib/timeline/component/Group.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

                        var range = this.itemSet.body.range; // TODO: not nice accessing the range like this
                    Severity: Minor
                    Found in lib/timeline/component/Group.js by fixme

                    TODO found
                    Open

                              // TODO: ugly way to access options...
                    Severity: Minor
                    Found in lib/timeline/component/Group.js by fixme

                    There are no issues that match your filters.

                    Category
                    Status