Remove partial head function from src/ShellCheck/Formatter/TTY.hs
This commit is contained in:
parent
a9e7bf1950
commit
4c1d9171b2
|
@ -31,9 +31,9 @@ import Data.Ord
|
||||||
import Data.IORef
|
import Data.IORef
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import GHC.Exts
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Info
|
import System.Info
|
||||||
|
import qualified Data.List.NonEmpty as NE
|
||||||
|
|
||||||
wikiLink = "https://www.shellcheck.net/wiki/"
|
wikiLink = "https://www.shellcheck.net/wiki/"
|
||||||
|
|
||||||
|
@ -117,19 +117,19 @@ outputResult options ref result sys = do
|
||||||
color <- getColorFunc $ foColorOption options
|
color <- getColorFunc $ foColorOption options
|
||||||
let comments = crComments result
|
let comments = crComments result
|
||||||
appendComments ref comments (fromIntegral $ foWikiLinkCount options)
|
appendComments ref comments (fromIntegral $ foWikiLinkCount options)
|
||||||
let fileGroups = groupWith sourceFile comments
|
let fileGroups = NE.groupWith sourceFile comments
|
||||||
mapM_ (outputForFile color sys) fileGroups
|
mapM_ (outputForFile color sys) fileGroups
|
||||||
|
|
||||||
outputForFile color sys comments = do
|
outputForFile color sys comments = do
|
||||||
let fileName = sourceFile (head comments)
|
let fileName = sourceFile (NE.head comments)
|
||||||
result <- siReadFile sys (Just True) fileName
|
result <- siReadFile sys (Just True) fileName
|
||||||
let contents = either (const "") id result
|
let contents = either (const "") id result
|
||||||
let fileLinesList = lines contents
|
let fileLinesList = lines contents
|
||||||
let lineCount = length fileLinesList
|
let lineCount = length fileLinesList
|
||||||
let fileLines = listArray (1, lineCount) fileLinesList
|
let fileLines = listArray (1, lineCount) fileLinesList
|
||||||
let groups = groupWith lineNo comments
|
let groups = NE.groupWith lineNo comments
|
||||||
forM_ groups $ \commentsForLine -> do
|
forM_ groups $ \commentsForLine -> do
|
||||||
let lineNum = fromIntegral $ lineNo (head commentsForLine)
|
let lineNum = fromIntegral $ lineNo (NE.head commentsForLine)
|
||||||
let line = if lineNum < 1 || lineNum > lineCount
|
let line = if lineNum < 1 || lineNum > lineCount
|
||||||
then ""
|
then ""
|
||||||
else fileLines ! fromIntegral lineNum
|
else fileLines ! fromIntegral lineNum
|
||||||
|
@ -139,7 +139,7 @@ outputForFile color sys comments = do
|
||||||
putStrLn (color "source" line)
|
putStrLn (color "source" line)
|
||||||
forM_ commentsForLine $ \c -> putStrLn $ color (severityText c) $ cuteIndent c
|
forM_ commentsForLine $ \c -> putStrLn $ color (severityText c) $ cuteIndent c
|
||||||
putStrLn ""
|
putStrLn ""
|
||||||
showFixedString color commentsForLine (fromIntegral lineNum) fileLines
|
showFixedString color (toList commentsForLine) (fromIntegral lineNum) fileLines
|
||||||
|
|
||||||
-- Pick out only the lines necessary to show a fix in action
|
-- Pick out only the lines necessary to show a fix in action
|
||||||
sliceFile :: Fix -> Array Int String -> (Fix, Array Int String)
|
sliceFile :: Fix -> Array Int String -> (Fix, Array Int String)
|
||||||
|
|
Loading…
Reference in New Issue