Skip to content

Commit 99b7cdd

Browse files
committed
Codacity review
1 parent f94af5e commit 99b7cdd

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

js/chess.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const SAN = {
4848
CAPTURE: "x",
4949
CHECK: "+",
5050
CHECKMATE: "#"
51-
}
51+
};
5252
const Action = {
5353
MOVE: 1,
5454
PLAYER_CAPTURE: 2,
@@ -611,7 +611,7 @@ class Chess {
611611
this.moves--;
612612
this.turn({ change: true });
613613

614-
const [from, to] = [this.get({square:`${move.from.file}${move.from.rank}`}),this.get({square:`${move.to.file}${move.to.rank}`})]
614+
const [from, to] = [this.get({square:`${move.from.file}${move.from.rank}`}),this.get({square:`${move.to.file}${move.to.rank}`})];
615615

616616
this.get({square:`${move.from.file}${move.from.rank}`}).piece = to.piece;
617617

@@ -656,7 +656,7 @@ class Chess {
656656

657657
// return a copy of the board
658658
copy() {
659-
return this._board.map(r => r.slice().map(f=>Object.assign(Object.create(Object.getPrototypeOf(f)),f)));
659+
return this._board.map(r => r.slice().map(f => Object.assign(Object.create(Object.getPrototypeOf(f)),f)));
660660
}
661661

662662
// returns true if a square exists, else false
@@ -732,7 +732,7 @@ class Chess {
732732
else if (ambiguous.filter(a => a.rank === from.rank).length === 0)
733733
fromCoord = from.rank;
734734
else
735-
fromCoord = `${from.file}${from.rank}`
735+
fromCoord = `${from.file}${from.rank}`;
736736
}
737737

738738
if (this._move(from, to) === Action.INVALID_ACTION)
@@ -741,10 +741,10 @@ class Chess {
741741
if (this.checkmate().white || this.checkmate().black)
742742
check = "#";
743743
else if (this.check().length > 0)
744-
check = "+"
744+
check = "+";
745745
this.undo();
746746

747-
return `${pieceName}${fromCoord}${capture}${to.file}${to.rank}${check}`
747+
return `${pieceName}${fromCoord}${capture}${to.file}${to.rank}${check}`;
748748
}
749749
}
750750

test/game.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("Game tests", () => {
127127
chess.undo();
128128
let enPassant = chess.fen() === "rnbqkbnr/pp1ppppp/8/2pP4/8/8/PPP1PPPP/RNBQKBNR";
129129
chess.undo();
130-
let two_moves = chess.fen() == "rnbqkbnr/pppppppp/8/3P4/8/8/PPP1PPPP/RNBQKBNR";
130+
let twoMoves = chess.fen() === "rnbqkbnr/pppppppp/8/3P4/8/8/PPP1PPPP/RNBQKBNR";
131131

132132
chess = new Chess({fen:"r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R"});
133133
chess.move({from:"e1", to: "a1"});
@@ -147,9 +147,9 @@ describe("Game tests", () => {
147147
chess = new Chess({fen:"r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R"});
148148
chess.move({from:"e8", to: "h8"});
149149
chess.undo();
150-
let blackCastleKing = chess.fen() === "r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R"
150+
let blackCastleKing = chess.fen() === "r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R";
151151

152-
assert (start && enPassant && two_moves && whiteCastleQueen && whiteCastleKing && blackCastleQueen && blackCastleKing);
152+
assert (start && enPassant && twoMoves && whiteCastleQueen && whiteCastleKing && blackCastleQueen && blackCastleKing);
153153

154154
done();
155155
} catch (e) {

0 commit comments

Comments
 (0)