-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: misc: Create new linter test using golangci-lint instead of gom…
…etalinter
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# test-golangci-lint configuration file for golangci-lint | ||
|
||
run: | ||
skip-files: | ||
- lang/lexer.nn.go | ||
- lang/y.go | ||
- bindata/bindata.go | ||
- lang/types/kind_stringer.go | ||
- lang/interpolate/parse.generated.go | ||
- lang/interpolate/interpolate/parse.generated.go | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- goimports | ||
- revive # using revive instead of golint as it runs more quickly | ||
- misspell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# print current running test | ||
echo running "$0" | ||
|
||
command -v golangci-lint >/dev/null 2>&1 || { echo >&2 "golangci-lint not found"; exit 1; } | ||
|
||
# configure settings for test scripts | ||
ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
cd "${ROOT}" # Enter mgmt root | ||
. test/util.sh | ||
|
||
failures='' | ||
function run-test() | ||
{ | ||
$@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" ) | ||
} | ||
|
||
# using .golangci.yml config file settings in ROOT | ||
gcl='golangci-lint run' | ||
|
||
# commented out from gometalinter linter test | ||
# aligncheck, dupl, errcheck, gas, goconst, gocyclo, gotype, unconvert | ||
|
||
# TODO: only a few fixes needed before using following linters: | ||
# deadcode, gosimple, ineffassign, interfacer, lll --line-length=200 | ||
# safesql, staticcheck, structcheck, unparam, unused, varcheck | ||
|
||
for dir in `find * -maxdepth 9 -type d -not -path 'old/*' -not -path 'old' -not -path 'tmp/*' -not -path 'tmp' -not -path 'vendor/*' -not -path 'examples/*' -not -path 'test/*' -not -path 'interpolate/*'`; do | ||
|
||
# doesn't acquire files individually, but treats them as a set of * files | ||
match="$dir/*.go" | ||
|
||
if ! ls $match &>/dev/null; then | ||
continue # no *.go files found | ||
fi | ||
|
||
run-test $gcl "$dir" || fail_test "golangci-lint did not pass" | ||
done | ||
|
||
if [[ -n "$failures" ]]; then | ||
echo 'FAIL' | ||
echo 'The following tests have failed:' | ||
echo -e "$failures" | ||
echo | ||
exit 1 | ||
fi | ||
echo 'PASS' |