Showing 32 of 32 total issues
Use lambda-case Open
Open
A.withText "HalmaDirection" $ \text ->
case text of
"N" -> pure North
"NE" -> pure Northeast
"SE" -> pure Southeast
- Read upRead up
- Exclude checks
Found
\ text ->
case text of
"N" -> pure North
"NE" -> pure Northeast
"SE" -> pure Southeast
"S" -> pure South
"SW" -> pure Southwest
"NW" -> pure Northwest
_ -> fail
"expected a Halma direction (one of N, NE, SE, S, SW, NW)"
Perhaps
\case
"N" -> pure North
"NE" -> pure Northeast
"SE" -> pure Southeast
"S" -> pure South
"SW" -> pure Southwest
"NW" -> pure Northwest
_ -> fail
"expected a Halma direction (one of N, NE, SE, S, SW, NW)"
Use section Open
Open
in sendI18nMsg (flip hlAIMove moveByAi)
- Read upRead up
- Exclude checks
Found
(flip hlAIMove moveByAi)
Perhaps
(`hlAIMove` moveByAi)
Reduce duplication Open
Open
let
match' = match { matchCurrentGame = Just game' }
- Read upRead up
- Exclude checks
Found
let match' = match{matchCurrentGame = Just game'}
modify $ \ chat -> chat{hcMatchState = MatchRunning match'}
sendMatchState
Perhaps
Combine with halma-telegram-bot/src/Game/Halma/TelegramBot/Controller.hs:228:7
Use newtype instead of data Open
Open
data TargetModifier
= TargetModifier
{ _unTargetModifier :: Int
} deriving (Show, Eq, Ord)
- Read upRead up
- Exclude checks
Found
data TargetModifier
= TargetModifier {_unTargetModifier :: Int}
deriving (Show, Eq, Ord)
Perhaps
newtype TargetModifier
= TargetModifier {_unTargetModifier :: Int}
deriving (Show, Eq, Ord)
Applying this change:
- decreases laziness
Use lambda-case Open
Open
A.withText "MoveRestriction" $ \text ->
case text of
"allowed" -> pure Allowed
"temporarily" -> pure Temporarily
"forbidden" -> pure Forbidden
- Read upRead up
- Exclude checks
Found
\ text ->
case text of
"allowed" -> pure Allowed
"temporarily" -> pure Temporarily
"forbidden" -> pure Forbidden
_ -> fail "expected 'allowed', 'temporarily' or 'forbidden'"
Perhaps
\case
"allowed" -> pure Allowed
"temporarily" -> pure Temporarily
"forbidden" -> pure Forbidden
_ -> fail "expected 'allowed', 'temporarily' or 'forbidden'"
Applying this change:
- may require
{-# LANGUAGE LambdaCase #-}
adding to the top of the file
Use String Open
Open
pieceNumberToChars :: PieceNumber -> [Char]
- Read upRead up
- Exclude checks
Found
PieceNumber -> [Char]
Perhaps
PieceNumber -> String
Use section Open
Open
sendI18nMsg (flip hlUnrecognizedCmdMsg call)
- Read upRead up
- Exclude checks
Found
(flip hlUnrecognizedCmdMsg call)
Perhaps
(`hlUnrecognizedCmdMsg` call)
Use section Open
Open
] ++ map (flip button ButtonInactive) ["Four Players", "Five Players", "Six Players"]
- Read upRead up
- Exclude checks
Found
(flip button ButtonInactive)
Perhaps
(`button` ButtonInactive)
Redundant $ Open
Open
, map (\(numStr, players') -> button (numStr ++ " Players") (configButtonAction (playersOnLargeGrid players'))) $
[ ("Two", TwoPlayers () ())
, ("Three", ThreePlayers () () ())
, ("Four", FourPlayers () () () ())
, ("Five", FivePlayers () () () () ())
- Read upRead up
- Exclude checks
Found
map
(\ (numStr, players') ->
button (numStr ++ " Players")
(configButtonAction (playersOnLargeGrid players')))
$
[("Two", TwoPlayers () ()), ("Three", ThreePlayers () () ()),
("Four", FourPlayers () () () ()),
("Five", FivePlayers () () () () ()),
("Six", SixPlayers () () () () () ())]
Perhaps
map
(\ (numStr, players') ->
button (numStr ++ " Players")
(configButtonAction (playersOnLargeGrid players')))
[("Two", TwoPlayers () ()), ("Three", ThreePlayers () () ()),
("Four", FourPlayers () () () ()),
("Five", FivePlayers () () () () ()),
("Six", SixPlayers () () () () () ())]
Use section Open
Open
sendI18nMsg (flip hlNotYourTurn notYourTurnInfo)
- Read upRead up
- Exclude checks
Found
(flip hlNotYourTurn notYourTurnInfo)
Perhaps
(`hlNotYourTurn` notYourTurnInfo)
Use guards Open
Open
go (Just (currentMax, bestMove)) (option@(rating, move):options) =
if isWin rating then
option
else if newRating <= currentMax then
go (Just (currentMax, bestMove)) options
- Read upRead up
- Exclude checks
Found
go (Just (currentMax, bestMove)) (option@(rating, move) : options)
= if isWin rating then option else
if newRating <= currentMax then
go (Just (currentMax, bestMove)) options else
if boundReached newRating then (newRating, move) else
go (Just (newRating, move)) options
where newRating = fst $ nextLevel option (Just currentMax)
Perhaps
go (Just (currentMax, bestMove)) (option@(rating, move) : options)
| isWin rating = option
| newRating <= currentMax =
go (Just (currentMax, bestMove)) options
| boundReached newRating = (newRating, move)
| otherwise = go (Just (newRating, move)) options
where newRating = fst $ nextLevel option (Just currentMax)
Use section Open
Open
sendI18nMsg (flip hlCantUndo Nothing)
- Read upRead up
- Exclude checks
Found
(flip hlCantUndo Nothing)
Perhaps
(`hlCantUndo` Nothing)