chartjs/Chart.js

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

Summary

Maintainability
A
2 hrs
Test Coverage

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 getNearestItems has 6 arguments (exceeds 5 allowed). Consider refactoring.
Open

function getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
Severity: Minor
Found in src/core/core.interaction.js - About 35 mins to fix

    Function getNearestCartesianItems has 6 arguments (exceeds 5 allowed). Consider refactoring.
    Open

    function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
    Severity: Minor
    Found in src/core/core.interaction.js - About 35 mins to fix

      Function getNearestCartesianItems has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
      Open

      function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
        let items = [];
        const distanceMetric = getDistanceMetricForAxis(axis);
        let minDistance = Number.POSITIVE_INFINITY;
      
      
      Severity: Minor
      Found in src/core/core.interaction.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

      There are no issues that match your filters.

      Category
      Status