chartjs/Chart.js

View on GitHub

Showing 242 of 247 total issues

Avoid too many return statements within this function.
Open

return;
Severity: Major
Found in src/plugins/plugin.decimation.js - About 30 mins to fix

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

    const h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y;
    Severity: Minor
    Found in src/elements/element.bar.js and 1 other location - About 30 mins to fix
    src/elements/element.bar.js on lines 130..130

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

    ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFont.lineHeight / 2);
    Severity: Minor
    Found in src/plugins/plugin.tooltip.js and 1 other location - About 30 mins to fix
    src/plugins/plugin.tooltip.js on lines 955..955

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

    const w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x;
    Severity: Minor
    Found in src/elements/element.bar.js and 1 other location - About 30 mins to fix
    src/elements/element.bar.js on lines 131..131

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

    ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFont.lineHeight / 2);
    Severity: Minor
    Found in src/plugins/plugin.tooltip.js and 1 other location - About 30 mins to fix
    src/plugins/plugin.tooltip.js on lines 776..776

    Function computeMinSampleSize has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function computeMinSampleSize(meta) {
    const scale = meta.iScale;
    const values = getAllScaleValues(scale, meta.type);
    let min = scale._length;
    let i, ilen, curr, prev;
    Severity: Minor
    Found in src/controllers/controller.bar.js - About 25 mins to fix

    Function updateElements has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    updateElements(points, start, count, mode) {
    const scale = this._cachedMeta.rScale;
    const reset = mode === 'reset';
     
    for (let i = start; i < start + count; i++) {
    Severity: Minor
    Found in src/controllers/controller.radar.js - About 25 mins to fix

    Function fitBoxes has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function fitBoxes(boxes, chartArea, params, stacks) {
    const refitBoxes = [];
    let i, ilen, layout, box, refit, changed;
     
    for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) {
    Severity: Minor
    Found in src/core/core.layouts.js - About 25 mins to fix

    Function _calculateBarIndexPixels has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    _calculateBarIndexPixels(index, ruler) {
    const scale = ruler.scale;
    const options = this.options;
    const skipNull = options.skipNull;
    const maxBarThickness = valueOrDefault(options.maxBarThickness, Infinity);
    Severity: Minor
    Found in src/controllers/controller.bar.js - About 25 mins to fix

    Function _segments has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    export function _segments(line, target, property) {
    const segments = line.segments;
    const points = line.points;
    const tpoints = target.points;
    const parts = [];
    Severity: Minor
    Found in src/plugins/plugin.filler/filler.segment.js - About 25 mins to fix

    Function getMinMax has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    getMinMax(canStack) {
    let {min, max, minDefined, maxDefined} = this.getUserBounds();
    let range;
     
    if (minDefined && maxDefined) {
    Severity: Minor
    Found in src/core/core.scale.js - About 25 mins to fix

    Function updateDims has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function updateDims(chartArea, params, layout, stacks) {
    const {pos, box} = layout;
    const maxPadding = chartArea.maxPadding;
     
    // dynamically placed boxes size is not considered
    Severity: Minor
    Found in src/core/core.layouts.js - About 25 mins to fix

    Function title has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    title(tooltipItems) {
    if (tooltipItems.length > 0) {
    const item = tooltipItems[0];
    const labels = item.chart.data.labels;
    const labelCount = labels ? labels.length : 0;
    Severity: Minor
    Found in src/plugins/plugin.tooltip.js - About 25 mins to fix

    Function setBorderSkipped has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function setBorderSkipped(properties, options, stack, index) {
    let edge = options.borderSkipped;
    const res = {};
     
    if (!edge) {
    Severity: Minor
    Found in src/controllers/controller.bar.js - About 25 mins to fix

    Function merge has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject {
    const sources = isArray(source) ? source : [source];
    const ilen = sources.length;
     
    if (!isObject(target)) {
    Severity: Minor
    Found in src/helpers/helpers.core.ts - About 25 mins to fix

    Function capBezierPoints has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function capBezierPoints(points: SplinePoint[], area: ChartArea) {
    let i, ilen, point, inArea, inAreaPrev;
    let inAreaNext = _isPointInArea(points[0], area);
    for (i = 0, ilen = points.length; i < ilen; ++i) {
    inAreaPrev = inArea;
    Severity: Minor
    Found in src/helpers/helpers.curve.ts - About 25 mins to fix

    Function monotoneAdjust has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    function monotoneAdjust(points: SplinePoint[], deltaK: number[], mK: number[]) {
    const pointsLen = points.length;
     
    let alphaK: number, betaK: number, tauK: number, squaredMagnitude: number, pointCurrent: OptionalSplinePoint;
    let pointAfter = getPoint(points, 0);
    Severity: Minor
    Found in src/helpers/helpers.curve.ts - About 25 mins to fix

    Function _dataCheck has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

    _dataCheck() {
    const dataset = this.getDataset();
    const data = dataset.data || (dataset.data = []);
    const _data = this._data;
     
     
    Severity: Minor
    Found in src/core/core.datasetController.js - About 25 mins to fix

    TODO found
    Open

    // TODO: It is not optimal to always parse the old data
    Severity: Minor
    Found in src/core/core.datasetController.js by fixme

    TODO found
    Open

    // TODO: V4, make this private, rename to `_labelStyles`, and combine with `labelPointStyles`
    Severity: Minor
    Found in src/plugins/plugin.tooltip.js by fixme
    Severity
    Category
    Status
    Source
    Language