Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
e264f642
S
ShellCheck
项目概览
Annlix
/
ShellCheck
与 Fork 源项目一致
Fork自
镜像 / koalaman / ShellCheck
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
ShellCheck
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e264f642
编写于
11月 06, 2012
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed from codename Shpell to final name ShellCheck.
上级
45b98f40
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
49 addition
and
16 deletion
+49
-16
Makefile
Makefile
+5
-5
ShellCheck/Analytics.hs
ShellCheck/Analytics.hs
+2
-2
ShellCheck/Parser.hs
ShellCheck/Parser.hs
+1
-1
ShellCheck/Simple.hs
ShellCheck/Simple.hs
+33
-0
shellcheck.hs
shellcheck.hs
+8
-8
未找到文件。
Makefile
浏览文件 @
e264f642
all
:
sh
pell
.tests
all
:
sh
ellcheck
.tests
: Done
sh
pell
:
regardless
: Conditionally compiling sh
pell
ghc
--make
sh
pell
sh
ellcheck
:
regardless
: Conditionally compiling sh
ellcheck
ghc
--make
sh
ellcheck
.tests
:
*.hs */*.hs
: Running unit tests
./test/runQuack
&&
touch
.tests
clean
:
rm
-f
.tests sh
pell
*
.hi
*
.o Shpell/
*
.hi Shpell
/
*
.o
rm
-f
.tests sh
ellcheck
*
.hi
*
.o ShellCheck/
*
.hi ShellCheck
/
*
.o
regardless
:
Sh
pell
/Analytics.hs
→
Sh
ellCheck
/Analytics.hs
浏览文件 @
e264f642
module
Sh
pell
.Analytics
where
module
Sh
ellCheck
.Analytics
where
import
Sh
pell
.Parser
import
Sh
ellCheck
.Parser
import
Control.Monad
import
Control.Monad.State
import
qualified
Data.Map
as
Map
...
...
Sh
pell
/Parser.hs
→
Sh
ellCheck
/Parser.hs
浏览文件 @
e264f642
{-# LANGUAGE NoMonomorphismRestriction #-}
module
Sh
pell
.Parser
(
Token
(
..
),
Id
(
..
),
Note
(
..
),
Severity
(
..
),
parseShell
,
ParseResult
(
..
),
ParseNote
(
..
),
notesFromMap
,
Metadata
(
..
),
doAnalysis
,
doStackAnalysis
,
doTransform
,
sortNotes
)
where
module
Sh
ellCheck
.Parser
(
Token
(
..
),
Id
(
..
),
Note
(
..
),
Severity
(
..
),
parseShell
,
ParseResult
(
..
),
ParseNote
(
..
),
notesFromMap
,
Metadata
(
..
),
doAnalysis
,
doStackAnalysis
,
doTransform
,
sortNotes
)
where
import
Text.Parsec
import
Debug.Trace
...
...
Sh
pell
/Simple.hs
→
Sh
ellCheck
/Simple.hs
浏览文件 @
e264f642
module
Sh
pell.Simple
(
shpellCheck
,
ShpellComment
,
shpellLine
,
shpellColumn
,
shpellSeverity
,
shpell
Comment
)
where
module
Sh
ellCheck.Simple
(
shellcheckCheck
,
ShellCheckComment
,
shellcheckLine
,
shellcheckColumn
,
shellcheckSeverity
,
shellcheck
Comment
)
where
import
Sh
pell
.Parser
import
Sh
pell
.Analytics
import
Sh
ellCheck
.Parser
import
Sh
ellCheck
.Analytics
import
Data.Maybe
import
Text.Parsec.Pos
import
Data.List
sh
pellCheck
::
String
->
[
Shpell
Comment
]
sh
pell
Check
script
=
sh
ellcheckCheck
::
String
->
[
ShellCheck
Comment
]
sh
ellcheck
Check
script
=
let
(
ParseResult
result
notes
)
=
parseShell
"-"
script
in
let
allNotes
=
notes
++
(
concat
$
maybeToList
$
do
(
tree
,
map
)
<-
result
...
...
@@ -17,11 +17,11 @@ shpellCheck script =
in
map
formatNote
$
nub
$
sortNotes
allNotes
data
Sh
pellComment
=
ShpellComment
{
shpellLine
::
Int
,
shpellColumn
::
Int
,
shpellSeverity
::
String
,
shpell
Comment
::
String
}
data
Sh
ellCheckComment
=
ShellCheckComment
{
shellcheckLine
::
Int
,
shellcheckColumn
::
Int
,
shellcheckSeverity
::
String
,
shellcheck
Comment
::
String
}
instance
Show
Sh
pell
Comment
where
show
c
=
concat
[
"("
,
show
$
sh
pellLine
c
,
","
,
show
$
shpellColumn
c
,
") "
,
shpellSeverity
c
,
": "
,
shpell
Comment
c
]
instance
Show
Sh
ellCheck
Comment
where
show
c
=
concat
[
"("
,
show
$
sh
ellcheckLine
c
,
","
,
show
$
shellcheckColumn
c
,
") "
,
shellcheckSeverity
c
,
": "
,
shellcheck
Comment
c
]
severityToString
s
=
case
s
of
...
...
@@ -30,4 +30,4 @@ severityToString s =
InfoC
->
"info"
StyleC
->
"style"
formatNote
(
ParseNote
pos
severity
text
)
=
Sh
pell
Comment
(
sourceLine
pos
)
(
sourceColumn
pos
)
(
severityToString
severity
)
text
formatNote
(
ParseNote
pos
severity
text
)
=
Sh
ellCheck
Comment
(
sourceLine
pos
)
(
sourceColumn
pos
)
(
severityToString
severity
)
text
sh
pell
.hs
→
sh
ellcheck
.hs
浏览文件 @
e264f642
import
Control.Monad
import
GHC.Exts
import
GHC.IO.Device
import
Sh
pell
.Simple
import
Sh
ellCheck
.Simple
import
System.Directory
import
System.Environment
import
System.Exit
...
...
@@ -33,25 +33,25 @@ doFile path colorFunc = do
doInput
filename
contents
colorFunc
=
do
let
fileLines
=
lines
contents
let
lineCount
=
length
fileLines
let
comments
=
sh
pell
Check
contents
let
groups
=
groupWith
sh
pell
Line
comments
let
comments
=
sh
ellcheck
Check
contents
let
groups
=
groupWith
sh
ellcheck
Line
comments
if
not
$
null
comments
then
do
mapM_
(
\
x
->
do
let
lineNum
=
sh
pell
Line
(
head
x
)
let
lineNum
=
sh
ellcheck
Line
(
head
x
)
let
line
=
if
lineNum
<
1
||
lineNum
>
lineCount
then
""
else
fileLines
!!
(
lineNum
-
1
)
putStrLn
""
putStrLn
$
colorFunc
"message"
(
"In "
++
filename
++
" line "
++
(
show
$
lineNum
)
++
":"
)
putStrLn
(
colorFunc
"source"
line
)
mapM
(
\
c
->
putStrLn
(
colorFunc
(
sh
pell
Severity
c
)
$
cuteIndent
c
))
x
mapM
(
\
c
->
putStrLn
(
colorFunc
(
sh
ellcheck
Severity
c
)
$
cuteIndent
c
))
x
putStrLn
""
)
groups
else
do
putStrLn
(
"No comments for "
++
filename
)
cuteIndent
comment
=
(
replicate
((
sh
pellColumn
comment
)
-
1
)
' '
)
++
"^-- "
++
(
shpell
Comment
comment
)
(
replicate
((
sh
ellcheckColumn
comment
)
-
1
)
' '
)
++
"^-- "
++
(
shellcheck
Comment
comment
)
getColorFunc
=
do
term
<-
hIsTerminalDevice
stdout
...
...
@@ -61,8 +61,8 @@ main = do
args
<-
getArgs
colors
<-
getColorFunc
if
null
args
then
do
hPutStrLn
stderr
"sh
pell
-- bash/sh shell script static analysis tool"
hPutStrLn
stderr
"Usage: sh
pell
filenames..."
hPutStrLn
stderr
"sh
ellcheck
-- bash/sh shell script static analysis tool"
hPutStrLn
stderr
"Usage: sh
ellcheck
filenames..."
exitFailure
else
mapM
(
\
f
->
doFile
f
colors
)
args
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录