Skip to content

Commit

Permalink
Fix Swift 3 guard warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nvzqz committed Jul 19, 2016
1 parent 3c44747 commit 4f96a8f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Expand Up @@ -12,6 +12,7 @@ disabled_rules: # rule identifiers to exclude from running
- type_body_length
- function_body_length
- comma
- conditional_binding_cascade

opt_in_rules: # some rules are only opt-in
- empty_count
Expand Down
21 changes: 12 additions & 9 deletions Sources/Game.swift
Expand Up @@ -171,14 +171,17 @@ public final class Game {
#else
let parts = fen.characters.split(" ").map(String.init)
#endif
guard parts.count == 6,
let board = Board(fen: parts[0])
where parts[1].characters.count == 1,
guard
parts.count == 6,
let board = Board(fen: parts[0]),
parts[1].characters.count == 1,
let playerTurn = parts[1].characters.first.flatMap(Color.init),
rights = CastlingRights(string: parts[2]),
halfmoves = UInt(parts[4]),
fullmoves = UInt(parts[5]) where fullmoves > 0
else { return nil }
let rights = CastlingRights(string: parts[2]),
let halfmoves = UInt(parts[4]),
let fullmoves = UInt(parts[5]),
fullmoves > 0 else {
return nil
}
var target: Square? = nil
let targetStr = parts[3]
let targetChars = targetStr.characters
Expand Down Expand Up @@ -335,7 +338,7 @@ public final class Game {

/// The target move location for an en passant.
public var enPassantTarget: Square? {
guard let (move, piece, _, _, _, _) = _moveHistory.last where piece.kind.isPawn else {
guard let (move, piece, _, _, _, _) = _moveHistory.last, piece.kind.isPawn else {
return nil
}
guard abs(move.rankChange) == 2 else {
Expand Down Expand Up @@ -427,7 +430,7 @@ public final class Game {
if considerHalfmoves && halfmoves >= 100 {
return 0
}
guard let piece = board[square] where piece.color == playerTurn else {
guard let piece = board[square], piece.color == playerTurn else {
return 0
}
if kingIsDoubleChecked {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Square.swift
Expand Up @@ -474,7 +474,7 @@ extension Square {

/// Create a square from `file` and `rank`. Returns `nil` if either is `nil`.
public init?(file: File?, rank: Rank?) {
guard let file = file, rank = rank else {
guard let file = file, let rank = rank else {
return nil
}
self.init(file: file, rank: rank)
Expand Down

0 comments on commit 4f96a8f

Please sign in to comment.