FanaHOVA/blazer

View on GitHub
app/assets/javascripts/blazer/chartkick.js

Summary

Maintainability
F
1 wk
Test Coverage

Function loadAdapters has 862 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function loadAdapters() {
    if (!HighchartsAdapter && "Highcharts" in window) {
      HighchartsAdapter = new function () {
        var Highcharts = window.Highcharts;

Severity: Major
Found in app/assets/javascripts/blazer/chartkick.js - About 4 days to fix

    File chartkick.js has 1419 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Chartkick.js
     * Create beautiful charts with one line of JavaScript
     * https://github.com/ankane/chartkick.js
     * v2.2.1
    Severity: Major
    Found in app/assets/javascripts/blazer/chartkick.js - About 3 days to fix

      Function createDataTable has 131 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var createDataTable = function (chart, options, chartType) {
                var datasets = [];
                var labels = [];
      
                var colors = chart.options.colors || defaultColors;
      Severity: Major
      Found in app/assets/javascripts/blazer/chartkick.js - About 5 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if (!GoogleChartsAdapter && window.google && (window.google.setOnLoadCallback || window.google.charts)) {
              GoogleChartsAdapter = new function () {
                var google = window.google;
        
                this.name = "google";
        Severity: Critical
        Found in app/assets/javascripts/blazer/chartkick.js - About 3 hrs to fix

          Function createChart has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function createChart(chartType, chart, element, dataSource, opts, processData) {
              var elementId;
              if (typeof element === "string") {
                elementId = element;
                element = document.getElementById(element);
          Severity: Major
          Found in app/assets/javascripts/blazer/chartkick.js - About 3 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                if (!ChartjsAdapter && "Chart" in window) {
                  ChartjsAdapter = new function () {
                    var Chart = window.Chart;
            
                    this.name = "chartjs";
            Severity: Critical
            Found in app/assets/javascripts/blazer/chartkick.js - About 2 hrs to fix

              Function renderLineChart has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      this.renderLineChart = function (chart, chartType) {
                        chartType = chartType || "spline";
                        var chartOptions = {};
                        if (chartType === "areaspline") {
                          chartOptions = {
              Severity: Minor
              Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                Function createDataTable has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        var createDataTable = function (series, columnType) {
                          var i, j, s, d, key, rows = [], sortedLabels = [];
                          for (i = 0; i < series.length; i++) {
                            s = series[i];
                
                
                Severity: Minor
                Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                    function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {
                      return function (chart, opts, chartOptions) {
                        var series = chart.data;
                        var options = merge({}, defaultOptions);
                        options = merge(options, chartOptions || {});
                  Severity: Minor
                  Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                      function addDownloadButton(chart) {
                        var element = chart.element;
                        var link = document.createElement("a");
                        link.download = chart.options.download === true ? "chart.png" : chart.options.download; // http://caniuse.com/download
                        link.style.position = "absolute";
                    Severity: Minor
                    Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                              this.renderColumnChart = function (chart, chartType) {
                                chartType = chartType || "column";
                                var series = chart.data;
                                var options = jsOptions(chart, chart.options), i, j, s, d, rows = [], categories = [];
                                options.chart.type = chartType;
                      Severity: Minor
                      Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                                this.renderPieChart = function (chart) {
                                  waitForLoaded(function () {
                                    var chartOptions = {
                                      chartArea: {
                                        top: "10%",
                        Severity: Minor
                        Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                            function parseISO8601(input) {
                              var day, hour, matches, milliseconds, minutes, month, offset, result, seconds, type, year;
                              type = Object.prototype.toString.call(input);
                              if (type === "[object Date]") {
                                return input;
                          Severity: Minor
                          Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

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

                                    this.renderPieChart = function (chart) {
                                      var options = merge({}, baseOptions);
                                      if (chart.options.donut) {
                                        options.cutoutPercentage = 50;
                                      }
                            Severity: Minor
                            Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                              Function renderScatterChart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      this.renderScatterChart = function (chart) {
                                        var options = jsOptions(chart, chart.options);
                              
                                        var colors = chart.options.colors || defaultColors;
                              
                              
                              Severity: Minor
                              Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                    if (!HighchartsAdapter && "Highcharts" in window) {
                                      HighchartsAdapter = new function () {
                                        var Highcharts = window.Highcharts;
                                
                                        this.name = "highcharts";
                                Severity: Major
                                Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                                  Function jsOptionsFunc has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                    function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {
                                  Severity: Major
                                  Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                                if (detectType) {
                                                  value = new Date(toFloat(i));
                                                  // TODO make this efficient
                                                  day = day && isDay(value);
                                                  if (!dayOfWeek) {
                                    Severity: Major
                                    Found in app/assets/javascripts/blazer/chartkick.js - About 1 hr to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                      if (week && step === 1) {
                                                        unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
                                                      }
                                      Severity: Major
                                      Found in app/assets/javascripts/blazer/chartkick.js - About 45 mins to fix

                                        Function createChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          function createChart(chartType, chart, element, dataSource, opts, processData) {
                                        Severity: Minor
                                        Found in app/assets/javascripts/blazer/chartkick.js - About 45 mins to fix

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

                                            function allZeros(data) {
                                              var i, j, d;
                                              for (i = 0; i < data.length; i++) {
                                                d = data[i].data;
                                                for (j = 0; j < d.length; j++) {
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 3 hrs to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 95..106

                                          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 105.

                                          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

                                            function negativeValues(series) {
                                              var i, j, data;
                                              for (i = 0; i < series.length; i++) {
                                                data = series[i].data;
                                                for (j = 0; j < data.length; j++) {
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 3 hrs to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1454..1465

                                          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 105.

                                          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 setXtitle = function (options, title) {
                                                    options.scales.xAxes[0].scaleLabel.display = true;
                                                    options.scales.xAxes[0].scaleLabel.labelString = title;
                                                  };
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 1 hr to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1056..1059

                                          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 68.

                                          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 setYtitle = function (options, title) {
                                                    options.scales.yAxes[0].scaleLabel.display = true;
                                                    options.scales.yAxes[0].scaleLabel.labelString = title;
                                                  };
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 1 hr to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1051..1054

                                          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 68.

                                          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 setBarMin = function (options, min) {
                                                    if (min !== null) {
                                                      options.scales.xAxes[0].ticks.min = toFloat(min);
                                                    }
                                                  };
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 1 hr to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1026..1030

                                          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 56.

                                          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 setMin = function (options, min) {
                                                    if (min !== null) {
                                                      options.scales.yAxes[0].ticks.min = toFloat(min);
                                                    }
                                                  };
                                          Severity: Major
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 1 hr to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1036..1040

                                          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 56.

                                          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 setYtitle = function (options, title) {
                                                    options.vAxis.title = title;
                                                    options.vAxis.titleTextStyle.italic = false;
                                                  };
                                          Severity: Minor
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 40 mins to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 726..729

                                          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 48.

                                          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 setXtitle = function (options, title) {
                                                    options.hAxis.title = title;
                                                    options.hAxis.titleTextStyle.italic = false;
                                                  };
                                          Severity: Minor
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 40 mins to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 731..734

                                          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 48.

                                          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

                                              configure: function (options) {
                                                for (var key in options) {
                                                  if (options.hasOwnProperty(key)) {
                                                    config[key] = options[key];
                                                  }
                                          Severity: Minor
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 35 mins to fix
                                          app/assets/javascripts/blazer/Sortable.js on lines 1100..1106

                                          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 46.

                                          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 setMax = function (options, max) {
                                                    options.scales.yAxes[0].ticks.max = toFloat(max);
                                                  };
                                          Severity: Minor
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 30 mins to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1042..1044

                                          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 45.

                                          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 setBarMax = function (options, max) {
                                                    options.scales.xAxes[0].ticks.max = toFloat(max);
                                                  };
                                          Severity: Minor
                                          Found in app/assets/javascripts/blazer/chartkick.js and 1 other location - About 30 mins to fix
                                          app/assets/javascripts/blazer/chartkick.js on lines 1032..1034

                                          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 45.

                                          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