tom-weatherhead/thaw-tic-tac-toe-engine

View on GitHub

Showing 16 of 16 total issues

Function isVictory has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    isVictory (player, row, column) {
        // 1) Check the specified row.
        var victory = true;

        for (var column2 = 0; column2 < this.boardWidth; ++column2) {
Severity: Minor
Found in src/engine.js - 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 findBestMove has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    findBestMove (player, ply, bestUncleRecursiveScore) {    // For alpha-beta pruning.
        var returnBestCoordinates = ply === this.maxPly;
        let opponent;

        if (player === 'X') {
Severity: Minor
Found in src/engine.js - 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

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

    {
        name: 'VictoryTest2',
        // O . .
        // . O X
        // . X .
Severity: Major
Found in src/test_descriptors.js and 2 other locations - About 4 hrs to fix
src/test_descriptors.js on lines 35..50
src/test_descriptors.js on lines 99..114

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

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 3 locations. Consider refactoring.
Open

    {
        name: 'SmokeTest01ImmediateVictory',
        // X . X
        // . . .
        // O . O
Severity: Major
Found in src/test_descriptors.js and 2 other locations - About 4 hrs to fix
src/test_descriptors.js on lines 67..82
src/test_descriptors.js on lines 99..114

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

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 3 locations. Consider refactoring.
Open

    {
        name: 'VictoryTest4',
        // . X .    X X .    X X O    X X O
        // . . . -> . . . -> . . . -> . X .
        // O . .    O . .    O . .    O . .
Severity: Major
Found in src/test_descriptors.js and 2 other locations - About 4 hrs to fix
src/test_descriptors.js on lines 35..50
src/test_descriptors.js on lines 67..82

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

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

    {
        name: 'VictoryTest5',
        // X O .
        // . . .
        // . . .
Severity: Major
Found in src/test_descriptors.js and 1 other location - About 3 hrs to fix
src/test_descriptors.js on lines 83..98

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

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

    {
        name: 'VictoryTest3',
        // X . .
        // . . .
        // . O .
Severity: Major
Found in src/test_descriptors.js and 1 other location - About 3 hrs to fix
src/test_descriptors.js on lines 115..130

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

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

Function getNumOpenLines has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    getNumOpenLines (opponent) {
        var numOpenLines = this.boardWidth + this.boardHeight + (this.boardIsSquare ? 2 : 0);
        let row;
        let column;

Severity: Minor
Found in src/engine.js - About 3 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 findBestMove has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    findBestMove (player, ply, bestUncleRecursiveScore) {    // For alpha-beta pruning.
        var returnBestCoordinates = ply === this.maxPly;
        let opponent;

        if (player === 'X') {
Severity: Major
Found in src/engine.js - About 2 hrs to fix

    Function isVictory has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        isVictory (player, row, column) {
            // 1) Check the specified row.
            var victory = true;
    
            for (var column2 = 0; column2 < this.boardWidth; ++column2) {
    Severity: Minor
    Found in src/engine.js - About 1 hr to fix

      Function getNumOpenLines has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getNumOpenLines (opponent) {
              var numOpenLines = this.boardWidth + this.boardHeight + (this.boardIsSquare ? 2 : 0);
              let row;
              let column;
      
      
      Severity: Minor
      Found in src/engine.js - About 1 hr to fix

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

                for (column = 0; column < this.boardWidth; ++column) {
        
                    for (row = 0; row < this.boardHeight; ++row) {
        
                        if (this.getSquareAt(row, column) === opponent) {
        Severity: Major
        Found in src/engine.js and 1 other location - About 1 hr to fix
        src/engine.js on lines 190..199

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

        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

                for (var row2 = 0; row2 < this.boardHeight; ++row2) {
        
                    if (this.getSquareAt(row2, column) !== player) {
                        victory = false;
                        break;
        Severity: Major
        Found in src/engine.js and 1 other location - About 1 hr to fix
        src/engine.js on lines 78..84

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

        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

                for (row = 0; row < this.boardHeight; ++row) {
        
                    for (column = 0; column < this.boardWidth; ++column) {
        
                        if (this.getSquareAt(row, column) === opponent) {
        Severity: Major
        Found in src/engine.js and 1 other location - About 1 hr to fix
        src/engine.js on lines 203..212

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

        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

                for (var column2 = 0; column2 < this.boardWidth; ++column2) {
        
                    if (this.getSquareAt(row, column2) !== player) {
                        victory = false;
                        break;
        Severity: Major
        Found in src/engine.js and 1 other location - About 1 hr to fix
        src/engine.js on lines 93..99

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

        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

        Avoid too many return statements within this function.
        Open

                return false;
        Severity: Major
        Found in src/engine.js - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language