chartjs/Chart.js

View on GitHub
src/controllers/controller.bar.js

Summary

Maintainability
D
2 days
Test Coverage

File controller.bar.js has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import DatasetController from '../core/core.datasetController.js';
import {
  _arrayUnique, isArray, isNullOrUndef,
  valueOrDefault, resolveObjectKey, sign, defined
} from '../helpers/index.js';
Severity: Minor
Found in src/controllers/controller.bar.js - About 7 hrs to fix

    Function _calculateBarValuePixels has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _calculateBarValuePixels(index) {
        const {_cachedMeta: {vScale, _stacked, index: datasetIndex}, options: {base: baseValue, minBarLength}} = this;
        const actualBase = baseValue || 0;
        const parsed = this.getParsed(index);
        const custom = parsed._custom;
    Severity: Major
    Found in src/controllers/controller.bar.js - About 2 hrs to fix

      Function updateElements has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
      Open

        updateElements(bars, start, count, mode) {
          const reset = mode === 'reset';
          const {index, _cachedMeta: {vScale}} = this;
          const base = vScale.getBasePixel();
          const horizontal = vScale.isHorizontal();
      Severity: Minor
      Found in src/controllers/controller.bar.js - About 1 hr to fix

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

        _getStacks(last, dataIndex) {
          const {iScale} = this._cachedMeta;
          const metasets = iScale.getMatchingVisibleMetas(this._type)
            .filter(meta => meta.controller.options.grouped);
          const stacked = iScale.options.stacked;
      Severity: Minor
      Found in src/controllers/controller.bar.js - About 1 hr to fix

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

        _calculateBarValuePixels(index) {
          const {_cachedMeta: {vScale, _stacked, index: datasetIndex}, options: {base: baseValue, minBarLength}} = this;
          const actualBase = baseValue || 0;
          const parsed = this.getParsed(index);
          const custom = parsed._custom;
      Severity: Minor
      Found in src/controllers/controller.bar.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 _getStacks has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _getStacks(last, dataIndex) {
          const {iScale} = this._cachedMeta;
          const metasets = iScale.getMatchingVisibleMetas(this._type)
            .filter(meta => meta.controller.options.grouped);
          const stacked = iScale.options.stacked;
      Severity: Minor
      Found in src/controllers/controller.bar.js - About 1 hr to fix

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

          updateElements(bars, start, count, mode) {
            const reset = mode === 'reset';
            const {index, _cachedMeta: {vScale}} = this;
            const base = vScale.getBasePixel();
            const horizontal = vScale.isHorizontal();
        Severity: Minor
        Found in src/controllers/controller.bar.js - About 1 hr to fix

          Function setBorderSkipped has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          function setBorderSkipped(properties, options, stack, index) {
            let edge = options.borderSkipped;
            const res = {};
          
            if (!edge) {
          Severity: Minor
          Found in src/controllers/controller.bar.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

          Function _calculateBarIndexPixels has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

            _calculateBarIndexPixels(index, ruler) {
              const scale = ruler.scale;
              const options = this.options;
              const skipNull = options.skipNull;
              const maxBarThickness = valueOrDefault(options.maxBarThickness, Infinity);
          Severity: Minor
          Found in src/controllers/controller.bar.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

          Function computeMinSampleSize has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          function computeMinSampleSize(meta) {
            const scale = meta.iScale;
            const values = getAllScaleValues(scale, meta.type);
            let min = scale._length;
            let i, ilen, curr, prev;
          Severity: Minor
          Found in src/controllers/controller.bar.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

          There are no issues that match your filters.

          Category
          Status