lib/network/modules/Canvas.js

Summary

Maintainability
C
1 day
Test Coverage

File Canvas.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

let Hammer = require('../../module/hammer');
let hammerUtil = require('../../hammerUtil');

let util = require('../../util');

Severity: Minor
Found in lib/network/modules/Canvas.js - About 2 hrs to fix

    Canvas has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Canvas {
      /**
       * @param {Object} body
       */
      constructor(body) {
    Severity: Minor
    Found in lib/network/modules/Canvas.js - About 2 hrs to fix

      Function setSize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        setSize(width = this.options.width, height = this.options.height) {
          width = this._prepareValue(width);
          height= this._prepareValue(height);
      
          let emitEvent = false;
      Severity: Minor
      Found in lib/network/modules/Canvas.js - About 1 hr to fix

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

          _setCameraState() {
            if (this.cameraState.scale !== undefined &&
              this.frame.canvas.clientWidth !== 0 &&
              this.frame.canvas.clientHeight !== 0 &&
              this.pixelRatio !== 0 &&
        Severity: Minor
        Found in lib/network/modules/Canvas.js - About 1 hr to fix

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

            _create() {
              // remove all elements from the container element.
              while (this.body.container.hasChildNodes()) {
                this.body.container.removeChild(this.body.container.firstChild);
              }
          Severity: Minor
          Found in lib/network/modules/Canvas.js - About 1 hr to fix

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

              setSize(width = this.options.width, height = this.options.height) {
                width = this._prepareValue(width);
                height= this._prepareValue(height);
            
                let emitEvent = false;
            Severity: Minor
            Found in lib/network/modules/Canvas.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 _setCameraState has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              _setCameraState() {
                if (this.cameraState.scale !== undefined &&
                  this.frame.canvas.clientWidth !== 0 &&
                  this.frame.canvas.clientHeight !== 0 &&
                  this.pixelRatio !== 0 &&
            Severity: Minor
            Found in lib/network/modules/Canvas.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 _prepareValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              _prepareValue(value) {
                if (typeof value === 'number') {
                  return value + 'px';
                }
                else if (typeof value === 'string') {
            Severity: Minor
            Found in lib/network/modules/Canvas.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

                //       there should be a mechanism for reloading the data (TODO: check if this is present).
            Severity: Minor
            Found in lib/network/modules/Canvas.js by fixme

            TODO found
            Open

                // TODO: neatly cleanup these handlers when re-creating the Canvas, IF these are done with hammer, event.stopPropagation will not work?
            Severity: Minor
            Found in lib/network/modules/Canvas.js by fixme

            There are no issues that match your filters.

            Category
            Status