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;
- Read upRead up
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');
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;
- Read upRead up
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;
- Read upRead up
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;
- Read upRead up
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;
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]];
- Read upRead up
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;
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 = {
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;
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;
- Read upRead up
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++) {
- Read upRead up
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;
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;
- Read upRead up
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]];
- Read upRead up
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;
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++) {
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
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]);
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;
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]];
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;
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)) {
- Read upRead up
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]);
- Read upRead up
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);
}
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;
Avoid deeply nested control flow statements. Open
if (options.yAxisOrientation === 'left') {
combinedDataLeft = combinedDataLeft.concat(groupData);
}
else {
combinedDataRight = combinedDataRight.concat(groupData);
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;
}
Avoid deeply nested control flow statements. Open
if (this.groups.hasOwnProperty(groupId)) {
this._removeGroup(groupId);
}
Avoid deeply nested control flow statements. Open
if (dataset == null || dataset.length == 0) {
continue;
}
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;
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);
}
Avoid deeply nested control flow statements. Open
if (groupsContent[groupId].length < newLength) {
groupsContent[groupId][newLength - 1] = {};
}
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"){
Avoid deeply nested control flow statements. Open
if (!paths.hasOwnProperty(groupIds[i])) {
paths[groupIds[i]] = Lines.calcPath(dataset, group);
}
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];
}
Avoid deeply nested control flow statements. Open
if (group == undefined) {
group = {id: groupId, content: this.options.defaultGroup + groupId};
}
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
- Read upRead up
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();
- Read upRead up
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;
- Read upRead up
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!
- Exclude checks