TargetProcess/tauCharts

View on GitHub
src/utils/path/interpolators/smooth.ts

Summary

Maintainability
D
2 days
Test Coverage

Function getCubicSpline has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

function getCubicSpline(points: Point[], limited: boolean): Point[] {
    if (points.length < 2) {
        return points.slice(0);
    }
    if (points.length === 2) {
Severity: Minor
Found in src/utils/path/interpolators/smooth.ts - About 6 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 getCubicSpline has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getCubicSpline(points: Point[], limited: boolean): Point[] {
    if (points.length < 2) {
        return points.slice(0);
    }
    if (points.length === 2) {
Severity: Major
Found in src/utils/path/interpolators/smooth.ts - About 4 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        if ((p1.y - c0.y) * (c3.y - p1.y) <= 0) {
                            tan = 0;
                        } else {
                            if (p1.y > c0.y === c2y > c3.y) {
                                kl = ((c3.y - p1.y) / (c2y - p1.y));
    Severity: Major
    Found in src/utils/path/interpolators/smooth.ts - About 45 mins to fix

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

                      qy = (p1.y - c0.y * (1 - qt) * (1 - qt) - c3.y * qt * qt) / (2 * (1 - qt) * qt);
      Severity: Major
      Found in src/utils/path/interpolators/smooth.ts and 1 other location - About 1 hr to fix
      src/utils/path/interpolators/smooth.ts on lines 87..87

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

      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

                      qx = (p1.x - c0.x * (1 - qt) * (1 - qt) - c3.x * qt * qt) / (2 * (1 - qt) * qt);
      Severity: Major
      Found in src/utils/path/interpolators/smooth.ts and 1 other location - About 1 hr to fix
      src/utils/path/interpolators/smooth.ts on lines 88..88

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

      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

                  {
                      x: interpolate(points[0].x, points[1].x, 2 / 3),
                      y: interpolate(points[0].y, points[1].y, 2 / 3)
                  },
      Severity: Major
      Found in src/utils/path/interpolators/smooth.ts and 1 other location - About 1 hr to fix
      src/utils/path/interpolators/smooth.ts on lines 28..31

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

      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

                  {
                      x: interpolate(points[0].x, points[1].x, 1 / 3),
                      y: interpolate(points[0].y, points[1].y, 1 / 3)
                  },
      Severity: Major
      Found in src/utils/path/interpolators/smooth.ts and 1 other location - About 1 hr to fix
      src/utils/path/interpolators/smooth.ts on lines 32..35

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

      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

      Forbidden 'var' keyword, use 'let' or 'const' instead
      Open

          var result = curve.slice(0);

      Rule: no-var-keyword

      Disallows usage of the var keyword.

      Use let or const instead.

      Rationale

      Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

      Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

      Notes
      • Has Fix

      Config

      Not configurable.

      Examples
      "no-var-keyword": true

      For more information see this page.

      Identifier 'curve' is never reassigned; use 'const' instead of 'var'.
      Open

          var curve: Point[] = new Array((points.length - 1) * 3 + 1);

      Rule: prefer-const

      Requires that variable declarations use const instead of let and var if possible.

      If a variable is only assigned to once when it is declared, it should be declared using 'const'

      Notes
      • Has Fix

      Config

      An optional object containing the property "destructuring" with two possible values:

      • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
      • "all" - Only warns if all variables in destructuring can be const.
      Examples
      "prefer-const": true
      "prefer-const": true,[object Object]
      Schema
      {
        "type": "object",
        "properties": {
          "destructuring": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          }
        }
      }

      For more information see this page.

      Forbidden 'var' keyword, use 'let' or 'const' instead
      Open

          var c0, p1, c3, c1x, c1y, c2x, c2y, qx, qy, qt, tan, dx1, dx2, kl;

      Rule: no-var-keyword

      Disallows usage of the var keyword.

      Use let or const instead.

      Rationale

      Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

      Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

      Notes
      • Has Fix

      Config

      Not configurable.

      Examples
      "no-var-keyword": true

      For more information see this page.

      Forbidden 'var' keyword, use 'let' or 'const' instead
      Open

          var curve: Point[] = new Array((points.length - 1) * 3 + 1);

      Rule: no-var-keyword

      Disallows usage of the var keyword.

      Use let or const instead.

      Rationale

      Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

      Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

      Notes
      • Has Fix

      Config

      Not configurable.

      Examples
      "no-var-keyword": true

      For more information see this page.

      Multiple variable declarations in the same statement are forbidden
      Open

          var c0, p1, c3, c1x, c1y, c2x, c2y, qx, qy, qt, tan, dx1, dx2, kl;

      Rule: one-variable-per-declaration

      Disallows multiple variable definitions in the same declaration statement.

      Config

      One argument may be optionally provided:

      • ignore-for-loop allows multiple variable definitions in a for loop declaration.
      Examples
      "one-variable-per-declaration": true
      "one-variable-per-declaration": true,ignore-for-loop
      Schema
      {
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "ignore-for-loop"
          ]
        },
        "minLength": 0,
        "maxLength": 1
      }

      For more information see this page.

      Forbidden 'var' keyword, use 'let' or 'const' instead
      Open

          for (var j = 0; j < 3; j++) {

      Rule: no-var-keyword

      Disallows usage of the var keyword.

      Use let or const instead.

      Rationale

      Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

      Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

      Notes
      • Has Fix

      Config

      Not configurable.

      Examples
      "no-var-keyword": true

      For more information see this page.

      Forbidden 'var' keyword, use 'let' or 'const' instead
      Open

          for (var i = 0; i < points.length; i++) {

      Rule: no-var-keyword

      Disallows usage of the var keyword.

      Use let or const instead.

      Rationale

      Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

      Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

      Notes
      • Has Fix

      Config

      Not configurable.

      Examples
      "no-var-keyword": true

      For more information see this page.

      There are no issues that match your filters.

      Category
      Status