nnnick/Chart.js

View on GitHub

Showing 191 of 245 total issues

Function splineCurveMonotone has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
Open

export function splineCurveMonotone(points: SplinePoint[], indexAxis: 'x' | 'y' = 'x') {
  const valueAxis = getValueAxis(indexAxis);
  const pointsLen = points.length;
  const deltaK: number[] = Array(pointsLen).fill(0);
  const mK: number[] = Array(pointsLen);
Severity: Minor
Found in src/helpers/helpers.curve.ts - 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 lttbDecimation has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function lttbDecimation(data, start, count, availableWidth, options) {
  /**
   * Implementation of the Largest Triangle Three Buckets algorithm.
   *
   * This implementation is based on the original implementation by Sveinn Steinarsson
Severity: Minor
Found in src/plugins/plugin.decimation.js - About 1 hr to fix

    Function drawLegendBox has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const drawLegendBox = function(x, y, legendItem) {
          if (isNaN(boxWidth) || boxWidth <= 0 || isNaN(boxHeight) || boxHeight < 0) {
            return;
          }
    
    
    Severity: Minor
    Found in src/plugins/plugin.legend.js - About 1 hr to fix

      Function solidSegments has a Cognitive Complexity of 16 (exceeds 7 allowed). Consider refactoring.
      Open

      function solidSegments(points, start, max, loop) {
        const count = points.length;
        const result = [];
        let last = start;
        let prev = points[start];
      Severity: Minor
      Found in src/helpers/helpers.segment.js - 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 _createAnimations has a Cognitive Complexity of 16 (exceeds 7 allowed). Consider refactoring.
      Open

        _createAnimations(target, values) {
          const animatedProps = this._properties;
          const animations = [];
          const running = target.$animations || (target.$animations = {});
          const props = Object.keys(values);
      Severity: Minor
      Found in src/core/core.animations.js - 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 drawGrid has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        drawGrid(chartArea) {
          const grid = this.options.grid;
          const ctx = this.ctx;
          const items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea));
          let i, ilen;
      Severity: Minor
      Found in src/core/core.scale.js - About 1 hr to fix

        Function constructor has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(_descriptors, _appliers) {
            this.animation = undefined;
            this.backgroundColor = 'rgba(0,0,0,0.1)';
            this.borderColor = 'rgba(0,0,0,0.1)';
            this.color = '#666';
        Severity: Minor
        Found in src/core/core.defaults.js - About 1 hr to fix

          Function fastPathSegment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function fastPathSegment(ctx, line, segment, params) {
            const points = line.points;
            const {count, start, ilen} = pathVars(points, segment, params);
            const {move = true, reverse} = params || {};
            let avgX = 0;
          Severity: Minor
          Found in src/elements/element.line.js - About 1 hr to fix

            Function getCaretPosition has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getCaretPosition(tooltipPoint, size, options) {
                const {xAlign, yAlign} = this;
                const {caretSize, cornerRadius} = options;
                const {topLeft, topRight, bottomLeft, bottomRight} = toTRBLCorners(cornerRadius);
                const {x: ptX, y: ptY} = tooltipPoint;
            Severity: Minor
            Found in src/plugins/plugin.tooltip.js - About 1 hr to fix

              Function update has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                update(changed, replay) {
                  const options = this.options.setContext(this.getContext());
                  const active = this._active;
                  let properties;
                  let tooltipItems = [];
              Severity: Minor
              Found in src/plugins/plugin.tooltip.js - About 1 hr to fix

                Function _computeLabelSizes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _computeLabelSizes(ticks, length, maxTicksLimit) {
                    const {ctx, _longestTextCache: caches} = this;
                    const widths = [];
                    const heights = [];
                    const increment = Math.floor(length / getTicksLimit(length, maxTicksLimit));
                Severity: Minor
                Found in src/core/core.scale.js - About 1 hr to fix

                  Function drawBody has 41 lines of code (exceeds 25 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 1 hr to fix

                    Function fit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      fit() {
                        // Reset
                        const minSize = {
                          width: 0,
                          height: 0
                    Severity: Minor
                    Found in src/core/core.scale.js - About 1 hr to fix

                      Function bindResponsiveEvents has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        bindResponsiveEvents() {
                          if (!this._responsiveListeners) {
                            this._responsiveListeners = {};
                          }
                          const listeners = this._responsiveListeners;
                      Severity: Minor
                      Found in src/core/core.controller.js - About 1 hr to fix

                        Function drawGrid has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          drawGrid() {
                            const ctx = this.ctx;
                            const opts = this.options;
                            const {angleLines, grid, border} = opts;
                            const labelCount = this._pointLabels.length;
                        Severity: Minor
                        Found in src/scales/scale.radialLinear.js - About 1 hr to fix

                          Function _attachContext has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function _attachContext<
                            T extends AnyObject[] = AnyObject[],
                            R extends AnyObject[] = T
                          >(
                            proxy: ResolverProxy<T, R>,
                          Severity: Minor
                          Found in src/helpers/helpers.config.ts - About 1 hr to fix

                            Function fastPathSegment has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
                            Open

                            function fastPathSegment(ctx, line, segment, params) {
                              const points = line.points;
                              const {count, start, ilen} = pathVars(points, segment, params);
                              const {move = true, reverse} = params || {};
                              let avgX = 0;
                            Severity: Minor
                            Found in src/elements/element.line.js - 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 _calculateBarValuePixels has a Cognitive Complexity of 15 (exceeds 7 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;
                            Severity: Minor
                            Found in src/controllers/controller.bar.js - 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 _getStacks has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
                            Open

                              _getStacks(last, dataIndex) {
                                const {iScale} = this._cachedMeta;
                                const metasets = iScale.getMatchingVisibleMetas(this._type)
                                  .filter(meta => meta.controller.options.grouped);
                                const stacked = iScale.options.stacked;
                            Severity: Minor
                            Found in src/controllers/controller.bar.js - 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 updateElements has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
                            Open

                              updateElements(points, start, count, mode) {
                                const reset = mode === 'reset';
                                const {iScale, vScale} = this._cachedMeta;
                                const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
                                const iAxis = iScale.axis;
                            Severity: Minor
                            Found in src/controllers/controller.bubble.js - 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

                            Severity
                            Category
                            Status
                            Source
                            Language