lib/graph3d/Graph3d.js

Summary

Maintainability
F
1 wk
Test Coverage

File Graph3d.js has 1358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Emitter = require('emitter-component');
var util = require('../util');
var Point3d = require('./Point3d');
var Point2d = require('./Point2d');
var Slider = require('./Slider');
Severity: Major
Found in lib/graph3d/Graph3d.js - About 3 days to fix

    Function _getDataPoints has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    Graph3d.prototype._getDataPoints = function (data) {
      // TODO: store the created matrix dataPoints in the filters instead of
      //       reloading each time.
      var x, y, i, obj;
    
    
    Severity: Minor
    Found in lib/graph3d/Graph3d.js - About 6 hrs 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 _redrawAxis has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    Graph3d.prototype._redrawAxis = function() {
      var ctx = this._getContext(),
        from, to, step, prettyStep,
        text, xText, yText, zText,
        offset, xOffset, yOffset;
    Severity: Minor
    Found in lib/graph3d/Graph3d.js - About 5 hrs 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 _redrawAxis has 135 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Graph3d.prototype._redrawAxis = function() {
      var ctx = this._getContext(),
        from, to, step, prettyStep,
        text, xText, yText, zText,
        offset, xOffset, yOffset;
    Severity: Major
    Found in lib/graph3d/Graph3d.js - About 5 hrs to fix

      Function _dataPointFromXY has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      Graph3d.prototype._dataPointFromXY = function (x, y) {
        var i,
          distMax = 100, // px
          dataPoint = null,
          closestDataPoint = null,
      Severity: Minor
      Found in lib/graph3d/Graph3d.js - About 3 hrs 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 _redrawLegend has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Graph3d.prototype._redrawLegend = function() {
      
        //Return without drawing anything, if no legend is specified
        if (this.showLegend !== true) {
          return;
      Severity: Major
      Found in lib/graph3d/Graph3d.js - About 3 hrs to fix

        Function _showTooltip has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Graph3d.prototype._showTooltip = function (dataPoint) {
          var content, line, dot;
        
          if (!this.tooltip) {
            content = document.createElement('div');
        Severity: Major
        Found in lib/graph3d/Graph3d.js - About 2 hrs to fix

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

          Graph3d.prototype._redrawBar = function(ctx, point, xWidth, yWidth, color, borderColor) {
            var surface;
          
            // calculate all corner points
            var me = this;
          Severity: Minor
          Found in lib/graph3d/Graph3d.js - About 1 hr to fix

            Function _onTooltip has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            Graph3d.prototype._onTooltip = function (event) {
              var delay = 300; // ms
              var boundingRect = this.frame.getBoundingClientRect();
              var mouseX = getMouseX(event) - boundingRect.left;
              var mouseY = getMouseY(event) - boundingRect.top;
            Severity: Minor
            Found in lib/graph3d/Graph3d.js - About 1 hr 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 _getDataPoints has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Graph3d.prototype._getDataPoints = function (data) {
              // TODO: store the created matrix dataPoints in the filters instead of
              //       reloading each time.
              var x, y, i, obj;
            
            
            Severity: Minor
            Found in lib/graph3d/Graph3d.js - About 1 hr to fix

              Function _dataPointFromXY has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Graph3d.prototype._dataPointFromXY = function (x, y) {
                var i,
                  distMax = 100, // px
                  dataPoint = null,
                  closestDataPoint = null,
              Severity: Minor
              Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                Function _onMouseMove has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                Graph3d.prototype._onMouseMove = function (event) {
                  this.moving = true;
                  event = event || window.event;
                
                  // calculate change in mouse position
                Severity: Minor
                Found in lib/graph3d/Graph3d.js - About 1 hr 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 _redrawSurfaceGraphPoint has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Graph3d.prototype._redrawSurfaceGraphPoint = function(ctx, point) {
                  var right = point.pointRight;
                  var top   = point.pointTop;
                  var cross = point.pointCross;
                
                
                Severity: Minor
                Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                  Function setPointDrawingMethod has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Graph3d.prototype.setPointDrawingMethod = function() {
                    var method = undefined;
                  
                    switch (this.style) {
                      case Graph3d.STYLE.BAR:
                  Severity: Minor
                  Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                    Function _redrawLegend has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Graph3d.prototype._redrawLegend = function() {
                    
                      //Return without drawing anything, if no legend is specified
                      if (this.showLegend !== true) {
                        return;
                    Severity: Minor
                    Found in lib/graph3d/Graph3d.js - About 1 hr 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 create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Graph3d.prototype.create = function () {
                      // remove all elements from the container element.
                      while (this.containerElement.hasChildNodes()) {
                        this.containerElement.removeChild(this.containerElement.firstChild);
                      }
                    Severity: Minor
                    Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                      Function _onTooltip has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      Graph3d.prototype._onTooltip = function (event) {
                        var delay = 300; // ms
                        var boundingRect = this.frame.getBoundingClientRect();
                        var mouseX = getMouseX(event) - boundingRect.left;
                        var mouseY = getMouseY(event) - boundingRect.top;
                      Severity: Minor
                      Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                        Function _onMouseMove has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        Graph3d.prototype._onMouseMove = function (event) {
                          this.moving = true;
                          event = event || window.event;
                        
                          // calculate change in mouse position
                        Severity: Minor
                        Found in lib/graph3d/Graph3d.js - About 1 hr to fix

                          Function _hideTooltip has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          Graph3d.prototype._hideTooltip = function () {
                            if (this.tooltip) {
                              this.tooltip.dataPoint = null;
                          
                              for (var prop in this.tooltip.dom) {
                          Severity: Minor
                          Found in lib/graph3d/Graph3d.js - About 1 hr 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 _insideTriangle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                          Graph3d.prototype._insideTriangle = function (point, triangle) {
                            var a = triangle[0],
                              b = triangle[1],
                              c = triangle[2];
                          
                          
                          Severity: Minor
                          Found in lib/graph3d/Graph3d.js - About 1 hr 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 _redrawSurfaceGraphPoint has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          Graph3d.prototype._redrawSurfaceGraphPoint = function(ctx, point) {
                            var right = point.pointRight;
                            var top   = point.pointTop;
                            var cross = point.pointCross;
                          
                          
                          Severity: Minor
                          Found in lib/graph3d/Graph3d.js - About 45 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 _redrawBar has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          Graph3d.prototype._redrawBar = function(ctx, point, xWidth, yWidth, color, borderColor) {
                          Severity: Minor
                          Found in lib/graph3d/Graph3d.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if (this._insideTriangle(center, triangle1) ||
                                        this._insideTriangle(center, triangle2)) {
                                        // return immediately at the first hit
                                        return dataPoint;
                                      }
                            Severity: Major
                            Found in lib/graph3d/Graph3d.js - About 45 mins to fix

                              Function drawAxisLabelY has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              Graph3d.prototype.drawAxisLabelY = function(ctx, point3d, text, armAngle, yMargin) {
                              Severity: Minor
                              Found in lib/graph3d/Graph3d.js - About 35 mins to fix

                                Function drawAxisLabelX has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                Graph3d.prototype.drawAxisLabelX = function(ctx, point3d, text, armAngle, yMargin) {
                                Severity: Minor
                                Found in lib/graph3d/Graph3d.js - About 35 mins to fix

                                  Function _drawCircle has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  Graph3d.prototype._drawCircle = function(ctx, point, color, borderColor, size) {
                                  Severity: Minor
                                  Found in lib/graph3d/Graph3d.js - About 35 mins to fix

                                    TODO found
                                    Open

                                          // TODO: implement Array().indexOf() for Internet Explorer
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: can this be automated? verticalRatio?
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                          strokeStyle = this.axisColor; // TODO: should be customizable
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                        return;  // TODO: throw exception?
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      ctx.font = '14px arial'; // TODO: put in options
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: get the actual rendered style of the containerElement
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                        // TODO: this dept calculation doesn't work 100% of the cases due to perspective,
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                          v = Math.min(1 + (crossproduct.x / len) / 2, 1);  // value. TODO: scale
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: customize axis range
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      ctx.stroke(); // TODO: only draw stroke when strokeWidth > 0
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    FIXME found
                                    Open

                                        // FIXME: there is a bug with determining the surface side (shadow or colored)
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                        offset = 30;  // pixels.  // TODO: relate to the max width of the values on the z axis?
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                       || this.style === Graph3d.STYLE.BARSIZE //TODO add legend support for BARSIZE
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: only draw stroke when strokeWidth > 0
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: store the created matrix dataPoints in the filters instead of
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: later on, all min/maxes of all datagroups will be combined here
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                          // TODO: make z-grid lines really 3d?
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: these events are never cleaned up... can give a 'memory leakage'
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      ctx.font = '14px arial'; // TODO: put in options
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    TODO found
                                    Open

                                      // TODO: css here is not nice here...
                                    Severity: Minor
                                    Found in lib/graph3d/Graph3d.js by fixme

                                    There are no issues that match your filters.

                                    Category
                                    Status