chartjs/Chart.js

View on GitHub

Showing 190 of 245 total issues

Function parse has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parse(start, count) {
    const {_cachedMeta: meta, _data: data} = this;
    const {iScale, _stacked} = meta;
    const iAxis = iScale.axis;

Severity: Minor
Found in src/core/core.datasetController.js - About 1 hr to fix

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

      Function adjustHitBoxes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        adjustHitBoxes() {
          if (!this.options.display) {
            return;
          }
          const titleHeight = this._computeTitleHeight();
      Severity: Minor
      Found in src/plugins/plugin.legend.js - About 1 hr to fix

        Function fitWithPointLabels has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function fitWithPointLabels(scale) {
        
          // Right, this is really confusing and there is a lot of maths going on here
          // The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
          //
        Severity: Minor
        Found in src/scales/scale.radialLinear.js - About 1 hr to fix

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

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

            function drawBorder(
              ctx: CanvasRenderingContext2D,
              element: ArcElement,
              offset: number,
              spacing: number,
            Severity: Minor
            Found in src/elements/element.arc.ts - About 1 hr to fix

              Function handleTickRangeOptions has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
              Open

                handleTickRangeOptions() {
                  const {beginAtZero} = this.options;
                  const {minDefined, maxDefined} = this.getUserBounds();
                  let {min, max} = this;
              
              
              Severity: Minor
              Found in src/scales/scale.linearbase.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 _computeLabelSizes has a Cognitive Complexity of 13 (exceeds 7 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

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

                adjustHitBoxes() {
                  if (!this.options.display) {
                    return;
                  }
                  const titleHeight = this._computeTitleHeight();
              Severity: Minor
              Found in src/plugins/plugin.legend.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 each has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
              Open

              export function each<T, TA>(
                loopable: T[] | Record<string, T>,
                fn: (this: TA, v: T, i: any) => void,
                thisArg?: TA,
                reverse?: boolean
              Severity: Minor
              Found in src/helpers/helpers.core.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 renderText has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
              Open

              export function renderText(
                ctx: CanvasRenderingContext2D,
                text: string | string[],
                x: number,
                y: number,
              Severity: Minor
              Found in src/helpers/helpers.canvas.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 buildTicks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                buildTicks() {
                  const opts = this.options;
                  const tickOpts = opts.ticks;
              
                  // Figure out what the max number of ticks we can support it is based on the size of
              Severity: Minor
              Found in src/scales/scale.linearbase.js - About 1 hr to fix

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

                  update(mode) {
                    const meta = this._cachedMeta;
                    const {data: points = []} = meta;
                    // @ts-ignore
                    const animationsDisabled = this.chart._animationsDisabled;
                Severity: Minor
                Found in src/controllers/controller.scatter.js - About 1 hr to fix

                  Function drawTitle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    drawTitle() {
                      const opts = this.options;
                      const titleOpts = opts.title;
                      const titleFont = toFont(titleOpts.font);
                      const titlePadding = toPadding(titleOpts.padding);
                  Severity: Minor
                  Found in src/plugins/plugin.legend.js - About 1 hr to fix

                    Function _layers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _layers() {
                        const opts = this.options;
                        const tz = opts.ticks && opts.ticks.z || 0;
                        const gz = valueOrDefault(opts.grid && opts.grid.z, -1);
                        const bz = valueOrDefault(opts.border && opts.border.z, 0);
                    Severity: Minor
                    Found in src/core/core.scale.js - About 1 hr to fix

                      Function draw has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        draw(ctx) {
                          const options = this.options.setContext(this.getContext());
                          let opacity = this.opacity;
                      
                          if (!opacity) {
                      Severity: Minor
                      Found in src/plugins/plugin.tooltip.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 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 afterDatasetsUpdate has 28 lines of code (exceeds 25 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 1 hr to fix

                              Function updateElements has 28 lines of code (exceeds 25 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();
                              Severity: Minor
                              Found in src/controllers/controller.bar.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language