Showing 26 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
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 = [];
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
- Read upRead up
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: {},
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
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
- Read upRead up
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)
- Read upRead up
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 = {};
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;
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
- Read upRead up
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
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
- Read upRead up
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 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])) {
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;
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 = {
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)
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
- Read upRead up
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 render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render(*args, ** options)
json_options = {}
chartkick_options = options.dup
if args.length > 1
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?
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