Hi-Level/three-csg

View on GitHub
src/Plane.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function splitPolygon has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  splitPolygon(
    polygon: Polygon,
    coplanarFront: Polygon[],
    coplanarBack: Polygon[],
    front: Polygon[],
Severity: Minor
Found in src/Plane.ts - About 4 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 splitPolygon has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  splitPolygon(
    polygon: Polygon,
    coplanarFront: Polygon[],
    coplanarBack: Polygon[],
    front: Polygon[],
Severity: Major
Found in src/Plane.ts - About 2 hrs to fix

    Forbidden bitwise operation
    Open

          polygonType |= type;
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: no-bitwise

    Disallows bitwise operators.

    Specifically, the following bitwise operators are banned: &, &=, |, |=, ^, ^=, <<, <<=, >>, >>=, >>>, >>>=, and ~. This rule does not ban the use of & and | for intersection and union types.

    Rationale

    Bitwise operators are often typos - for example bool1 & bool2 instead of bool1 && bool2. They also can be an indicator of overly clever code which decreases maintainability.

    Config

    Not configurable.

    Examples
    "no-bitwise": true

    For more information see this page.

    Multiple variable declarations in the same statement are forbidden
    Open

              const ti = types[i],
                tj = types[j];
    Severity: Minor
    Found in src/Plane.ts by tslint

    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.

    Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
    Open

        for (let i = 0; i < polygon.vertices.length; i++) {
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: prefer-for-of

    Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.

    Rationale

    A for(... of ...) loop is easier to implement and read when the index is not needed.

    Config

    Not configurable.

    Examples
    "prefer-for-of": true

    For more information see this page.

    != should be !==
    Open

              if (ti != FRONT) b.push(ti != BACK ? vi.clone() : vi);
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: triple-equals

    Requires === and !== in place of == and !=.

    Config

    Two arguments may be optionally provided:

    • "allow-null-check" allows == and != when comparing to null.
    • "allow-undefined-check" allows == and != when comparing to undefined.
    Examples
    "triple-equals": true
    "triple-equals": true,allow-null-check
    "triple-equals": true,allow-undefined-check
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-null-check",
          "allow-undefined-check"
        ]
      },
      "minLength": 0,
      "maxLength": 2
    }

    For more information see this page.

    != should be !==
    Open

              if (ti != FRONT) b.push(ti != BACK ? vi.clone() : vi);
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: triple-equals

    Requires === and !== in place of == and !=.

    Config

    Two arguments may be optionally provided:

    • "allow-null-check" allows == and != when comparing to null.
    • "allow-undefined-check" allows == and != when comparing to undefined.
    Examples
    "triple-equals": true
    "triple-equals": true,allow-null-check
    "triple-equals": true,allow-undefined-check
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-null-check",
          "allow-undefined-check"
        ]
      },
      "minLength": 0,
      "maxLength": 2
    }

    For more information see this page.

    == should be ===
    Open

              if ((ti | tj) == SPANNING) {
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: triple-equals

    Requires === and !== in place of == and !=.

    Config

    Two arguments may be optionally provided:

    • "allow-null-check" allows == and != when comparing to null.
    • "allow-undefined-check" allows == and != when comparing to undefined.
    Examples
    "triple-equals": true
    "triple-equals": true,allow-null-check
    "triple-equals": true,allow-undefined-check
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-null-check",
          "allow-undefined-check"
        ]
      },
      "minLength": 0,
      "maxLength": 2
    }

    For more information see this page.

    Multiple variable declarations in the same statement are forbidden
    Open

              const vi = polygon.vertices[i],
                vj = polygon.vertices[j];
    Severity: Minor
    Found in src/Plane.ts by tslint

    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 bitwise operation
    Open

              if ((ti | tj) == SPANNING) {
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: no-bitwise

    Disallows bitwise operators.

    Specifically, the following bitwise operators are banned: &, &=, |, |=, ^, ^=, <<, <<=, >>, >>=, >>>, >>>=, and ~. This rule does not ban the use of & and | for intersection and union types.

    Rationale

    Bitwise operators are often typos - for example bool1 & bool2 instead of bool1 && bool2. They also can be an indicator of overly clever code which decreases maintainability.

    Config

    Not configurable.

    Examples
    "no-bitwise": true

    For more information see this page.

    != should be !==
    Open

              if (ti != BACK) f.push(vi);
    Severity: Minor
    Found in src/Plane.ts by tslint

    Rule: triple-equals

    Requires === and !== in place of == and !=.

    Config

    Two arguments may be optionally provided:

    • "allow-null-check" allows == and != when comparing to null.
    • "allow-undefined-check" allows == and != when comparing to undefined.
    Examples
    "triple-equals": true
    "triple-equals": true,allow-null-check
    "triple-equals": true,allow-undefined-check
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-null-check",
          "allow-undefined-check"
        ]
      },
      "minLength": 0,
      "maxLength": 2
    }

    For more information see this page.

    Multiple variable declarations in the same statement are forbidden
    Open

            const f = [],
              b = [];
    Severity: Minor
    Found in src/Plane.ts by tslint

    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.

    There are no issues that match your filters.

    Category
    Status