File InteractionHandler.js
has 434 lines of code (exceeds 250 allowed). Consider refactoring. Open
let util = require('../../util');
var NavigationHandler = require('./components/NavigationHandler').default;
var Popup = require('./../../shared/Popup').default;
Function _checkShowPopup
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
_checkShowPopup(pointer) {
let x = this.canvas._XconvertDOMtoCanvas(pointer.x);
let y = this.canvas._YconvertDOMtoCanvas(pointer.y);
let pointerObj = {
left: x,
- 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 _checkShowPopup
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
_checkShowPopup(pointer) {
let x = this.canvas._XconvertDOMtoCanvas(pointer.x);
let y = this.canvas._YconvertDOMtoCanvas(pointer.y);
let pointerObj = {
left: x,
Function _checkHidePopup
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
_checkHidePopup(pointer) {
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
let stillOnObj = false;
if (this.popup.popupTargetType === 'node') {
- 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
InteractionHandler
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class InteractionHandler {
/**
* @param {Object} body
* @param {Canvas} canvas
* @param {SelectionHandler} selectionHandler
Function zoom
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
zoom(scale, pointer) {
if (this.options.zoomView === true) {
let scaleOld = this.body.view.scale;
if (scale < 0.00001) {
scale = 0.00001;
- 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 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(body, canvas, selectionHandler) {
this.body = body;
this.canvas = canvas;
this.selectionHandler = selectionHandler;
this.navigationHandler = new NavigationHandler(body,canvas);
Function onDragStart
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
onDragStart(event) {
//in case the touch event was triggered on an external div, do the initial touch now.
if (this.drag.pointer === undefined) {
this.onTouch(event);
}
Function onMouseMove
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
onMouseMove(event) {
let pointer = this.getPointer({x:event.clientX, y:event.clientY});
let popupVisible = false;
// check if the previously selected node is still selected
- 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 onDrag
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
onDrag(event) {
if (this.drag.pinched === true) {
return;
}
Function zoom
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
zoom(scale, pointer) {
if (this.options.zoomView === true) {
let scaleOld = this.body.view.scale;
if (scale < 0.00001) {
scale = 0.00001;
Function onDragStart
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
onDragStart(event) {
//in case the touch event was triggered on an external div, do the initial touch now.
if (this.drag.pointer === undefined) {
this.onTouch(event);
}
- 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 checkSelectionChanges
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkSelectionChanges(pointer, event, add = false) {
let previousSelection = this.selectionHandler.getSelection();
let selected = false;
if (add === true) {
selected = this.selectionHandler.selectAdditionalOnPoint(pointer);
Function onMouseMove
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
onMouseMove(event) {
let pointer = this.getPointer({x:event.clientX, y:event.clientY});
let popupVisible = false;
// check if the previously selected node is still selected
Function onMouseWheel
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
onMouseWheel(event) {
if (this.options.zoomView === true) {
// retrieve delta
let delta = 0;
if (event.wheelDelta) { /* IE/Opera. */
- 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 onDrag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
onDrag(event) {
if (this.drag.pinched === true) {
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 checkSelectionChanges
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
checkSelectionChanges(pointer, event, add = false) {
let previousSelection = this.selectionHandler.getSelection();
let selected = false;
if (add === true) {
selected = this.selectionHandler.selectAdditionalOnPoint(pointer);
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
setOptions(options) {
if (options !== undefined) {
// extend all but the values in fields
let fields = ['hideEdgesOnDrag','hideNodesOnDrag','keyboard','multiselect','selectable','selectConnectedEdges'];
util.selectiveNotDeepExtend(fields, this.options, 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
TODO found Open
// TODO: enabled moving while pinching?
- Exclude checks
TODO found Open
* TODO: This is all SelectionHandler calls; the method should be moved to there.
- Exclude checks