Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
cb7fa786
Commit
cb7fa786
authored
Nov 26, 2018
by
liuyuhang
Committed by
vipwzw
Nov 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add make linter_test, ex the cmd is: make linter_test p=plugin/dapp/blackwhite
parent
27e5be5f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
23 deletions
+77
-23
Makefile
Makefile
+5
-23
golinter.sh
golinter.sh
+72
-0
No files found.
Makefile
View file @
cb7fa786
...
...
@@ -74,30 +74,12 @@ updatevendor:
dep
:
dep init
-v
linter
:
##
Use gometalinter check code
,
ignore some unserious warning
@
res
=
$$
(
gometalinter.v2
-t
--sort
=
linter
--enable-gc
--deadline
=
2m
--disable-all
\
--enable
=
gofmt
\
--enable
=
gosimple
\
--enable
=
deadcode
\
--enable
=
unconvert
\
--enable
=
interfacer
\
--enable
=
varcheck
\
--enable
=
structcheck
\
--enable
=
goimports
\
--vendor
./...
)
\
# --enable=vet
\
# --enable=staticcheck
\
# --enable=gocyclo
\
# --enable=staticcheck
\
# --enable=golint
\
# --enable=unused
\
# --enable=gotype
\
# --enable=gotypex
\
if
[
-n
"
$$
res"
]
;
then
\
echo
"
$$
{res}"
;
\
exit
1
;
\
fi
;
@
./golinter.sh
"filter"
@
find
.
-name
'*.sh'
-not
-path
"./vendor/*"
| xargs shellcheck
linter_test
:
##
Use gometalinter check code
,
for local test
@
./golinter.sh
"test"
"
${
p
}
"
@
find
.
-name
'*.sh'
-not
-path
"./vendor/*"
| xargs shellcheck
race
:
##
Run data race detector
...
...
golinter.sh
0 → 100755
View file @
cb7fa786
#!/bin/bash
# shellcheck disable=SC2207
set
+e
OP
=
"
${
1
}
"
path
=
"
${
2
}
"
function
filterLinter
()
{
res
=
$(
gometalinter.v2
-t
--sort
=
linter
--enable-gc
--deadline
=
2m
--disable-all
\
--enable
=
gofmt
\
--enable
=
gosimple
\
--enable
=
deadcode
\
--enable
=
unconvert
\
--enable
=
interfacer
\
--enable
=
varcheck
\
--enable
=
structcheck
\
--enable
=
goimports
\
--vendor
./...
)
# --enable=staticcheck \
# --enable=gocyclo \
# --enable=staticcheck \
# --enable=golint \
# --enable=unused \
# --enable=gotype \
# --enable=gotypex \
if
[[
${#
res
}
-gt
"0"
]]
;
then
resNoSpace
=
$(
echo
"
${
res
}
"
|
tr
' '
'@'
)
array
=(
$(
echo
"
${
resNoSpace
}
"
|
tr
'\n'
'\n'
)
)
str
=
""
for
var
in
${
array
[*]
}
;
do
if
!
[[
$var
=
~
"underscores"
]]
;
then
str
=
"
${
str
}
""
${
var
}
""
\\
n"
fi
done
res
=
""
res
=
$(
echo
"
${
str
}
"
|
tr
'@'
' '
)
fi
if
[[
${#
res
}
-gt
"0"
]]
;
then
echo
-e
"
${
res
}
"
exit
1
fi
}
function
testLinter
()
{
cd
"
${
path
}
"
>
/dev/null
||
exit
gometalinter.v2
-t
--sort
=
linter
--enable-gc
--deadline
=
2m
--disable-all
\
--enable
=
gofmt
\
--enable
=
gosimple
\
--enable
=
deadcode
\
--enable
=
unconvert
\
--enable
=
interfacer
\
--enable
=
varcheck
\
--enable
=
structcheck
\
--enable
=
goimports
\
--enable
=
vet
\
--enable
=
golint
\
--enable
=
ineffassign
\
--vendor
./...
cd
-
>
/dev/null
||
exit
}
function
main
()
{
if
[
"
${
OP
}
"
==
"filter"
]
;
then
filterLinter
elif
[
"
${
OP
}
"
==
"test"
]
;
then
testLinter
fi
}
# run script
main
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment