Fix bug in command handling
'f' means FalsePositive, 'i' means Intentional
This commit is contained in:
parent
8c7bf983d9
commit
db487e3783
1 changed files with 12 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ import System.Environment (getArgs)
|
|||
import System.IO
|
||||
import System.Exit
|
||||
import System.Console.GetOpt
|
||||
-- import System.Console.Haskeline
|
||||
import System.Directory (doesFileExist)
|
||||
import System.Posix.Files
|
||||
import Control.Monad
|
||||
|
|
@ -30,7 +31,7 @@ import Annotator.Rule
|
|||
import Annotator.Annotation
|
||||
|
||||
version :: Vsn.Version
|
||||
version = Vsn.makeVersion [0,0,5,0]
|
||||
version = Vsn.makeVersion [0,0,5,1]
|
||||
|
||||
type App a = ReaderT Options IO a
|
||||
|
||||
|
|
@ -218,8 +219,7 @@ genericMain file = do
|
|||
opts <- ask
|
||||
verbose Chatty $ show opts
|
||||
liftIO $ hSetBuffering stdin NoBuffering
|
||||
violations' <- liftIO $ filter (isRelevant (onlyNewest opts)) . parseViolations <$> readFile file
|
||||
_ <- liftIO $ evaluate (length violations') -- ensure file is completely read
|
||||
violations' <- liftIO $ filter (isRelevant (onlyNewest opts)) . parseViolations <$> readFileStrict file
|
||||
|
||||
let mviolations = NE.nonEmpty violations'
|
||||
|
||||
|
|
@ -264,8 +264,7 @@ handleViolations violations = do
|
|||
|
||||
verbose Chatty $ show violations
|
||||
|
||||
content <- liftIO $ readFile fname
|
||||
_ <- liftIO $ evaluate (length content) -- ensure file is completely read
|
||||
content <- liftIO $ readFileStrict fname
|
||||
|
||||
let numberedContent = zip [1..] . lines $ content
|
||||
|
||||
|
|
@ -311,10 +310,10 @@ getUserChoice Violation{..} = do
|
|||
pure $ Annotate (ToDo rule)
|
||||
'i' -> do
|
||||
excuse <- getExcuse
|
||||
pure $ Annotate (FalsePositive rule excuse)
|
||||
pure $ Annotate (Intentional rule excuse)
|
||||
'f' -> do
|
||||
excuse <- getExcuse
|
||||
pure $ Annotate (Intentional rule excuse)
|
||||
pure $ Annotate (FalsePositive rule excuse)
|
||||
'q' -> pure Abort
|
||||
'?' -> do
|
||||
putStrLn $ unlines [ "t - add TODO marker to fix this issue"
|
||||
|
|
@ -417,3 +416,9 @@ getContext :: Int -> [(Int, String)] -> [(Int, String)] -> [(Int, String)]
|
|||
getContext n before after = before' ++ after'
|
||||
where before' = reverse . take n . reverse $ before
|
||||
after' = take (n+1) after
|
||||
|
||||
readFileStrict :: FilePath -> IO String
|
||||
readFileStrict fname = do
|
||||
content <- readFile fname
|
||||
void $ evaluate (length content)
|
||||
pure content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue