concord-consortium/rigse

View on GitHub
rails/app/assets/javascripts/flotr/flotr.js

Summary

Maintainability
F
9 mos
Test Coverage

File flotr.js has 2424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* $Id$ */
/** 
 * @projectDescription Flotr is a javascript plotting library based on the Prototype Javascript Framework.
 * @author Bas Wenneker
 * @license MIT License <http://www.opensource.org/licenses/mit-license.php>
Severity: Major
Found in rails/app/assets/javascripts/flotr/flotr.js - About 6 days to fix

    Function drawLabels has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
    Open

        drawLabels: function(){        
            // Construct fixed width label boxes, which can be styled easily. 
            var noLabels = 0, axis,
                xBoxWidth, i, html, tick,
                options = this.options,
    Severity: Minor
    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day 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 insertLegend has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
    Open

        insertLegend: function(){
            if(!this.options.legend.show)
                return;
                
            var series = this.series,
    Severity: Minor
    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day 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 hit has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        hit: function(mouse){
            var series = this.series,
                options = this.options,
                prevHit = this.prevHit,
                plotOffset = this.plotOffset,
    Severity: Minor
    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day 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

    Graph has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Flotr.Graph = Class.create({
        /**
         * Flotr Graph constructor.
         * @param {Element} el - element to insert the graph into
         * @param {Object} data - an array or object of dataseries
    Severity: Major
    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day to fix

      Function setOptions has 204 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setOptions: function(opts){
              var options = {
                  colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.
                  title: null,
                  subtitle: null,
      Severity: Major
      Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day to fix

        Function extendXRangeIfNeededByBar has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
        Open

            extendXRangeIfNeededByBar: function(axis){
                if(axis.options.max == null){
                    var newmin = axis.min,
                        newmax = axis.max,
                        i, s, b, c,
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 day 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 plotBars has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

            plotBars: function(series, barWidth, offset, fill){
                var data = series.data;
                if(data.length < 1) return;
                
                var xa = series.xaxis,
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr.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 plotLine has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

            plotLine: function(series, offset){
                var ctx = this.ctx,
                    xa = series.xaxis,
                    ya = series.yaxis,
                      tHoz = this.tHoz.bind(this),
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr.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 plotLineArea has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

            plotLineArea: function(series, offset){
                var data = series.data;
                if(data.length < 2) return;
        
                var top, lastX = 0,
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr.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 findDataRanges has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

            findDataRanges: function(){
                var s = this.series, 
                    a = this.axes;
                
                a.x.datamin  = a.x.datamax = 
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr.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 drawLabels has 139 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            drawLabels: function(){        
                // Construct fixed width label boxes, which can be styled easily. 
                var noLabels = 0, axis,
                    xBoxWidth, i, html, tick,
                    options = this.options,
        Severity: Major
        Found in rails/app/assets/javascripts/flotr/flotr.js - About 5 hrs to fix

          Function extendYRangeIfNeededByBar has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

              extendYRangeIfNeededByBar: function(axis){
                  if(axis.options.max == null){
                      var newmax = axis.max,
                            i, s, b, c,
                            stackedSums = {},
          Severity: Minor
          Found in rails/app/assets/javascripts/flotr/flotr.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 setOptions has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              setOptions: function(opts){
                  var options = {
                      colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.
                      title: null,
                      subtitle: null,
          Severity: Minor
          Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 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 constructDataGrid has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              constructDataGrid: function(){
                  // If the data grid has already been built, nothing to do here
                  if (this.datagrid) return this.datagrid;
                  
                  var i, j, 
          Severity: Minor
          Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 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 drawSeriesPie has 109 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              drawSeriesPie: function(series) {
                  if (this.options.pie.drawn) return;
                  
                  var ctx = this.ctx,
                      options = this.options,
          Severity: Major
          Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 hrs to fix

            Function insertLegend has 109 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                insertLegend: function(){
                    if(!this.options.legend.show)
                        return;
                        
                    var series = this.series,
            Severity: Major
            Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 hrs to fix

              Function hit has 104 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  hit: function(mouse){
                      var series = this.series,
                          options = this.options,
                          prevHit = this.prevHit,
                          plotOffset = this.plotOffset,
              Severity: Major
              Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 hrs to fix

                Function plotBarsShadows has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    plotBarsShadows: function(series, barWidth, offset){
                        var data = series.data;
                        if(data.length < 1) return;
                        
                        var xa = series.xaxis,
                Severity: Minor
                Found in rails/app/assets/javascripts/flotr/flotr.js - About 4 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 drawTitles has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                    drawTitles: function(){
                        var html,
                            options = this.options,
                            margin = options.grid.labelMargin,
                            ctx = this.ctx,
                Severity: Minor
                Found in rails/app/assets/javascripts/flotr/flotr.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 drawTitles has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    drawTitles: function(){
                        var html,
                            options = this.options,
                            margin = options.grid.labelMargin,
                            ctx = this.ctx,
                Severity: Major
                Found in rails/app/assets/javascripts/flotr/flotr.js - About 3 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (!options.HtmlText && this.textEnabled) {
                              var style = {
                                  size: options.fontSize,
                                  adjustAlign: true
                              };
                  Severity: Critical
                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 3 hrs to fix

                    Function plotLineArea has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        plotLineArea: function(series, offset){
                            var data = series.data;
                            if(data.length < 2) return;
                    
                            var top, lastX = 0,
                    Severity: Major
                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 3 hrs to fix

                      Function calculateTicks has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                          calculateTicks: function(axis){
                              var o = axis.options, i, v;
                              
                              axis.ticks = [];    
                              if(o.ticks){
                      Severity: Minor
                      Found in rails/app/assets/javascripts/flotr/flotr.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 drawGrid has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          drawGrid: function(){
                              var v, o = this.options,
                                  ctx = this.ctx;
                              if(o.grid.verticalLines || o.grid.horizontalLines){
                                  this.el.fire('flotr:beforegrid', [this.axes.x, this.axes.y, o, this]);
                      Severity: Minor
                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 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 plotLine has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          plotLine: function(series, offset){
                              var ctx = this.ctx,
                                  xa = series.xaxis,
                                  ya = series.yaxis,
                                    tHoz = this.tHoz.bind(this),
                      Severity: Major
                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 hrs to fix

                        Function plotBars has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            plotBars: function(series, barWidth, offset, fill){
                                var data = series.data;
                                if(data.length < 1) return;
                                
                                var xa = series.xaxis,
                        Severity: Major
                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 hrs to fix

                          Function plotCandles has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              plotCandles: function(series, offset){
                                  var data = series.data;
                                  if(data.length < 1) return;
                                  
                                  var xa = series.xaxis,
                          Severity: Major
                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 hrs to fix

                            Function constructDataGrid has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                constructDataGrid: function(){
                                    // If the data grid has already been built, nothing to do here
                                    if (this.datagrid) return this.datagrid;
                                    
                                    var i, j, 
                            Severity: Major
                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 hrs to fix

                              Function calculateRange has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  calculateRange: function(axis){
                                      var o = axis.options,
                                          min = o.min != null ? o.min : axis.datamin,
                                          max = o.max != null ? o.max : axis.datamax,
                                          margin;
                              Severity: Minor
                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 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 plotCandles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  plotCandles: function(series, offset){
                                      var data = series.data;
                                      if(data.length < 1) return;
                                      
                                      var xa = series.xaxis,
                              Severity: Minor
                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 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 calculateSpacing has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  calculateSpacing: function(){
                                      var a = this.axes,
                                            options = this.options,
                                            series = this.series,
                                            margin = options.grid.labelMargin,
                              Severity: Major
                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 2 hrs to fix

                                Function generator has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    generator: function(axis) {
                                        var ticks = [],
                                            tickSize = axis.tickSize[0], unit = axis.tickSize[1],
                                            d = new Date(axis.min),
                                            step = tickSize * timeUnitSize[unit];
                                Severity: Minor
                                Found in rails/app/assets/javascripts/flotr/flotr.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 findDataRanges has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    findDataRanges: function(){
                                        var s = this.series, 
                                            a = this.axes;
                                        
                                        a.x.datamin  = a.x.datamax = 
                                Severity: Minor
                                Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                  Function drawGrid has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      drawGrid: function(){
                                          var v, o = this.options,
                                              ctx = this.ctx;
                                          if(o.grid.verticalLines || o.grid.horizontalLines){
                                              this.el.fire('flotr:beforegrid', [this.axes.x, this.axes.y, o, this]);
                                  Severity: Minor
                                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                        generator: function(axis) {
                                            var ticks = [],
                                                tickSize = axis.tickSize[0], unit = axis.tickSize[1],
                                                d = new Date(axis.min),
                                                step = tickSize * timeUnitSize[unit];
                                    Severity: Minor
                                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                      Function drawHit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          drawHit: function(n){
                                              var octx = this.octx,
                                                  s = n.series,
                                                  tHoz = this.tHoz.bind(this),
                                                  tVert = this.tVert.bind(this);
                                      Severity: Minor
                                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                            format: function(d, format) {
                                                if (!d) return;
                                        
                                                var leftPad = function(n) {
                                                    n = n.toString();
                                        Severity: Minor
                                        Found in rails/app/assets/javascripts/flotr/flotr.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 extendXRangeIfNeededByBar has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            extendXRangeIfNeededByBar: function(axis){
                                                if(axis.options.max == null){
                                                    var newmin = axis.min,
                                                        newmax = axis.max,
                                                        i, s, b, c,
                                        Severity: Minor
                                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                          Function plotBarsShadows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              plotBarsShadows: function(series, barWidth, offset){
                                                  var data = series.data;
                                                  if(data.length < 1) return;
                                                  
                                                  var xa = series.xaxis,
                                          Severity: Minor
                                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                                calculateSpacing: function(){
                                                    var a = this.axes,
                                                          options = this.options,
                                                          series = this.series,
                                                          margin = options.grid.labelMargin,
                                            Severity: Minor
                                            Found in rails/app/assets/javascripts/flotr/flotr.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 drawCrosshair has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                drawCrosshair: function(pos) {
                                                    var octx = this.octx,
                                                        options = this.options,
                                                        plotOffset = this.plotOffset,
                                                        x = plotOffset.left+pos.relX+0.5,
                                            Severity: Minor
                                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                              Consider simplifying this complex logical expression.
                                              Open

                                                      if(event.pageX == null && event.clientX != null){
                                                          var de = document.documentElement, b = document.body;
                                                          ax = event.clientX + (de && de.scrollLeft || b.scrollLeft || 0);
                                                          ay = event.clientY + (de && de.scrollTop || b.scrollTop || 0);
                                                      }else{
                                              Severity: Critical
                                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                Function constructCanvas has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    constructCanvas: function(){
                                                        var el = this.el,
                                                            size, c, oc;
                                                        
                                                        // The old canvases are retrieved to avoid memory leaks ...
                                                Severity: Minor
                                                Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                  Function calculateTicks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      calculateTicks: function(axis){
                                                          var o = axis.options, i, v;
                                                          
                                                          axis.ticks = [];    
                                                          if(o.ticks){
                                                  Severity: Minor
                                                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                    Function format has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        format: function(d, format) {
                                                            if (!d) return;
                                                    
                                                            var leftPad = function(n) {
                                                                n = n.toString();
                                                    Severity: Minor
                                                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                      Function extendYRangeIfNeededByBar has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                          extendYRangeIfNeededByBar: function(axis){
                                                              if(axis.options.max == null){
                                                                  var newmax = axis.max,
                                                                        i, s, b, c,
                                                                        stackedSums = {},
                                                      Severity: Minor
                                                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                        Function calculateRange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                        Open

                                                            calculateRange: function(axis){
                                                                var o = axis.options,
                                                                    min = o.min != null ? o.min : axis.datamin,
                                                                    max = o.max != null ? o.max : axis.datamax,
                                                                    margin;
                                                        Severity: Minor
                                                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                                              drawSeriesLines: function(series){
                                                                  series = series || this.series;
                                                                  var ctx = this.ctx;
                                                                  ctx.save();
                                                                  ctx.translate(this.plotOffset.left, this.plotOffset.top);
                                                          Severity: Minor
                                                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                                                drawSelection: function() {
                                                                    var prevSelection = this.prevSelection,
                                                                        selection = this.selection,
                                                                        octx = this.octx,
                                                                        options = this.options,
                                                            Severity: Minor
                                                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

                                                              Consider simplifying this complex logical expression.
                                                              Open

                                                                              if(((!s.bars.show) && xdiff < xsens && ydiff < ysens) || 
                                                                                  (s.bars.show && xdiff < s.bars.barWidth/2 && my > ya.min && my < y)){
                                                                                  var distance = Math.sqrt(xdiff*xdiff + ydiff*ydiff);
                                                                                  if(distance < n.dist){
                                                                                      n.dist = distance;
                                                              Severity: Major
                                                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

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

                                                                    formatter: function (v, axis) {
                                                                        var d = new Date(v);
                                                                
                                                                        // first check global format
                                                                        if (axis.options.timeformat != null)
                                                                Severity: Minor
                                                                Found in rails/app/assets/javascripts/flotr/flotr.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 convertToBytes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    convertToBytes: function(value, precision, base){
                                                                        var sizes =         ['Y','Z','E','P','T','G','M','k',''],
                                                                            fractionSizes = ['y','z','a','f','p','n','µ','m',''], 
                                                                                total = sizes.length;
                                                                            
                                                                Severity: Minor
                                                                Found in rails/app/assets/javascripts/flotr/flotr.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 parseColor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    parseColor: function(str){
                                                                        if (str instanceof Flotr.Color) return str;
                                                                        
                                                                        var result, Color = Flotr.Color;
                                                                
                                                                
                                                                Severity: Minor
                                                                Found in rails/app/assets/javascripts/flotr/flotr.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 downloadCSV has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    downloadCSV: function(){
                                                                        var i, csv = '"x"',
                                                                            series = this.series,
                                                                            dg = this.loadDataGrid();
                                                                        
                                                                Severity: Minor
                                                                Found in rails/app/assets/javascripts/flotr/flotr.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 plotSlice has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                                Open

                                                                    plotSlice: function(x, y, radius, startAngle, endAngle, fill, vScale) {
                                                                Severity: Major
                                                                Found in rails/app/assets/javascripts/flotr/flotr.js - About 50 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                                            for(j = 1; j < data[h].length; j++){
                                                                                                y = data[h][j];
                                                                                                 if(y < yaxis.datamin) yaxis.datamin = y;
                                                                                              else if(y > yaxis.datamax) yaxis.datamax = y;
                                                                                            }
                                                                  Severity: Major
                                                                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                                            if (!b.horizontal && (b.barWidth + axis.datamax > newmax))
                                                                                                newmax = axis.max + (b.centered ? b.barWidth/2 : b.barWidth);
                                                                    Severity: Major
                                                                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                      Function drawHit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                          drawHit: function(n){
                                                                              var octx = this.octx,
                                                                                  s = n.series,
                                                                                  tHoz = this.tHoz.bind(this),
                                                                                  tVert = this.tVert.bind(this);
                                                                      Severity: Minor
                                                                      Found in rails/app/assets/javascripts/flotr/flotr.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 plotCandlesShadows has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                          plotCandlesShadows: function(series, offset){
                                                                              var data = series.data;
                                                                              if(data.length < 1 || series.candles.barcharts) return;
                                                                              
                                                                              var xa = series.xaxis,
                                                                      Severity: Minor
                                                                      Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                          if (!tick.label || tick.label.length == 0 ||
                                                                                                   (this.plotOffset.top + this.tVert(tick.v, axis) < 0) || 
                                                                                                   (this.plotOffset.top + this.tVert(tick.v, axis) > this.canvasHeight)) continue;
                                                                      Severity: Major
                                                                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                        Function drawSeriesPie has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                            drawSeriesPie: function(series) {
                                                                                if (this.options.pie.drawn) return;
                                                                                
                                                                                var ctx = this.ctx,
                                                                                    options = this.options,
                                                                        Severity: Minor
                                                                        Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                        Avoid deeply nested control flow statements.
                                                                        Open

                                                                                                for (j = 0; j < s.data.length; j++) {
                                                                                                    if (s.bars.show && s.bars.stacked) {
                                                                                                        var x = s.data[j][0]+'';
                                                                                                        stackedSums[x] = (stackedSums[x] || 0) + s.data[j][1];
                                                                                                        lastSerie = s;
                                                                        Severity: Major
                                                                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                          Function setSelectionPos has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                                          Open

                                                                              setSelectionPos: function(pos, event) {
                                                                                  var options = this.options,
                                                                                      offset = $(this.overlay).cumulativeOffset();
                                                                                  
                                                                                  if(options.selection.mode.indexOf('x') == -1){
                                                                          Severity: Minor
                                                                          Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                          Avoid deeply nested control flow statements.
                                                                          Open

                                                                                              if(!tick.label || tick.label.length == 0 || 
                                                                                                  (this.plotOffset.left + this.tHoz(tick.v, axis) < 0) || 
                                                                                                  (this.plotOffset.left + this.tHoz(tick.v, axis) > this.canvasWidth)) continue;
                                                                          Severity: Major
                                                                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                            Avoid deeply nested control flow statements.
                                                                            Open

                                                                                                           if(p.charAt(0) == 'n') pos += 'top:' + (m + plotOffset.top) + 'px;';
                                                                                                      else if(p.charAt(0) == 's') pos += 'bottom:' + (m + plotOffset.bottom) + 'px;';                    
                                                                            Severity: Major
                                                                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                              Avoid deeply nested control flow statements.
                                                                              Open

                                                                                                      if (tick) label = tick[1];
                                                                              Severity: Major
                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                Avoid deeply nested control flow statements.
                                                                                Open

                                                                                                           if(x < xaxis.datamin) xaxis.datamin = x;
                                                                                                           else if(x > xaxis.datamax) xaxis.datamax = x;
                                                                                Severity: Major
                                                                                Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                  Avoid deeply nested control flow statements.
                                                                                  Open

                                                                                                          for (var j in stackedSums) {
                                                                                                              newmax = Math.max(stackedSums[j], newmax);
                                                                                                          }
                                                                                  Severity: Major
                                                                                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                    Avoid deeply nested control flow statements.
                                                                                    Open

                                                                                                              if(options.legend.backgroundOpacity != 0.0){
                                                                                                                  /**
                                                                                                                   * Put in the transparent background separately to avoid blended labels and
                                                                                                                   * label boxes.
                                                                                                                   */
                                                                                    Severity: Major
                                                                                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                      Avoid deeply nested control flow statements.
                                                                                      Open

                                                                                                              if(b.stacked && b.horizontal){
                                                                                                                  for (j = 0; j < s.data.length; j++) {
                                                                                                                      if (b.show && b.stacked) {
                                                                                                                          var x = s.data[j][0]+'';
                                                                                                                          stackedSums[x] = (stackedSums[x] || 0) + s.data[j][1];
                                                                                      Severity: Major
                                                                                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                        Avoid deeply nested control flow statements.
                                                                                        Open

                                                                                                            if(!tick.label || tick.label.length == 0 || 
                                                                                                                (this.plotOffset.left + this.tHoz(tick.v, axis) < 0) || 
                                                                                                                (this.plotOffset.left + this.tHoz(tick.v, axis) > this.canvasWidth)) continue;
                                                                                        Severity: Major
                                                                                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                          Avoid deeply nested control flow statements.
                                                                                          Open

                                                                                                              if (!tick.label || tick.label.length == 0 ||
                                                                                                                       (this.plotOffset.top + this.tVert(tick.v, axis) < 0) || 
                                                                                                                       (this.plotOffset.top + this.tVert(tick.v, axis) > this.canvasHeight)) continue;
                                                                                          Severity: Major
                                                                                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                            Avoid deeply nested control flow statements.
                                                                                            Open

                                                                                                                           if(p.charAt(1) == 'e') pos += 'right:' + (m + plotOffset.right) + 'px;';
                                                                                                                      else if(p.charAt(1) == 'w') pos += 'left:' + (m + plotOffset.left) + 'px;';
                                                                                            Severity: Major
                                                                                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 45 mins to fix

                                                                                              Consider simplifying this complex logical expression.
                                                                                              Open

                                                                                                          if (!options.HtmlText && this.textEnabled) {
                                                                                                              var style = {
                                                                                                                  size: options.fontSize*1.1,
                                                                                                                  color: options.grid.color
                                                                                                              };
                                                                                              Severity: Major
                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js - About 40 mins to fix

                                                                                                Consider simplifying this complex logical expression.
                                                                                                Open

                                                                                                        if(n.series && (n.mouse && n.mouse.track && !prevHit || (prevHit /*&& (n.x != prevHit.x || n.y != prevHit.y)*/))){
                                                                                                            var mt = this.mouseTrack || this.el.select(".flotr-mouse-value")[0],
                                                                                                                pos = '', 
                                                                                                                s = n.series,
                                                                                                                p = n.mouse.position, 
                                                                                                Severity: Major
                                                                                                Found in rails/app/assets/javascripts/flotr/flotr.js - About 40 mins to fix

                                                                                                  Consider simplifying this complex logical expression.
                                                                                                  Open

                                                                                                                  if ((doc = node.ownerDocument) && (win = doc.defaultView) && 
                                                                                                                      win.getSelection && doc.createRange && 
                                                                                                                      (selection = window.getSelection()) && 
                                                                                                                      selection.removeAllRanges) {
                                                                                                                          range = doc.createRange();
                                                                                                  Severity: Major
                                                                                                  Found in rails/app/assets/javascripts/flotr/flotr.js - About 40 mins to fix

                                                                                                    Function drawSeriesLines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                    Open

                                                                                                        drawSeriesLines: function(series){
                                                                                                            series = series || this.series;
                                                                                                            var ctx = this.ctx;
                                                                                                            ctx.save();
                                                                                                            ctx.translate(this.plotOffset.left, this.plotOffset.top);
                                                                                                    Severity: Minor
                                                                                                    Found in rails/app/assets/javascripts/flotr/flotr.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 getSeries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                    Open

                                                                                                        getSeries: function(data){
                                                                                                            return data.collect(function(serie){
                                                                                                                var i;
                                                                                                                serie = (serie.data) ? Object.clone(serie) : {'data': serie};
                                                                                                                for (i = serie.data.length-1; i > -1; --i) {
                                                                                                    Severity: Minor
                                                                                                    Found in rails/app/assets/javascripts/flotr/flotr.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 merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                    Open

                                                                                                        merge: function(src, dest){
                                                                                                            var result = dest || {};
                                                                                                            for(var i in src){
                                                                                                                result[i] = (src[i] != null && typeof(src[i]) == 'object' && !(src[i].constructor == Array || src[i].constructor == RegExp) && !Object.isElement(src[i])) ? Flotr.merge(src[i], dest[i]) : result[i] = src[i];        
                                                                                                            }
                                                                                                    Severity: Minor
                                                                                                    Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                                                    Avoid too many return statements within this function.
                                                                                                    Open

                                                                                                                return new Color(parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16));
                                                                                                    Severity: Major
                                                                                                    Found in rails/app/assets/javascripts/flotr/flotr.js - About 30 mins to fix

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

                                                                                                                  return new Color(parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16));
                                                                                                      Severity: Major
                                                                                                      Found in rails/app/assets/javascripts/flotr/flotr.js - About 30 mins to fix

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                                    return new Color(255, 255, 255, 0);
                                                                                                        Severity: Major
                                                                                                        Found in rails/app/assets/javascripts/flotr/flotr.js - About 30 mins to fix

                                                                                                          Avoid too many return statements within this function.
                                                                                                          Open

                                                                                                                  return ((result = Color.lookupColors[name])) ? new Color(result[0], result[1], result[2]) : false;
                                                                                                          Severity: Major
                                                                                                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 30 mins to fix

                                                                                                            Avoid too many return statements within this function.
                                                                                                            Open

                                                                                                                        return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));
                                                                                                            Severity: Major
                                                                                                            Found in rails/app/assets/javascripts/flotr/flotr.js - About 30 mins to fix

                                                                                                              Function getTickSize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  getTickSize: function(noTicks, min, max, decimals){
                                                                                                                      var delta = (max - min) / noTicks;    
                                                                                                                      var magn = Flotr.getMagnitude(delta);
                                                                                                                      
                                                                                                                      // Norm is between 1.0 and 10.0.
                                                                                                              Severity: Minor
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                                                              Function getEventPosition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  getEventPosition: function (event){
                                                                                                                      var offset = this.overlay.cumulativeOffset(),
                                                                                                                          rx = (event.pageX - offset.left - this.plotOffset.left),
                                                                                                                          ry = (event.pageY - offset.top - this.plotOffset.top),
                                                                                                                          ax = 0, ay = 0;
                                                                                                              Severity: Minor
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                                                              Function drawSeries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  drawSeries: function(series){
                                                                                                                      series = series || this.series;
                                                                                                                      
                                                                                                                      var drawn = false;
                                                                                                                      for(var type in Flotr._registeredTypes){
                                                                                                              Severity: Minor
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                                                              Function draw has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  draw: function() {
                                                                                                                      this.drawGrid();
                                                                                                                      this.drawLabels();
                                                                                                                      this.drawTitles();
                                                                                                                  
                                                                                                              Severity: Minor
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.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

                                                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                              Open

                                                                                                              Flotr.Graph = Class.create({
                                                                                                                  /**
                                                                                                                   * Flotr Graph constructor.
                                                                                                                   * @param {Element} el - element to insert the graph into
                                                                                                                   * @param {Object} data - an array or object of dataseries
                                                                                                              Severity: Major
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js and 1 other location - About 7 mos to fix
                                                                                                              rails/app/assets/javascripts/flotr/flotr_out.js on lines 225..3028

                                                                                                              Duplicated Code

                                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                              Tuning

                                                                                                              This issue has a mass of 33815.

                                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                              Refactorings

                                                                                                              Further Reading

                                                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                              Open

                                                                                                              var Flotr = {
                                                                                                                  version: '%version%',
                                                                                                                  author: 'Bas Wenneker',
                                                                                                                  website: 'http://www.solutoire.com',
                                                                                                                  /**
                                                                                                              Severity: Major
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js and 1 other location - About 1 wk to fix
                                                                                                              rails/app/assets/javascripts/flotr/flotr_out.js on lines 9..221

                                                                                                              Duplicated Code

                                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                              Tuning

                                                                                                              This issue has a mass of 1630.

                                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                              Refactorings

                                                                                                              Further Reading

                                                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                              Open

                                                                                                              Flotr.Date = {
                                                                                                                  format: function(d, format) {
                                                                                                                      if (!d) return;
                                                                                                              
                                                                                                                      var leftPad = function(n) {
                                                                                                              Severity: Major
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js and 1 other location - About 1 wk to fix
                                                                                                              rails/app/assets/javascripts/flotr/flotr_out.js on lines 3137..3267

                                                                                                              Duplicated Code

                                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                              Tuning

                                                                                                              This issue has a mass of 1610.

                                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                              Refactorings

                                                                                                              Further Reading

                                                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                              Open

                                                                                                              Flotr.Color = Class.create({
                                                                                                                  initialize: function(r, g, b, a){
                                                                                                                      this.rgba = ['r','g','b','a'];
                                                                                                                      var x = 4;
                                                                                                                      while(-1<--x){
                                                                                                              Severity: Major
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js and 1 other location - About 4 days to fix
                                                                                                              rails/app/assets/javascripts/flotr/flotr_out.js on lines 3030..3088

                                                                                                              Duplicated Code

                                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                              Tuning

                                                                                                              This issue has a mass of 677.

                                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                              Refactorings

                                                                                                              Further Reading

                                                                                                              Identical blocks of code found in 2 locations. Consider refactoring.
                                                                                                              Open

                                                                                                              Flotr.Color.lookupColors = {
                                                                                                                  aqua:[0,255,255],
                                                                                                                  azure:[240,255,255],
                                                                                                                  beige:[245,245,220],
                                                                                                                  black:[0,0,0],
                                                                                                              Severity: Major
                                                                                                              Found in rails/app/assets/javascripts/flotr/flotr.js and 1 other location - About 2 days to fix
                                                                                                              rails/app/assets/javascripts/flotr/flotr_out.js on lines 3090..3134

                                                                                                              Duplicated Code

                                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                              Tuning

                                                                                                              This issue has a mass of 405.

                                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                              Refactorings

                                                                                                              Further Reading

                                                                                                              There are no issues that match your filters.

                                                                                                              Category
                                                                                                              Status