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) {
- Read upRead up
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') {
- Read upRead up
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;
- Read upRead up
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') {
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) {
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;
Avoid too many return
statements within this function. Open
return false;