Removed jsoncheck. Use 'shellcheck -f json -' instead
This commit is contained in:
parent
17515ad706
commit
2e13cedc4b
7
Makefile
7
Makefile
|
@ -9,15 +9,12 @@ shellcheck: regardless
|
||||||
: Conditionally compiling shellcheck
|
: Conditionally compiling shellcheck
|
||||||
ghc $(GHCFLAGS) --make shellcheck
|
ghc $(GHCFLAGS) --make shellcheck
|
||||||
|
|
||||||
jsoncheck: regardless
|
|
||||||
: Conditionally compiling shellcheck
|
|
||||||
ghc $(GHCFLAGS) --make jsoncheck
|
|
||||||
|
|
||||||
.tests: *.hs */*.hs
|
.tests: *.hs */*.hs
|
||||||
: Running unit tests
|
: Running unit tests
|
||||||
./test/runQuack && touch .tests
|
./test/runQuack && touch .tests
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f .tests dist shellcheck jsoncheck *.hi *.o ShellCheck/*.hi ShellCheck/*.o
|
rm -f .tests shellcheck *.hi *.o ShellCheck/*.hi ShellCheck/*.o
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
regardless:
|
regardless:
|
||||||
|
|
|
@ -9,12 +9,8 @@ Build-Type: Simple
|
||||||
Cabal-Version: >= 1.2
|
Cabal-Version: >= 1.2
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4, parsec, containers, regex-compat, mtl, directory
|
build-depends: base >= 4, parsec, containers, regex-compat, mtl, directory, json
|
||||||
exposed-modules: ShellCheck.AST, ShellCheck.Data, ShellCheck.Parser, ShellCheck.Analytics, ShellCheck.Simple
|
exposed-modules: ShellCheck.AST, ShellCheck.Data, ShellCheck.Parser, ShellCheck.Analytics, ShellCheck.Simple
|
||||||
|
|
||||||
executable shellcheck
|
executable shellcheck
|
||||||
main-is: shellcheck.hs
|
main-is: shellcheck.hs
|
||||||
|
|
||||||
executable jsoncheck
|
|
||||||
build-depends: json
|
|
||||||
main-is: jsoncheck.hs
|
|
||||||
|
|
33
jsoncheck.hs
33
jsoncheck.hs
|
@ -1,33 +0,0 @@
|
||||||
{-
|
|
||||||
This file is part of ShellCheck.
|
|
||||||
http://www.vidarholen.net/contents/shellcheck
|
|
||||||
|
|
||||||
ShellCheck is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
ShellCheck is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-}
|
|
||||||
import ShellCheck.Simple
|
|
||||||
import Text.JSON
|
|
||||||
|
|
||||||
instance JSON ShellCheckComment where
|
|
||||||
showJSON c = makeObj [
|
|
||||||
("line", showJSON $ scLine c),
|
|
||||||
("column", showJSON $ scColumn c),
|
|
||||||
("level", showJSON $ scSeverity c),
|
|
||||||
("code", showJSON $ scCode c),
|
|
||||||
("message", showJSON $ scMessage c)
|
|
||||||
]
|
|
||||||
readJSON = undefined
|
|
||||||
|
|
||||||
main = do
|
|
||||||
script <- getContents
|
|
||||||
putStrLn $ encodeStrict $ shellCheck script
|
|
|
@ -24,6 +24,7 @@ import System.Directory
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
|
import Text.JSON
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
|
||||||
data Flag = Flag String String
|
data Flag = Flag String String
|
||||||
|
@ -36,6 +37,16 @@ options = [
|
||||||
|
|
||||||
printErr = hPutStrLn stderr
|
printErr = hPutStrLn stderr
|
||||||
|
|
||||||
|
instance JSON ShellCheckComment where
|
||||||
|
showJSON c = makeObj [
|
||||||
|
("line", showJSON $ scLine c),
|
||||||
|
("column", showJSON $ scColumn c),
|
||||||
|
("level", showJSON $ scSeverity c),
|
||||||
|
("code", showJSON $ scCode c),
|
||||||
|
("message", showJSON $ scMessage c)
|
||||||
|
]
|
||||||
|
readJSON = undefined
|
||||||
|
|
||||||
parseArguments argv =
|
parseArguments argv =
|
||||||
case getOpt Permute options argv of
|
case getOpt Permute options argv of
|
||||||
(opts, files, []) ->
|
(opts, files, []) ->
|
||||||
|
@ -55,6 +66,7 @@ parseArguments argv =
|
||||||
specials x = x
|
specials x = x
|
||||||
|
|
||||||
formats = Map.fromList [
|
formats = Map.fromList [
|
||||||
|
("json", forJson),
|
||||||
("tty", forTty)
|
("tty", forTty)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -114,6 +126,16 @@ forTty options files = do
|
||||||
term <- hIsTerminalDevice stdout
|
term <- hIsTerminalDevice stdout
|
||||||
return $ if term then colorComment else const id
|
return $ if term then colorComment else const id
|
||||||
|
|
||||||
|
-- This totally ignores the filenames. Fixme?
|
||||||
|
forJson options files = do
|
||||||
|
comments <- liftM concat $ mapM process files
|
||||||
|
putStrLn $ encodeStrict $ comments
|
||||||
|
return . null $ comments
|
||||||
|
where
|
||||||
|
process file = do
|
||||||
|
script <- readFile file
|
||||||
|
return $ shellCheck script
|
||||||
|
|
||||||
getOption [] _ def = def
|
getOption [] _ def = def
|
||||||
getOption ((Flag var val):_) name _ | name == var = val
|
getOption ((Flag var val):_) name _ | name == var = val
|
||||||
getOption (_:rest) flag def = getOption rest flag def
|
getOption (_:rest) flag def = getOption rest flag def
|
||||||
|
|
Loading…
Reference in New Issue