chartjs/Chart.js

View on GitHub
src/helpers/helpers.segment.js

Summary

Maintainability
C
1 day
Test Coverage

Function doSplitByStyles has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
Open

function doSplitByStyles(line, segments, points, segmentOptions) {
  const chartContext = line._chart.getContext();
  const baseStyle = readStyle(line.options);
  const {_datasetIndex: datasetIndex, options: {spanGaps}} = line;
  const count = points.length;
Severity: Minor
Found in src/helpers/helpers.segment.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 doSplitByStyles has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function doSplitByStyles(line, segments, points, segmentOptions) {
  const chartContext = line._chart.getContext();
  const baseStyle = readStyle(line.options);
  const {_datasetIndex: datasetIndex, options: {spanGaps}} = line;
  const count = points.length;
Severity: Major
Found in src/helpers/helpers.segment.js - About 2 hrs to fix

    File helpers.segment.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {_angleBetween, _angleDiff, _isBetween, _normalizeAngle} from './helpers.math.js';
    import {createContext} from './helpers.options.js';
    import {isPatternOrGradient} from './helpers.color.js';
    
    /**
    Severity: Minor
    Found in src/helpers/helpers.segment.js - About 2 hrs to fix

      Function _boundSegment has a Cognitive Complexity of 17 (exceeds 7 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

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

      function solidSegments(points, start, max, loop) {
        const count = points.length;
        const result = [];
        let last = start;
        let prev = points[start];
      Severity: Minor
      Found in src/helpers/helpers.segment.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 _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

        There are no issues that match your filters.

        Category
        Status