Showing 191 of 245 total issues
Function parse
has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring. Open
parse(start, count) {
const {_cachedMeta: meta, _data: data} = this;
const {iScale, _stacked} = meta;
const iAxis = iScale.axis;
- 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
TimeScale
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export default class TimeScale extends Scale {
static id = 'time';
/**
Function _getYAxisLabelAlignment
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getYAxisLabelAlignment(tl) {
const {position, ticks: {crossAlign, mirror, padding}} = this.options;
const labelSizes = this._getLabelSizes();
const tickAndPadding = tl + padding;
const widest = labelSizes.widest.width;
Function update
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
update(chart, width, height, minPadding) {
if (!chart) {
return;
}
Function buildOrUpdateScales
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildOrUpdateScales() {
const options = this.options;
const scaleOpts = options.scales;
const scales = this.scales;
const updated = Object.keys(scales).reduce((obj, id) => {
Function _calculateBarValuePixels
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
_calculateBarValuePixels(index) {
const {_cachedMeta: {vScale, _stacked, index: datasetIndex}, options: {base: baseValue, minBarLength}} = this;
const actualBase = baseValue || 0;
const parsed = this.getParsed(index);
const custom = parsed._custom;
Function beforeElementsUpdate
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
beforeElementsUpdate: (chart, args, options) => {
if (!options.enabled) {
// The decimation plugin may have been previously enabled. Need to remove old `dataset._data` handlers
cleanDecimatedData(chart);
return;
Function constructor
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(item, userConfig) {
const config = this.config = new Config(userConfig);
const initialCanvas = getCanvas(item);
const existingChart = getChart(initialCanvas);
if (existingChart) {
File helpers.core.ts
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @namespace Chart.helpers
*/
import type {AnyObject} from '../types/basic.js';
Function placeBoxes
has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring. Open
function placeBoxes(boxes, chartArea, params, stacks) {
const userPadding = params.padding;
let {x, y} = chartArea;
for (const layout of boxes) {
- 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 pathArc
has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring. Open
function pathArc(
ctx: CanvasRenderingContext2D,
element: ArcElement,
offset: number,
spacing: number,
- 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 doSplitByStyles
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doSplitByStyles(line, segments, points, segmentOptions) {
const chartContext = line._chart.getContext();
const baseStyle = readStyle(line.options);
const {_datasetIndex: datasetIndex, options: {spanGaps}} = line;
const count = points.length;
Function minMaxDecimation
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function minMaxDecimation(data, start, count, availableWidth) {
let avgX = 0;
let countX = 0;
let i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;
const decimated = [];
Function getTooltipSize
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTooltipSize(tooltip, options) {
const ctx = tooltip.chart.ctx;
const {body, footer, title} = tooltip;
const {boxWidth, boxHeight} = options;
const bodyFont = toFont(options.bodyFont);
File helpers.segment.js
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {_angleBetween, _angleDiff, _isBetween, _normalizeAngle} from './helpers.math.js';
import {createContext} from './helpers.options.js';
import {isPatternOrGradient} from './helpers.color.js';
/**
Function update
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
update(maxWidth, maxHeight, margins) {
const {beginAtZero, grace, ticks: tickOpts} = this.options;
const sampleSize = tickOpts.sampleSize;
// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
Function constructor
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(cfg) {
super();
/** @type {string} */
this.id = cfg.id;
Function _boundSegment
has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring. Open
export function _boundSegment(segment, points, bounds) {
if (!bounds) {
return [segment];
}
- 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 updateElements
has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring. Open
updateElements(bars, start, count, mode) {
const reset = mode === 'reset';
const {index, _cachedMeta: {vScale}} = this;
const base = vScale.getBasePixel();
const horizontal = vScale.isHorizontal();
- 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 _longestText
has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring. Open
export function _longestText(
ctx: CanvasRenderingContext2D,
font: string,
arrayOfThings: Things,
cache?: {data?: Record<string, number>, garbageCollect?: string[], font?: string}
- 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"