File ManipulationSystem.js
has 783 lines of code (exceeds 250 allowed). Consider refactoring. Open
let util = require('../../util');
let Hammer = require('../../module/hammer');
let hammerUtil = require('../../hammerUtil');
ManipulationSystem
has 45 functions (exceeds 20 allowed). Consider refactoring. Open
class ManipulationSystem {
/**
* @param {Object} body
* @param {Canvas} canvas
* @param {SelectionHandler} selectionHandler
Function showManipulatorToolbar
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
showManipulatorToolbar() {
// restore the state of any bound functions or events, remove control nodes, restore physics
this._clean();
// reset global variables
- 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 showManipulatorToolbar
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
showManipulatorToolbar() {
// restore the state of any bound functions or events, remove control nodes, restore physics
this._clean();
// reset global variables
Function deleteSelected
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
deleteSelected() {
// when using the gui, enable edit mode if it wasnt already.
if (this.editMode !== true) {
this.enableEditMode();
}
- 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 editEdgeMode
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
editEdgeMode() {
// when using the gui, enable edit mode if it wasn't already.
if (this.editMode !== true) {
this.enableEditMode();
}
Function deleteSelected
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
deleteSelected() {
// when using the gui, enable edit mode if it wasnt already.
if (this.editMode !== true) {
this.enableEditMode();
}
Function editNode
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
editNode() {
// when using the gui, enable edit mode if it wasnt already.
if (this.editMode !== true) {
this.enableEditMode();
}
- 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 _controlNodeDragEnd
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_controlNodeDragEnd(event) {
let pointer = this.body.functions.getPointer(event.center);
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
let edge = this.body.edges[this.edgeBeingEditedId];
// if the node that was dragged is not a control node, return
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
setOptions(options, allOptions, globalOptions) {
if (allOptions !== undefined) {
if (allOptions.locale !== undefined) {this.options.locale = allOptions.locale} else {this.options.locale = globalOptions.locale;}
if (allOptions.locales !== undefined) {this.options.locales = allOptions.locales} else {this.options.locales = globalOptions.locales;}
}
- 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 _finishConnect
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_finishConnect(event) {
let pointer = this.body.functions.getPointer(event.center);
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
// remember the edge id
- 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 constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(body, canvas, selectionHandler) {
this.body = body;
this.canvas = canvas;
this.selectionHandler = selectionHandler;
Function editNode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
editNode() {
// when using the gui, enable edit mode if it wasnt already.
if (this.editMode !== true) {
this.enableEditMode();
}
Function _controlNodeDragEnd
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_controlNodeDragEnd(event) {
let pointer = this.body.functions.getPointer(event.center);
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
let edge = this.body.edges[this.edgeBeingEditedId];
// if the node that was dragged is not a control node, return
Function _handleConnect
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleConnect(event) {
// check to avoid double fireing of this function.
if (new Date().valueOf() - this.touchTime > 100) {
this.lastTouch = this.body.functions.getPointer(event.center);
this.lastTouch.translation = util.extend({},this.body.view.translation); // copy the object
Function _performEditEdge
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_performEditEdge(sourceNodeId, targetNodeId) {
let defaultData = {id: this.edgeBeingEditedId, from: sourceNodeId, to: targetNodeId, label: this.body.data.edges._data[this.edgeBeingEditedId].label };
let eeFunct = this.options.editEdge;
if (typeof eeFunct === 'object') {
eeFunct = eeFunct.editWithoutDrag;
Function _createWrappers
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createWrappers() {
// load the manipulator HTML elements. All styling done in css.
if (this.manipulationDiv === undefined) {
this.manipulationDiv = document.createElement('div');
this.manipulationDiv.className = 'vis-manipulation';
Function _finishConnect
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_finishConnect(event) {
let pointer = this.body.functions.getPointer(event.center);
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
// remember the edge id
Function _createWrappers
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_createWrappers() {
// load the manipulator HTML elements. All styling done in css.
if (this.manipulationDiv === undefined) {
this.manipulationDiv = document.createElement('div');
this.manipulationDiv.className = 'vis-manipulation';
- 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 editEdgeMode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
editEdgeMode() {
// when using the gui, enable edit mode if it wasn't already.
if (this.editMode !== true) {
this.enableEditMode();
}
- 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 (needSeperator === true) {
this._createSeperator(4);
}
Avoid deeply nested control flow statements. Open
if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {
this.body.data.nodes.getDataSet().update(finalizedData);
}
Function _handleConnect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_handleConnect(event) {
// check to avoid double fireing of this function.
if (new Date().valueOf() - this.touchTime > 100) {
this.lastTouch = this.body.functions.getPointer(event.center);
this.lastTouch.translation = util.extend({},this.body.view.translation); // copy the object
- 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 _performEditEdge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_performEditEdge(sourceNodeId, targetNodeId) {
let defaultData = {id: this.edgeBeingEditedId, from: sourceNodeId, to: targetNodeId, label: this.body.data.edges._data[this.edgeBeingEditedId].label };
let eeFunct = this.options.editEdge;
if (typeof eeFunct === 'object') {
eeFunct = eeFunct.editWithoutDrag;
- 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 _cleanupTemporaryNodesAndEdges
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_cleanupTemporaryNodesAndEdges() {
// _clean temporary edges
for (let i = 0; i < this.temporaryIds.edges.length; i++) {
this.body.edges[this.temporaryIds.edges[i]].disconnect();
delete this.body.edges[this.temporaryIds.edges[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"