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.IO
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
|
-- import System.Console.Haskeline
|
||||||
import System.Directory (doesFileExist)
|
import System.Directory (doesFileExist)
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
|
@ -30,7 +31,7 @@ import Annotator.Rule
|
||||||
import Annotator.Annotation
|
import Annotator.Annotation
|
||||||
|
|
||||||
version :: Vsn.Version
|
version :: Vsn.Version
|
||||||
version = Vsn.makeVersion [0,0,5,0]
|
version = Vsn.makeVersion [0,0,5,1]
|
||||||
|
|
||||||
type App a = ReaderT Options IO a
|
type App a = ReaderT Options IO a
|
||||||
|
|
||||||
|
|
@ -218,8 +219,7 @@ genericMain file = do
|
||||||
opts <- ask
|
opts <- ask
|
||||||
verbose Chatty $ show opts
|
verbose Chatty $ show opts
|
||||||
liftIO $ hSetBuffering stdin NoBuffering
|
liftIO $ hSetBuffering stdin NoBuffering
|
||||||
violations' <- liftIO $ filter (isRelevant (onlyNewest opts)) . parseViolations <$> readFile file
|
violations' <- liftIO $ filter (isRelevant (onlyNewest opts)) . parseViolations <$> readFileStrict file
|
||||||
_ <- liftIO $ evaluate (length violations') -- ensure file is completely read
|
|
||||||
|
|
||||||
let mviolations = NE.nonEmpty violations'
|
let mviolations = NE.nonEmpty violations'
|
||||||
|
|
||||||
|
|
@ -264,8 +264,7 @@ handleViolations violations = do
|
||||||
|
|
||||||
verbose Chatty $ show violations
|
verbose Chatty $ show violations
|
||||||
|
|
||||||
content <- liftIO $ readFile fname
|
content <- liftIO $ readFileStrict fname
|
||||||
_ <- liftIO $ evaluate (length content) -- ensure file is completely read
|
|
||||||
|
|
||||||
let numberedContent = zip [1..] . lines $ content
|
let numberedContent = zip [1..] . lines $ content
|
||||||
|
|
||||||
|
|
@ -311,10 +310,10 @@ getUserChoice Violation{..} = do
|
||||||
pure $ Annotate (ToDo rule)
|
pure $ Annotate (ToDo rule)
|
||||||
'i' -> do
|
'i' -> do
|
||||||
excuse <- getExcuse
|
excuse <- getExcuse
|
||||||
pure $ Annotate (FalsePositive rule excuse)
|
pure $ Annotate (Intentional rule excuse)
|
||||||
'f' -> do
|
'f' -> do
|
||||||
excuse <- getExcuse
|
excuse <- getExcuse
|
||||||
pure $ Annotate (Intentional rule excuse)
|
pure $ Annotate (FalsePositive rule excuse)
|
||||||
'q' -> pure Abort
|
'q' -> pure Abort
|
||||||
'?' -> do
|
'?' -> do
|
||||||
putStrLn $ unlines [ "t - add TODO marker to fix this issue"
|
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'
|
getContext n before after = before' ++ after'
|
||||||
where before' = reverse . take n . reverse $ before
|
where before' = reverse . take n . reverse $ before
|
||||||
after' = take (n+1) after
|
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