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

View on GitHub

Showing 7 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

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

        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