chartjs/Chart.js

View on GitHub

Showing 240 of 245 total issues

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 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 _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 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 _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 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 _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

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

                      defaults: {
                        align: 'center',
                        display: false,
                        font: {
                          weight: 'normal',
                    Severity: Minor
                    Found in src/plugins/plugin.subtitle.js and 1 other location - About 55 mins to fix
                    src/plugins/plugin.title.js on lines 145..156

                    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 54.

                    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

                      defaults: {
                        align: 'center',
                        display: false,
                        font: {
                          weight: 'bold',
                    Severity: Minor
                    Found in src/plugins/plugin.title.js and 1 other location - About 55 mins to fix
                    src/plugins/plugin.subtitle.js on lines 32..43

                    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 54.

                    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

                    function getLineMethod(options) {
                      if (options.stepped) {
                        return _steppedLineTo;
                      }
                    
                    
                    Severity: Minor
                    Found in src/elements/element.line.js and 1 other location - About 55 mins to fix
                    src/elements/element.line.js on lines 195..205

                    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 54.

                    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

                    function _getInterpolationMethod(options) {
                      if (options.stepped) {
                        return _steppedInterpolation;
                      }
                    
                    
                    Severity: Minor
                    Found in src/elements/element.line.js and 1 other location - About 55 mins to fix
                    src/elements/element.line.js on lines 28..38

                    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 54.

                    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

                    Function _drawDataset has a Cognitive Complexity of 11 (exceeds 7 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 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 parse has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
                    Open

                    function parse(scale, input) {
                      if (isNullOrUndef(input)) {
                        return null;
                      }
                    
                    
                    Severity: Minor
                    Found in src/scales/scale.time.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 updateElements has a Cognitive Complexity of 11 (exceeds 7 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 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 binarySearch has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
                    Open

                    function binarySearch(metaset, axis, value, intersect) {
                      const {controller, data, _sorted} = metaset;
                      const iScale = controller._cachedMeta.iScale;
                      if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {
                        const lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;
                    Severity: Minor
                    Found in src/core/core.interaction.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 initCanvas has a Cognitive Complexity of 11 (exceeds 7 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 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

                    Severity
                    Category
                    Status
                    Source
                    Language