chartjs/Chart.js

View on GitHub

Showing 242 of 247 total issues

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

this.width = this._length = chart.width - this._margins.left - this._margins.right;
Severity: Minor
Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
src/core/core.scale.js on lines 685..685

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

this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);
Severity: Minor
Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
src/core/core.scale.js on lines 720..720

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

this.height = this._length = chart.height - this._margins.top - this._margins.bottom;
Severity: Minor
Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
src/core/core.scale.js on lines 681..681

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

this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);
Severity: Minor
Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
src/core/core.scale.js on lines 721..721

Function nearest has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

nearest(items, eventPosition) {
if (!items.length) {
return false;
}
 
 
Severity: Minor
Found in src/plugins/plugin.tooltip.js - About 35 mins to fix

Function getNearestCartesianItems has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
let items = [];
const distanceMetric = getDistanceMetricForAxis(axis);
let minDistance = Number.POSITIVE_INFINITY;
 
 
Severity: Minor
Found in src/core/core.interaction.js - About 35 mins to fix

Function buildOrUpdateControllers has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

buildOrUpdateControllers() {
const newControllers = [];
const datasets = this.data.datasets;
let i, ilen;
 
 
Severity: Minor
Found in src/core/core.controller.js - About 35 mins to fix

Function initOffsets has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

initOffsets(timestamps = []) {
let start = 0;
let end = 0;
let first, last;
 
 
Severity: Minor
Found in src/scales/scale.time.js - About 35 mins to fix

Function handleEvent has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

handleEvent(e) {
const opts = this.options;
if (!isListened(e.type, opts)) {
return;
}
Severity: Minor
Found in src/plugins/plugin.legend.js - About 35 mins to fix

Function _generate has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

_generate() {
const adapter = this._adapter;
const min = this.min;
const max = this.max;
const options = this.options;
Severity: Minor
Found in src/scales/scale.time.js - About 35 mins to fix

Function getPixelForGridLine has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

function getPixelForGridLine(scale, index, offsetGridLines) {
const length = scale.ticks.length;
const validIndex = Math.min(index, length - 1);
const start = scale._startPixel;
const end = scale._endPixel;
Severity: Minor
Found in src/core/core.scale.js - About 35 mins to fix

Function interpolate has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

function interpolate(table, val, reverse) {
let lo = 0;
let hi = table.length - 1;
let prevSource, nextSource, prevTarget, nextTarget;
if (reverse) {
Severity: Minor
Found in src/scales/scale.timeseries.js - About 35 mins to fix

Function _resolveTarget has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

export function _resolveTarget(sources, index, propagate) {
const source = sources[index];
let fill = source.fill;
const visited = [index];
let target;
Severity: Minor
Found in src/plugins/plugin.filler/filler.options.js - About 35 mins to fix

Function drawBody has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

drawBody(pt, ctx, options) {
const {body} = this;
const {bodySpacing, bodyAlign, displayColors, boxHeight, boxWidth, boxPadding} = options;
const bodyFont = toFont(options.bodyFont);
let bodyLineHeight = bodyFont.lineHeight;
Severity: Minor
Found in src/plugins/plugin.tooltip.js - About 35 mins to fix

Function afterDatasetsUpdate has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

afterDatasetsUpdate(chart, _args, options) {
const count = (chart.data.datasets || []).length;
const sources = [];
let meta, i, line, source;
 
 
Severity: Minor
Found in src/plugins/plugin.filler/index.js - About 35 mins to fix

Function _drawColorBox has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

_drawColorBox(ctx, pt, i, rtlHelper, options) {
const labelColor = this.labelColors[i];
const labelPointStyle = this.labelPointStyles[i];
const {boxHeight, boxWidth} = options;
const bodyFont = toFont(options.bodyFont);
Severity: Minor
Found in src/plugins/plugin.tooltip.js - About 35 mins to fix

Function clearStacks has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

function clearStacks(meta, items) {
// Not using meta.index here, because it might be already updated if the dataset changed location
const datasetIndex = meta.controller.index;
const axis = meta.vScale && meta.vScale.axis;
if (!axis) {
Severity: Minor
Found in src/core/core.datasetController.js - About 35 mins to fix

Function draw has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

draw() {
const ctx = this._ctx;
const chart = this.chart;
const meta = this._cachedMeta;
const elements = meta.data || [];
Severity: Minor
Found in src/core/core.datasetController.js - About 35 mins to fix

Avoid too many return statements within this function.
Open

return _createBoundaryLine(boundary, line);
Severity: Major
Found in src/plugins/plugin.filler/filler.target.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

    return false;
    Severity: Major
    Found in src/plugins/plugin.filler/filler.options.js - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language