nnnick/Chart.js

View on GitHub
src/core/core.scale.js

Summary

Maintainability
F
2 wks
Test Coverage

File core.scale.js has 1223 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Element from './core.element.js';
import {_alignPixel, _measureText, renderText, clipArea, unclipArea} from '../helpers/helpers.canvas.js';
import {callback as call, each, finiteOrDefault, isArray, isFinite, isNullOrUndef, isObject, valueOrDefault} from '../helpers/helpers.core.js';
import {toDegrees, toRadians, _int16Range, _limitValue, HALF_PI} from '../helpers/helpers.math.js';
import {_alignStartEnd, _toLeftRightCenter} from '../helpers/helpers.extras.js';
Severity: Major
Found in src/core/core.scale.js - About 3 days to fix

    Function _computeLabelItems has a Cognitive Complexity of 78 (exceeds 7 allowed). Consider refactoring.
    Open

      _computeLabelItems(chartArea) {
        const axis = this.axis;
        const options = this.options;
        const {position, ticks: optionTicks} = options;
        const isHorizontal = this.isHorizontal();
    Severity: Minor
    Found in src/core/core.scale.js - About 1 day 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

    Scale has 68 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Scale extends Element {
    
      // eslint-disable-next-line max-statements
      constructor(cfg) {
        super();
    Severity: Major
    Found in src/core/core.scale.js - About 1 day to fix

      Function _computeLabelItems has 164 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _computeLabelItems(chartArea) {
          const axis = this.axis;
          const options = this.options;
          const {position, ticks: optionTicks} = options;
          const isHorizontal = this.isHorizontal();
      Severity: Major
      Found in src/core/core.scale.js - About 6 hrs to fix

        Function _computeGridLineItems has 113 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _computeGridLineItems(chartArea) {
            const axis = this.axis;
            const chart = this.chart;
            const options = this.options;
            const {grid, position, border} = options;
        Severity: Major
        Found in src/core/core.scale.js - About 4 hrs to fix

          Function _getYAxisLabelAlignment has a Cognitive Complexity of 29 (exceeds 7 allowed). Consider refactoring.
          Open

            _getYAxisLabelAlignment(tl) {
              const {position, ticks: {crossAlign, mirror, padding}} = this.options;
              const labelSizes = this._getLabelSizes();
              const tickAndPadding = tl + padding;
              const widest = labelSizes.widest.width;
          Severity: Minor
          Found in src/core/core.scale.js - About 3 hrs 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 fit has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
          Open

            fit() {
              // Reset
              const minSize = {
                width: 0,
                height: 0
          Severity: Minor
          Found in src/core/core.scale.js - About 2 hrs 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 _computeGridLineItems has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
          Open

            _computeGridLineItems(chartArea) {
              const axis = this.axis;
              const chart = this.chart;
              const options = this.options;
              const {grid, position, border} = options;
          Severity: Minor
          Found in src/core/core.scale.js - About 2 hrs 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 _getYAxisLabelAlignment has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _getYAxisLabelAlignment(tl) {
              const {position, ticks: {crossAlign, mirror, padding}} = this.options;
              const labelSizes = this._getLabelSizes();
              const tickAndPadding = tl + padding;
              const widest = labelSizes.widest.width;
          Severity: Major
          Found in src/core/core.scale.js - About 2 hrs to fix

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

              update(maxWidth, maxHeight, margins) {
                const {beginAtZero, grace, ticks: tickOpts} = this.options;
                const sampleSize = tickOpts.sampleSize;
            
                // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
            Severity: Minor
            Found in src/core/core.scale.js - About 1 hr to fix

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

                constructor(cfg) {
                  super();
              
                  /** @type {string} */
                  this.id = cfg.id;
              Severity: Minor
              Found in src/core/core.scale.js - About 1 hr to fix

                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 _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 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 _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 _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 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 _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 _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 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 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 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 drawGrid has a Cognitive Complexity of 11 (exceeds 7 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 55 mins 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 getPixelForGridLine has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
                                Open

                                function getPixelForGridLine(scale, index, offsetGridLines) {
                                  const length = scale.ticks.length;
                                  const validIndex = Math.min(index, length - 1);
                                  const start = scale._startPixel;
                                  const end = scale._endPixel;
                                Severity: Minor
                                Found in src/core/core.scale.js - About 35 mins 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 8 (exceeds 7 allowed). Consider refactoring.
                                Open

                                  getMinMax(canStack) {
                                    // eslint-disable-next-line prefer-const
                                    let {min, max, minDefined, maxDefined} = this.getUserBounds();
                                    let range;
                                
                                
                                Severity: Minor
                                Found in src/core/core.scale.js - About 25 mins 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

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

                                    if (position === 'left') {
                                      if (mirror) {
                                        x = this.right + padding;
                                
                                        if (crossAlign === 'near') {
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 7 hrs to fix
                                src/core/core.scale.js on lines 1388..1416

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 181.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    } else if (position === 'right') {
                                      if (mirror) {
                                        x = this.left + padding;
                                
                                        if (crossAlign === 'near') {
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 7 hrs to fix
                                src/core/core.scale.js on lines 1362..1416

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 181.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    if (isObject(position)) {
                                      const positionAxisID = Object.keys(position)[0];
                                      const value = position[positionAxisID];
                                      titleX = scales[positionAxisID].getPixelForValue(value) - width + offset;
                                    } else if (position === 'center') {
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 4 hrs to fix
                                src/core/core.scale.js on lines 142..150

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 128.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    if (isObject(position)) {
                                      const positionAxisID = Object.keys(position)[0];
                                      const value = position[positionAxisID];
                                      titleY = scales[positionAxisID].getPixelForValue(value) + height - offset;
                                    } else if (position === 'center') {
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 4 hrs to fix
                                src/core/core.scale.js on lines 153..161

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 128.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    } else if (position === 'bottom') {
                                      borderValue = alignBorderValue(this.top);
                                      y1 = chartArea.top;
                                      y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;
                                      ty1 = borderValue + axisHalfWidth;
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                                src/core/core.scale.js on lines 1053..1085

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 75.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    } else if (position === 'right') {
                                      borderValue = alignBorderValue(this.left);
                                      x1 = chartArea.left;
                                      x2 = alignBorderValue(chartArea.right) - axisHalfWidth;
                                      tx1 = borderValue + axisHalfWidth;
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                                src/core/core.scale.js on lines 1041..1085

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 75.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    if (position === 'top') {
                                      borderValue = alignBorderValue(this.bottom);
                                      ty1 = this.bottom - tl;
                                      ty2 = borderValue - axisHalfWidth;
                                      y1 = alignBorderValue(chartArea.top) + axisHalfWidth;
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                                src/core/core.scale.js on lines 1047..1085

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 75.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    } else if (position === 'left') {
                                      borderValue = alignBorderValue(this.right);
                                      tx1 = this.right - tl;
                                      tx2 = borderValue - axisHalfWidth;
                                      x1 = alignBorderValue(chartArea.left) + axisHalfWidth;
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                                src/core/core.scale.js on lines 1035..1085

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 75.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      if (position === 'center') {
                                        borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + 0.5);
                                      } else if (isObject(position)) {
                                        const positionAxisID = Object.keys(position)[0];
                                        const value = position[positionAxisID];
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 1 hr to fix
                                src/core/core.scale.js on lines 1073..1079

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 73.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      if (position === 'center') {
                                        borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
                                      } else if (isObject(position)) {
                                        const positionAxisID = Object.keys(position)[0];
                                        const value = position[positionAxisID];
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 1 hr to fix
                                src/core/core.scale.js on lines 1060..1066

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 73.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    if (this.isHorizontal()) {
                                      x1 = _alignPixel(chart, this.left, axisWidth) - axisWidth / 2;
                                      x2 = _alignPixel(chart, this.right, lastLineWidth) + lastLineWidth / 2;
                                      y1 = y2 = borderValue;
                                    } else {
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 1 hr to fix
                                src/core/core.scale.js on lines 1538..1542

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 64.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                    } else {
                                      y1 = _alignPixel(chart, this.top, axisWidth) - axisWidth / 2;
                                      y2 = _alignPixel(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;
                                      x1 = x2 = borderValue;
                                    }
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 1 hr to fix
                                src/core/core.scale.js on lines 1534..1538

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 64.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                  getPixelForTick(index) {
                                    const ticks = this.ticks;
                                    if (index < 0 || index > ticks.length - 1) {
                                      return null;
                                    }
                                Severity: Major
                                Found in src/core/core.scale.js and 1 other location - About 1 hr to fix
                                src/scales/scale.category.js on lines 143..149

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 64.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);
                                Severity: Minor
                                Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
                                src/core/core.scale.js on lines 722..722

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 47.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      this.height = this._length = chart.height - this._margins.top - this._margins.bottom;
                                Severity: Minor
                                Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
                                src/core/core.scale.js on lines 682..682

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 47.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      this.width = this._length = chart.width - this._margins.left - this._margins.right;
                                Severity: Minor
                                Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
                                src/core/core.scale.js on lines 686..686

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 47.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

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

                                      this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);
                                Severity: Minor
                                Found in src/core/core.scale.js and 1 other location - About 35 mins to fix
                                src/core/core.scale.js on lines 721..721

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 47.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                There are no issues that match your filters.

                                Category
                                Status