Hi-Level/three-csg

View on GitHub

Showing 52 of 52 total issues

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

    if (front.length) {
      if (!this.front) this.front = new Node();
      this.front.build(front);
    }
Severity: Minor
Found in src/Node.ts and 1 other location - About 45 mins to fix
src/Node.ts on lines 102..105

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

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

    if (back.length) {
      if (!this.back) this.back = new Node();
      this.back.build(back);
    }
Severity: Minor
Found in src/Node.ts and 1 other location - About 45 mins to fix
src/Node.ts on lines 98..101

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

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

unused expression, expected an assignment or function call
Open

    uvs && geom.setAttribute('uv', new BufferAttribute(uvs.array, 2));
Severity: Minor
Found in src/CSG.ts by tslint

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

For more information see this page.

Multiple variable declarations in the same statement are forbidden
Open

    const front = [],
      back = [];
Severity: Minor
Found in src/Node.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

      index = new Uint16Array((posattr.array.length / posattr.itemSize) | 0);
Severity: Minor
Found in src/CSG.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.

unused expression, expected an assignment or function call
Open

    this.plane && this.plane.flip();
Severity: Minor
Found in src/Node.ts by tslint

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

For more information see this page.

unused expression, expected an assignment or function call
Open

    this.back && this.back.invert();
Severity: Minor
Found in src/Node.ts by tslint

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

For more information see this page.

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.

Multiple variable declarations in the same statement are forbidden
Open

const box = new THREE.Mesh(
    new THREE.BoxGeometry(2, 2, 2),
    new THREE.MeshNormalMaterial()
  ),
  sphere = new THREE.Mesh(
Severity: Minor
Found in example/example.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.

!= 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 bx = b.x,
      by = b.y,
      bz = b.z;
Severity: Minor
Found in src/Vector.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

    result.position.x += -5 + ((i / 3) | 0) * 10;
Severity: Minor
Found in example/example.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.

unused expression, expected an assignment or function call
Open

    this.front && this.front.invert();
Severity: Minor
Found in src/Node.ts by tslint

Rule: no-unused-expression

Disallows unused expression statements.

Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

Rationale

Detects potential errors where an assignment or function call was intended.

Config

Three arguments may be optionally provided:

  • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
  • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
  • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
Examples
"no-unused-expression": true
"no-unused-expression": true,allow-fast-null-checks
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-fast-null-checks",
      "allow-new",
      "allow-tagged-template"
    ]
  },
  "minLength": 0,
  "maxLength": 3
}

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.

Multiple variable declarations in the same statement are forbidden
Open

    const ax = a.x,
      ay = a.y,
      az = a.z;
Severity: Minor
Found in src/Vector.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 < polygons.length; i++) {
Severity: Minor
Found in src/Node.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.

Severity
Category
Status
Source
Language