File Network.js
has 363 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Load custom shapes into CanvasRenderingContext2D
require('./shapes');
let Emitter = require('emitter-component');
let util = require('../util');
Function setOptions
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Network.prototype.setOptions = function (options) {
if (options !== undefined) {
let errorFound = Validator.validate(options, allOptions);
if (errorFound === true) {
console.log('%cErrors have been found in the supplied options object.', printStyle);
- 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 Network
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Network(container, data, options) {
if (!(this instanceof Network)) {
throw new SyntaxError('Constructor must be called with the new operator');
}
Function _updateValueRange
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Network.prototype._updateValueRange = function (obj) {
var id;
// determine the range of the objects
var valueMin = undefined;
- 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 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Network.prototype.setOptions = function (options) {
if (options !== undefined) {
let errorFound = Validator.validate(options, allOptions);
if (errorFound === true) {
console.log('%cErrors have been found in the supplied options object.', printStyle);
Function _updateVisibleIndices
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Network.prototype._updateVisibleIndices = function () {
let nodes = this.body.nodes;
let edges = this.body.edges;
this.body.nodeIndices = [];
this.body.edgeIndices = [];
- 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 _updateVisibleIndices
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Network.prototype._updateVisibleIndices = function () {
let nodes = this.body.nodes;
let edges = this.body.edges;
this.body.nodeIndices = [];
this.body.edgeIndices = [];
Function setData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Network.prototype.setData = function (data) {
// reset the physics engine.
this.body.emitter.emit("resetPhysics");
this.body.emitter.emit("_resetData");
Function destroy
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Network.prototype.destroy = function () {
this.body.emitter.emit("destroy");
// clear events
this.body.emitter.off();
this.off();
Function setData
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Network.prototype.setData = function (data) {
// reset the physics engine.
this.body.emitter.emit("resetPhysics");
this.body.emitter.emit("_resetData");
- 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
Consider simplifying this complex logical expression. Open
if (edges.hasOwnProperty(edgeId)) {
let edge = edges[edgeId];
// It can happen that this is executed *after* a node edge has been removed,
// but *before* the edge itself has been removed. Taking this into account.
Function destroy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Network.prototype.destroy = function () {
this.body.emitter.emit("destroy");
// clear events
this.body.emitter.off();
this.off();
- 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"