dontfidget/chartnado

View on GitHub

Showing 24 of 26 total issues

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

/*
 * Derived from:
 *
 * Chartkick.js
 * Create beautiful Javascript charts with minimal code
Severity: Major
Found in lib/assets/javascripts/chartkick-chartnado.js - About 1 day to fix

    Function GoogleChartsAdapter has 262 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var GoogleChartsAdapter = new function () {
          var google = window.google;
    
          var loaded = {};
          var callbacks = [];
    Severity: Major
    Found in lib/assets/javascripts/chartkick-chartnado.js - About 1 day to fix

      Method chart_json has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

        def chart_json(series, show_total: false, reverse_sort: false, percentage: false)
          series = Chartnado::Series::Wrap[series]
          series *= 100.0 if percentage
          if series.has_separate_named_series?
            series = series.to_a
      Severity: Minor
      Found in lib/chartnado/renderer.rb - About 7 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 HighchartsAdapter has 146 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var HighchartsAdapter = new function () {
            var Highcharts = window.Highcharts;
      
            var defaultOptions = {
              chart: {},
      Severity: Major
      Found in lib/assets/javascripts/chartkick-chartnado.js - About 5 hrs to fix

        Method chart_json has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def chart_json(series, show_total: false, reverse_sort: false, percentage: false)
            series = Chartnado::Series::Wrap[series]
            series *= 100.0 if percentage
            if series.has_separate_named_series?
              series = series.to_a
        Severity: Major
        Found in lib/chartnado/renderer.rb - About 2 hrs to fix

          Method times has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

                def times(factor, precision: 2)
                  factor = wrap(factor)
          
                  return factor.times(self, precision: precision) if factor.dimensions > dimensions
                  return with_precision(precision, factor.to_f * to_f) unless dimensions > 1
          Severity: Minor
          Found in lib/chartnado/series/wrap.rb - 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

          Method group_by has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def group_by(group_name, scope, label_block = nil, &eval_block)
              group_values = [group_name] + scope.group_values
              series = scope.except(:group).group(group_values).
                instance_eval(&eval_block)
          
          
          Severity: Minor
          Found in lib/chartnado/group_by.rb - 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

          Consider simplifying this complex logical expression.
          Open

            if (window.google && window.google.setOnLoadCallback) {
              var GoogleChartsAdapter = new function () {
                var google = window.google;
          
                var loaded = {};
          Severity: Critical
          Found in lib/assets/javascripts/chartkick-chartnado.js - About 2 hrs to fix

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

                  var createDataTable = function (series, columnType) {
                    var data = new google.visualization.DataTable();
                    data.addColumn(columnType, "");
            
                    var i, j, s, d, rows = [], pos, rowPos = [], columns;
            Severity: Minor
            Found in lib/assets/javascripts/chartkick-chartnado.js - About 1 hr to fix

              Method over has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                    def over(bottom, multiplier: 1.0, precision: 2)
                      bottom = wrap(bottom)
                      return times(1.0 * multiplier / bottom, precision: precision) if bottom.dimensions == 1
              
                      if dimensions > bottom.dimensions
              Severity: Minor
              Found in lib/chartnado/series/wrap.rb - 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

              Method over has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def over(bottom, multiplier: 1.0, precision: 2)
                      bottom = wrap(bottom)
                      return times(1.0 * multiplier / bottom, precision: precision) if bottom.dimensions == 1
              
                      if dimensions > bottom.dimensions
              Severity: Minor
              Found in lib/chartnado/series/wrap.rb - About 1 hr to fix

                Method render has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def render(*args, ** options)
                    json_options = {}
                    chartkick_options = options.dup
                
                    if args.length > 1
                Severity: Minor
                Found in lib/chartnado/renderer.rb - 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 renderColumnChart has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

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

                    function processSeries(series, opts, time) {
                      var i, data, key;
                  
                      // see if one series or multiple
                      if (!isArray(series) || typeof series[0] !== "object" || isArray(series[0])) {
                  Severity: Minor
                  Found in lib/assets/javascripts/chartkick-chartnado.js - About 1 hr to fix

                    Function renderLineChart has 32 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 lib/assets/javascripts/chartkick-chartnado.js - About 1 hr to fix

                      Method group_by has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def group_by(group_name, scope, label_block = nil, &eval_block)
                          group_values = [group_name] + scope.group_values
                          series = scope.except(:group).group(group_values).
                            instance_eval(&eval_block)
                      
                      
                      Severity: Minor
                      Found in lib/chartnado/group_by.rb - About 1 hr to fix

                        Method dimensions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def dimensions
                                return 1 unless respond_to?(:length)
                                if hash?
                                  if keys.first && keys.first.is_a?(Array) || hash_of_named_series?
                                    3
                        Severity: Minor
                        Found in lib/chartnado/series/wrap.rb - 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 parseISO8601 has 27 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 lib/assets/javascripts/chartkick-chartnado.js - About 1 hr to fix

                          Method add has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def add(*series, scalar_sum: 0.0)
                                  (series, scalars) = [__getobj__, *series].partition { |s| s.respond_to?(:map) }
                                  scalar_sum += scalars.reduce(:+) || 0.0
                                  return wrap(scalar_sum) unless series.present?
                          
                          
                          Severity: Minor
                          Found in lib/chartnado/series/wrap.rb - About 1 hr to fix

                            Method times has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  def times(factor, precision: 2)
                                    factor = wrap(factor)
                            
                                    return factor.times(self, precision: precision) if factor.dimensions > dimensions
                                    return with_precision(precision, factor.to_f * to_f) unless dimensions > 1
                            Severity: Minor
                            Found in lib/chartnado/series/wrap.rb - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language