nnnick/Chart.js

View on GitHub

Showing 191 of 245 total issues

Function calculateLabelRotation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  calculateLabelRotation() {
    const options = this.options;
    const tickOpts = options.ticks;
    const numTicks = getTicksLimit(this.ticks.length, options.ticks.maxTicksLimit);
    const minRotation = tickOpts.minRotation || 0;
Severity: Minor
Found in src/core/core.scale.js - About 1 hr to fix

    Function _getStacks has 28 lines of code (exceeds 25 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

      Function listenArrayEvents has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function listenArrayEvents(array, listener) {
        if (array._chartjs) {
          array._chartjs.listeners.push(listener);
          return;
        }
      Severity: Minor
      Found in src/helpers/helpers.collection.ts - About 1 hr to fix

        Function autoSkip has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        export function autoSkip(scale, ticks) {
          const tickOpts = scale.options.ticks;
          const determinedMaxTicks = determineMaxTicks(scale);
          const ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks);
          const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];
        Severity: Minor
        Found in src/core/core.scale.autoskip.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 getCaretPosition has a Cognitive Complexity of 12 (exceeds 7 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

        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 titleArgs has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        function titleArgs(scale, offset, position, align) {
          const {top, left, bottom, right, chart} = scale;
          const {chartArea, scales} = chart;
          let rotation = 0;
          let maxWidth, titleX, titleY;
        Severity: Minor
        Found in src/core/core.scale.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 determineDataLimits has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

          determineDataLimits() {
            const options = this.options;
            const adapter = this._adapter;
            const unit = options.time.unit || 'day';
            // eslint-disable-next-line prefer-const
        Severity: Minor
        Found in src/scales/scale.time.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 fill has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        function fill(ctx, cfg) {
          const {line, target, property, color, scale} = cfg;
          const segments = _segments(line, target, property);
        
          for (const {source: src, target: tgt, start, end} of segments) {
        Severity: Minor
        Found in src/plugins/plugin.filler/filler.drawing.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 resolve has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        export function resolve(inputs: Array<unknown>, context?: object, index?: number, info?: { cacheable: boolean }) {
          let cacheable = true;
          let i: number, ilen: number, value: unknown;
        
          for (i = 0, ilen = inputs.length; i < ilen; ++i) {
        Severity: Minor
        Found in src/helpers/helpers.options.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 _getStartAndCountOfVisiblePoints has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatter'>, points: PointElement[], animationsDisabled: boolean) {
          const pointCount = points.length;
        
          let start = 0;
          let count = pointCount;
        Severity: Minor
        Found in src/helpers/helpers.extras.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 getMinMax has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

          getMinMax(scale, canStack) {
            const meta = this._cachedMeta;
            const _parsed = meta._parsed;
            const sorted = meta._sorted && scale === meta.iScale;
            const ilen = _parsed.length;
        Severity: Minor
        Found in src/core/core.datasetController.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 _generate has 27 lines of code (exceeds 25 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 1 hr to fix

          Function nearest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Function _createItems has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _createItems(options) {
                const active = this._active;
                const data = this.chart.data;
                const labelColors = [];
                const labelPointStyles = [];
            Severity: Minor
            Found in src/plugins/plugin.tooltip.js - About 1 hr to fix

              Function fill has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function fill(ctx, cfg) {
                const {line, target, property, color, scale} = cfg;
                const segments = _segments(line, target, property);
              
                for (const {source: src, target: tgt, start, end} of segments) {
              Severity: Minor
              Found in src/plugins/plugin.filler/filler.drawing.js - About 1 hr to fix

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

                  Function drawBorder has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    drawBorder() {
                      const {chart, ctx, options: {border, grid}} = this;
                      const borderOpts = border.setContext(this.getContext());
                      const axisWidth = border.display ? borderOpts.width : 0;
                      if (!axisWidth) {
                  Severity: Minor
                  Found in src/core/core.scale.js - About 1 hr to fix

                    Function boundingRects has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function boundingRects(bar) {
                      const bounds = getBarBounds(bar);
                      const width = bounds.right - bounds.left;
                      const height = bounds.bottom - bounds.top;
                      const border = parseBorderWidth(bar, width / 2, height / 2);
                    Severity: Minor
                    Found in src/elements/element.bar.js - About 1 hr to fix

                      Function _drawDataset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _drawDataset(meta) {
                          const ctx = this.ctx;
                          const clip = meta._clip;
                          const useClip = !clip.disabled;
                          const area = getDatasetArea(meta, this.chartArea);
                      Severity: Minor
                      Found in src/core/core.controller.js - About 1 hr to fix

                        Function _updateBezierControlPoints has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function _updateBezierControlPoints(
                          points: SplinePoint[],
                          options,
                          area: ChartArea,
                          loop: boolean,
                        Severity: Minor
                        Found in src/helpers/helpers.curve.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language