Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
22ae83e3
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,发现更多精彩内容 >>
提交
22ae83e3
编写于
11月 04, 2012
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Gave Parsec errors proper positioning info
上级
d5587dd1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
25 addition
and
5 deletion
+25
-5
Shpell/Parser.hs
Shpell/Parser.hs
+17
-2
Shpell/Simple.hs
Shpell/Simple.hs
+2
-1
shpell.hs
shpell.hs
+6
-2
未找到文件。
Shpell/Parser.hs
浏览文件 @
22ae83e3
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
module
Shpell.Parser
(
Token
(
..
),
Note
(
..
),
Severity
(
..
),
parseShell
,
ParseResult
(
..
),
ParseNote
(
..
),
notesFromMap
,
Metadata
(
..
),
doAnalysis
,
doTransform
,
sortNotes
)
where
module
Shpell.Parser
(
Token
(
..
),
Note
(
..
),
Severity
(
..
),
parseShell
,
ParseResult
(
..
),
ParseNote
(
..
),
notesFromMap
,
Metadata
(
..
),
doAnalysis
,
doTransform
,
sortNotes
)
where
import
Text.Parsec
import
Text.Parsec
import
Text.Parsec.Pos
(
initialPos
)
import
Debug.Trace
import
Debug.Trace
import
Control.Monad
import
Control.Monad
import
Control.Monad.Identity
import
Control.Monad.Identity
...
@@ -14,7 +13,9 @@ import qualified Control.Monad.State as Ms
...
@@ -14,7 +13,9 @@ import qualified Control.Monad.State as Ms
import
Data.Maybe
import
Data.Maybe
import
Prelude
hiding
(
readList
)
import
Prelude
hiding
(
readList
)
import
System.IO
import
System.IO
import
Text.Parsec.Error
import
qualified
Text.Regex
as
Re
import
qualified
Text.Regex
as
Re
import
GHC.Exts
(
sortWith
)
...
@@ -993,8 +994,22 @@ sortNotes = sortBy compareNotes
...
@@ -993,8 +994,22 @@ sortNotes = sortBy compareNotes
data
ParseResult
=
ParseResult
{
parseResult
::
Maybe
(
Token
,
Map
.
Map
Id
Metadata
),
parseNotes
::
[
ParseNote
]
}
data
ParseResult
=
ParseResult
{
parseResult
::
Maybe
(
Token
,
Map
.
Map
Id
Metadata
),
parseNotes
::
[
ParseNote
]
}
makeErrorFor
parsecError
=
ParseNote
(
errorPos
parsecError
)
ErrorC
$
getStringFromParsec
$
errorMessages
parsecError
getStringFromParsec
errors
=
case
map
snd
$
sortWith
fst
$
map
f
errors
of
(
s
:
_
)
->
s
_
->
"Unknown error"
where
f
err
=
case
err
of
UnExpect
s
->
(
1
,
"Aborting due to unexpected "
++
s
++
". Is this valid?"
)
SysUnExpect
s
->
(
2
,
"Internal unexpected "
++
s
++
". Submit a bug."
)
Expect
s
->
(
3
,
"Expected "
++
s
++
""
)
Message
s
->
(
4
,
"Message: "
++
s
)
parseShell
filename
contents
=
do
parseShell
filename
contents
=
do
case
rp
(
parseWithNotes
readScript
)
filename
contents
of
case
rp
(
parseWithNotes
readScript
)
filename
contents
of
(
Right
(
script
,
map
,
notes
),
parsenotes
)
->
ParseResult
(
Just
(
script
,
map
))
(
nub
$
sortNotes
$
notes
++
parsenotes
)
(
Right
(
script
,
map
,
notes
),
parsenotes
)
->
ParseResult
(
Just
(
script
,
map
))
(
nub
$
sortNotes
$
notes
++
parsenotes
)
(
Left
err
,
p
)
->
ParseResult
Nothing
(
nub
$
sortNotes
$
(
ParseNote
(
initialPos
"-"
)
ErrorC
$
"Parsing failed: "
++
(
show
err
))
:
(
p
)
)
(
Left
err
,
p
)
->
ParseResult
Nothing
(
nub
$
sortNotes
$
(
makeErrorFor
err
)
:
p
)
Shpell/Simple.hs
浏览文件 @
22ae83e3
...
@@ -4,6 +4,7 @@ import Shpell.Parser
...
@@ -4,6 +4,7 @@ import Shpell.Parser
import
Shpell.Analytics
import
Shpell.Analytics
import
Data.Maybe
import
Data.Maybe
import
Text.Parsec.Pos
import
Text.Parsec.Pos
import
Data.List
shpellCheck
::
String
->
[
ShpellComment
]
shpellCheck
::
String
->
[
ShpellComment
]
shpellCheck
script
=
shpellCheck
script
=
...
@@ -14,7 +15,7 @@ shpellCheck script =
...
@@ -14,7 +15,7 @@ shpellCheck script =
return
$
notesFromMap
newMap
return
$
notesFromMap
newMap
)
)
in
in
map
formatNote
$
sortNotes
allNotes
map
formatNote
$
nub
$
sortNotes
allNotes
data
ShpellComment
=
ShpellComment
{
shpellLine
::
Int
,
shpellColumn
::
Int
,
shpellSeverity
::
String
,
shpellComment
::
String
}
data
ShpellComment
=
ShpellComment
{
shpellLine
::
Int
,
shpellColumn
::
Int
,
shpellSeverity
::
String
,
shpellComment
::
String
}
...
...
shpell.hs
浏览文件 @
22ae83e3
...
@@ -32,13 +32,17 @@ doFile path colorFunc = do
...
@@ -32,13 +32,17 @@ doFile path colorFunc = do
doInput
filename
contents
colorFunc
=
do
doInput
filename
contents
colorFunc
=
do
let
fileLines
=
lines
contents
let
fileLines
=
lines
contents
let
lineCount
=
length
fileLines
let
comments
=
shpellCheck
contents
let
comments
=
shpellCheck
contents
let
groups
=
groupWith
shpellLine
comments
let
groups
=
groupWith
shpellLine
comments
if
not
$
null
comments
then
do
if
not
$
null
comments
then
do
mapM_
(
\
x
->
do
mapM_
(
\
x
->
do
let
line
=
fileLines
!!
(
shpellLine
(
head
x
)
-
1
)
let
lineNum
=
shpellLine
(
head
x
)
let
line
=
if
lineNum
<
1
||
lineNum
>=
lineCount
then
""
else
fileLines
!!
(
lineNum
-
1
)
putStrLn
""
putStrLn
""
putStrLn
$
colorFunc
"message"
(
"In "
++
filename
++
" line "
++
(
show
$
shpellLine
(
head
x
)
)
++
":"
)
putStrLn
$
colorFunc
"message"
(
"In "
++
filename
++
" line "
++
(
show
$
lineNum
)
++
":"
)
putStrLn
(
colorFunc
"source"
line
)
putStrLn
(
colorFunc
"source"
line
)
mapM
(
\
c
->
putStrLn
(
colorFunc
(
shpellSeverity
c
)
$
cuteIndent
c
))
x
mapM
(
\
c
->
putStrLn
(
colorFunc
(
shpellSeverity
c
)
$
cuteIndent
c
))
x
putStrLn
""
putStrLn
""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录