lib/timeline/component/LineGraph.js

Summary

Maintainability
F
1 wk
Test Coverage

Function _updateGraph has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
Open

LineGraph.prototype._updateGraph = function () {
  // reset the svg elements
  DOMutil.prepareElements(this.svgElements);
  if (this.props.width != 0 && this.itemsData != null) {
    var group, i;
Severity: Minor
Found in lib/timeline/component/LineGraph.js - About 2 days to fix

Cognitive Complexity

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

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

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

Further reading

File LineGraph.js has 802 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('../../util');
var DOMutil = require('../../DOMutil');
var DataSet = require('../../DataSet');
var DataView = require('../../DataView');
var Component = require('./Component');
Severity: Major
Found in lib/timeline/component/LineGraph.js - About 1 day to fix

    Function _updateAllGroupData has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

    LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
      if (this.itemsData != null) {
        var groupsContent = {};
        var items = this.itemsData.get();
        var fieldId = this.itemsData._fieldId;
    Severity: Minor
    Found in lib/timeline/component/LineGraph.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 _updateYAxis has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

    LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
      var resized = false;
      var yAxisLeftUsed = false;
      var yAxisRightUsed = false;
      var minLeft = 1e9, minRight = 1e9, maxLeft = -1e9, maxRight = -1e9, minVal, maxVal;
    Severity: Minor
    Found in lib/timeline/component/LineGraph.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 setOptions has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    LineGraph.prototype.setOptions = function (options) {
      if (options) {
        var fields = ['sampling', 'defaultGroup', 'stack', 'height', 'graphHeight', 'yAxisOrientation', 'style', 'barChart', 'dataAxis', 'sort', 'groups'];
        if (options.graphHeight === undefined && options.height !== undefined) {
          this.updateSVGheight = true;
    Severity: Minor
    Found in lib/timeline/component/LineGraph.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 _updateGraph has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    LineGraph.prototype._updateGraph = function () {
      // reset the svg elements
      DOMutil.prepareElements(this.svgElements);
      if (this.props.width != 0 && this.itemsData != null) {
        var group, i;
    Severity: Major
    Found in lib/timeline/component/LineGraph.js - About 3 hrs to fix

      Function _getRelevantData has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate, maxDate) {
        var group, i, j, item;
        if (groupIds.length > 0) {
          for (i = 0; i < groupIds.length; i++) {
            group = this.groups[groupIds[i]];
      Severity: Minor
      Found in lib/timeline/component/LineGraph.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 _updateAllGroupData has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
        if (this.itemsData != null) {
          var groupsContent = {};
          var items = this.itemsData.get();
          var fieldId = this.itemsData._fieldId;
      Severity: Major
      Found in lib/timeline/component/LineGraph.js - About 3 hrs to fix

        Function LineGraph has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function LineGraph(body, options) {
          this.id = util.randomUUID();
          this.body = body;
        
          this.defaultOptions = {
        Severity: Major
        Found in lib/timeline/component/LineGraph.js - About 3 hrs to fix

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

          LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
            var resized = false;
            var yAxisLeftUsed = false;
            var yAxisRightUsed = false;
            var minLeft = 1e9, minRight = 1e9, maxLeft = -1e9, maxRight = -1e9, minVal, maxVal;
          Severity: Major
          Found in lib/timeline/component/LineGraph.js - About 3 hrs to fix

            Function _getYRanges has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

            LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) {
              var groupData, group, i;
              var combinedDataLeft = [];
              var combinedDataRight = [];
              var options;
            Severity: Minor
            Found in lib/timeline/component/LineGraph.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 _stack has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            LineGraph.prototype._stack = function (data, subData) {
              var index, dx, dy, subPrevPoint, subNextPoint;
              index = 0;
              // for each data point we look for a matching on in the set below
              for (var j = 0; j < data.length; j++) {
            Severity: Minor
            Found in lib/timeline/component/LineGraph.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 setOptions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            LineGraph.prototype.setOptions = function (options) {
              if (options) {
                var fields = ['sampling', 'defaultGroup', 'stack', 'height', 'graphHeight', 'yAxisOrientation', 'style', 'barChart', 'dataAxis', 'sort', 'groups'];
                if (options.graphHeight === undefined && options.height !== undefined) {
                  this.updateSVGheight = true;
            Severity: Major
            Found in lib/timeline/component/LineGraph.js - About 2 hrs to fix

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

              LineGraph.prototype.redraw = function () {
                var resized = false;
              
                // calculate actual size and position
                this.props.width = this.dom.frame.offsetWidth;
              Severity: Minor
              Found in lib/timeline/component/LineGraph.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 _applySampling has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              LineGraph.prototype._applySampling = function (groupIds, groupsData) {
                var group;
                if (groupIds.length > 0) {
                  for (var i = 0; i < groupIds.length; i++) {
                    group = this.groups[groupIds[i]];
              Severity: Minor
              Found in lib/timeline/component/LineGraph.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 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              LineGraph.prototype.redraw = function () {
                var resized = false;
              
                // calculate actual size and position
                this.props.width = this.dom.frame.offsetWidth;
              Severity: Minor
              Found in lib/timeline/component/LineGraph.js - About 1 hr to fix

                Function _stack has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                LineGraph.prototype._stack = function (data, subData) {
                  var index, dx, dy, subPrevPoint, subNextPoint;
                  index = 0;
                  // for each data point we look for a matching on in the set below
                  for (var j = 0; j < data.length; j++) {
                Severity: Minor
                Found in lib/timeline/component/LineGraph.js - About 1 hr to fix

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

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

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

                    LineGraph.prototype._updateGroup = function (group, groupId) {
                      if (!this.groups.hasOwnProperty(groupId)) {
                        this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles);
                        if (this.groups[groupId].options.yAxisOrientation == 'right') {
                          this.yAxisRight.addGroup(groupId, this.groups[groupId]);
                    Severity: Minor
                    Found in lib/timeline/component/LineGraph.js - About 1 hr to fix

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

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

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

                        LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate, maxDate) {
                          var group, i, j, item;
                          if (groupIds.length > 0) {
                            for (i = 0; i < groupIds.length; i++) {
                              group = this.groups[groupIds[i]];
                        Severity: Minor
                        Found in lib/timeline/component/LineGraph.js - About 1 hr to fix

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

                          LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) {
                            var groupData, group, i;
                            var combinedDataLeft = [];
                            var combinedDataRight = [];
                            var options;
                          Severity: Minor
                          Found in lib/timeline/component/LineGraph.js - About 1 hr to fix

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

                            LineGraph.prototype._getSortedGroupIds = function(){
                              // getting group Ids
                              var grouplist = [];
                              for (var groupId in this.groups) {
                                if (this.groups.hasOwnProperty(groupId)) {
                            Severity: Minor
                            Found in lib/timeline/component/LineGraph.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

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

                            LineGraph.prototype._updateGroup = function (group, groupId) {
                              if (!this.groups.hasOwnProperty(groupId)) {
                                this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles);
                                if (this.groups[groupId].options.yAxisOrientation == 'right') {
                                  this.yAxisRight.addGroup(groupId, this.groups[groupId]);
                            Severity: Minor
                            Found in lib/timeline/component/LineGraph.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 (this.groupsData != undefined) {
                                        group = this.groupsData.get(groupId);
                                      }
                            Severity: Major
                            Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                        if (group.options.shaded.orientation === "group") {
                                          var subGroupId = group.options.shaded.groupId;
                                          if (groupIds.indexOf(subGroupId) === -1) {
                                            console.log(group.id + ": Unknown shading group target given:" + subGroupId);
                                            continue;
                              Severity: Major
                              Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                          if (options.yAxisOrientation === 'left') {
                                            combinedDataLeft = combinedDataLeft.concat(groupData);
                                          }
                                          else {
                                            combinedDataRight = combinedDataRight.concat(groupData);
                                Severity: Major
                                Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                            if (groupRanges[groupIds[i]].yAxisOrientation != 'right') {
                                              yAxisLeftUsed = true;
                                              minLeft = minLeft > minVal ? minVal : minLeft;
                                              maxLeft = maxLeft < maxVal ? maxVal : maxLeft;
                                            }
                                  Severity: Major
                                  Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                              if (this.groups.hasOwnProperty(groupId)) {
                                                this._removeGroup(groupId);
                                              }
                                    Severity: Major
                                    Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                if (dataset == null || dataset.length == 0) {
                                                  continue;
                                                }
                                      Severity: Major
                                      Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                  if (options.interpolation.parametrization == 'uniform') {
                                                    this.options.interpolation.alpha = 0;
                                                  }
                                                  else if (options.interpolation.parametrization == 'chordal') {
                                                    this.options.interpolation.alpha = 1.0;
                                        Severity: Major
                                        Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                    switch (group.options.style) {
                                                      case "line":
                                                        if (!paths.hasOwnProperty(groupIds[i])) {
                                                          paths[groupIds[i]] = Lines.calcPath(groupsData[groupIds[i]], group);
                                                        }
                                          Severity: Major
                                          Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                      if (groupsContent[groupId].length < newLength) {
                                                        groupsContent[groupId][newLength - 1] = {};
                                                      }
                                            Severity: Major
                                            Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                        if (group.options.excludeFromStacking == undefined || !group.options.excludeFromStacking) {
                                                          if (below != undefined) {
                                                            this._stack(groupsData[group.id], groupsData[below.id]);
                                                            if (group.options.shaded.enabled == true && group.options.shaded.orientation !== "group"){
                                                              if (group.options.shaded.orientation == "top" && below.options.shaded.orientation !== "group"){
                                              Severity: Major
                                              Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                          if (!paths.hasOwnProperty(groupIds[i])) {
                                                            paths[groupIds[i]] = Lines.calcPath(dataset, group);
                                                          }
                                                Severity: Major
                                                Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                            for (var j = 0; j < amountOfPoints; j += increment) {
                                                              var idx = Math.round(j/increment);
                                                              sampledData[idx]=dataContainer[j];
                                                            }
                                                  Severity: Major
                                                  Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                              if (group == undefined) {
                                                                group = {id: groupId, content: this.options.defaultGroup + groupId};
                                                              }
                                                    Severity: Major
                                                    Found in lib/timeline/component/LineGraph.js - About 45 mins to fix

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

                                                      LineGraph.prototype.setGroups = function (groups) {
                                                        var me = this;
                                                        var ids;
                                                      
                                                        // unsubscribe from current dataset
                                                      Severity: Minor
                                                      Found in lib/timeline/component/LineGraph.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 _toggleAxisVisiblity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                      LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
                                                        var changed = false;
                                                        if (axisUsed == false) {
                                                          if (axis.dom.frame.parentNode && axis.hidden == false) {
                                                            axis.hide();
                                                      Severity: Minor
                                                      Found in lib/timeline/component/LineGraph.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 setItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                      LineGraph.prototype.setItems = function (items) {
                                                        var me = this,
                                                          ids,
                                                          oldItemsData = this.itemsData;
                                                      
                                                      
                                                      Severity: Minor
                                                      Found in lib/timeline/component/LineGraph.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: This assumes sorted data, but that's not guaranteed!
                                                      Severity: Minor
                                                      Found in lib/timeline/component/LineGraph.js by fixme

                                                      There are no issues that match your filters.

                                                      Category
                                                      Status