CSNW/d3.compose

View on GitHub
src/charts/labels.js

Summary

Maintainability
B
5 hrs
Test Coverage

Function getProps has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getProps(props, element, d, i, j) {
  // Load values for position, offset, padding, anchor, and alignment
  var position = props.position;
  var offset = props.offset;
  var padding = props.padding;
Severity: Minor
Found in src/charts/labels.js - About 1 hr to fix

    Function getProps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getProps(props, element, d, i, j) {
      // Load values for position, offset, padding, anchor, and alignment
      var position = props.position;
      var offset = props.offset;
      var padding = props.padding;
    Severity: Minor
    Found in src/charts/labels.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 calculateLabelLayout has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function calculateLabelLayout(textElement, x, y, props) {
      var textBounds = textElement.getBBox();
      var width = textBounds.width + (2 * props.padding);
      var height = textBounds.height + (2 * props.padding);
      var layout = {x: x, y: y, width: width, height: height};
    Severity: Minor
    Found in src/charts/labels.js - About 1 hr to fix

      Function getProps has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      export function getProps(props, element, d, i, j) {
      Severity: Minor
      Found in src/charts/labels.js - About 35 mins to fix

        Function prepareLabel has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export function prepareLabel(element, props, d, i, j) {
        Severity: Minor
        Found in src/charts/labels.js - About 35 mins to fix

          Function getText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          export function getText(format, yValue, d, i) {
            var value;
            if (d && !isUndefined(d.label)) {
              value = d.label;
            } else if (d && !isUndefined(d[ORIGINAL_Y])) {
          Severity: Minor
          Found in src/charts/labels.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