nnnick/Chart.js

View on GitHub

Showing 191 of 245 total issues

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

  _draw() {
    const {options: opts, columnSizes, lineWidths, ctx} = this;
    const {align, labels: labelOpts} = opts;
    const defaultColor = defaults.color;
    const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
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 drawLabels has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  drawLabels() {
    const ctx = this.ctx;
    const opts = this.options;
    const tickOpts = opts.ticks;

Severity: Minor
Found in src/scales/scale.radialLinear.js - About 1 hr to fix

    Function _boundSegment has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function _boundSegment(segment, points, bounds) {
      if (!bounds) {
        return [segment];
      }
    
    
    Severity: Minor
    Found in src/helpers/helpers.segment.js - About 1 hr to fix

      Function _calculatePadding has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _calculatePadding(first, last, sin, cos) {
          const {ticks: {align, padding}, position} = this.options;
          const isRotated = this.labelRotation !== 0;
          const labelsBelowTicks = position !== 'top' && this.axis === 'x';
      
      
      Severity: Minor
      Found in src/core/core.scale.js - About 1 hr to fix

        Function updateElements has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          updateElements(arcs, start, count, mode) {
            const reset = mode === 'reset';
            const chart = this.chart;
            const opts = chart.options;
            const animationOpts = opts.animation;
        Severity: Minor
        Found in src/controllers/controller.polarArea.js - About 1 hr to fix

          Function placeBoxes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function placeBoxes(boxes, chartArea, params, stacks) {
            const userPadding = params.padding;
            let {x, y} = chartArea;
          
            for (const layout of boxes) {
          Severity: Minor
          Found in src/core/core.layouts.js - About 1 hr to fix

            Function _update has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _update(date = Date.now()) {
                let remaining = 0;
            
                this._charts.forEach((anims, chart) => {
                  if (!anims.running || !anims.items.length) {
            Severity: Minor
            Found in src/core/core.animator.js - About 1 hr to fix

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

                update(mode) {
                  const config = this.config;
              
                  config.update();
                  const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext());
              Severity: Minor
              Found in src/core/core.controller.js - About 1 hr to fix

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

                  Function updateElements has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    updateElements(points, start, count, mode) {
                      const reset = mode === 'reset';
                      const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
                      const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
                      const iAxis = iScale.axis;
                  Severity: Minor
                  Found in src/controllers/controller.line.js - About 1 hr to fix

                    Function _calculatePadding has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
                    Open

                      _calculatePadding(first, last, sin, cos) {
                        const {ticks: {align, padding}, position} = this.options;
                        const isRotated = this.labelRotation !== 0;
                        const labelsBelowTicks = position !== 'top' && this.axis === 'x';
                    
                    
                    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 updateElements has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
                    Open

                      updateElements(arcs, start, count, mode) {
                        const reset = mode === 'reset';
                        const chart = this.chart;
                        const opts = chart.options;
                        const animationOpts = opts.animation;
                    Severity: Minor
                    Found in src/controllers/controller.polarArea.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 generateTicks has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
                    Open

                    function generateTicks(generationOptions, {min, max}) {
                      min = finiteOrDefault(generationOptions.min, min);
                      const ticks = [];
                      const minExp = log10Floor(min);
                      let exp = startExp(min, max);
                    Severity: Minor
                    Found in src/scales/scale.logarithmic.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 _longestText has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function _longestText(
                      ctx: CanvasRenderingContext2D,
                      font: string,
                      arrayOfThings: Things,
                      cache?: {data?: Record<string, number>, garbageCollect?: string[], font?: string}
                    Severity: Minor
                    Found in src/helpers/helpers.canvas.ts - About 1 hr to fix

                      Function drawBackground has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        drawBackground(pt, ctx, tooltipSize, options) {
                          const {xAlign, yAlign} = this;
                          const {x, y} = pt;
                          const {width, height} = tooltipSize;
                          const {topLeft, topRight, bottomLeft, bottomRight} = toTRBLCorners(options.cornerRadius);
                      Severity: Minor
                      Found in src/plugins/plugin.tooltip.js - About 1 hr to fix

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

                          Function buildOrUpdateControllers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            buildOrUpdateControllers() {
                              const newControllers = [];
                              const datasets = this.data.datasets;
                              let i, ilen;
                          
                          
                          Severity: Minor
                          Found in src/core/core.controller.js - About 1 hr to fix

                            Function updateElements has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              updateElements(arcs, start, count, mode) {
                                const reset = mode === 'reset';
                                const chart = this.chart;
                                const chartArea = chart.chartArea;
                                const opts = chart.options;
                            Severity: Minor
                            Found in src/controllers/controller.doughnut.js - About 1 hr to fix

                              Function mergeScaleConfig has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function mergeScaleConfig(config, options) {
                                const chartDefaults = overrides[config.type] || {scales: {}};
                                const configScales = options.scales || {};
                                const chartIndexAxis = getIndexAxis(config.type, options);
                                const scales = Object.create(null);
                              Severity: Minor
                              Found in src/core/core.config.js - About 1 hr to fix

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

                                function initCanvas(canvas, aspectRatio) {
                                  const style = canvas.style;
                                
                                  // NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it
                                  // returns null or '' if no explicit value has been set to the canvas attribute.
                                Severity: Minor
                                Found in src/platform/platform.dom.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language