Merge pull request #1717 from dnephin/use-gometalinter
Use gometalinter for linting
This commit is contained in:
commit
7e398dd591
@ -24,11 +24,7 @@ before_build:
|
|||||||
#- choco install codecov
|
#- choco install codecov
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe setup"
|
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe setup check"
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe fmt"
|
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe lint"
|
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe vet"
|
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe ineffassign"
|
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build"
|
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build"
|
||||||
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe binaries"
|
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe binaries"
|
||||||
|
|
||||||
|
19
.gometalinter.json
Normal file
19
.gometalinter.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"Vendor": true,
|
||||||
|
"Deadline": "2m",
|
||||||
|
"Sort": ["linter", "severity", "path", "line"],
|
||||||
|
"Exclude": [
|
||||||
|
".*\\.pb\\.go",
|
||||||
|
"fetch\\.go:.*::error: unrecognized printf verb 'r'"
|
||||||
|
],
|
||||||
|
"EnableGC": true,
|
||||||
|
"WarnUnmatchedDirective": true,
|
||||||
|
|
||||||
|
"Enable": [
|
||||||
|
"gofmt",
|
||||||
|
"goimports",
|
||||||
|
"golint",
|
||||||
|
"ineffassign",
|
||||||
|
"vet"
|
||||||
|
]
|
||||||
|
}
|
@ -48,12 +48,9 @@ script:
|
|||||||
- export GOOS=$TRAVIS_GOOS
|
- export GOOS=$TRAVIS_GOOS
|
||||||
- export CGO_ENABLED=$TRAVIS_CGO_ENABLED
|
- export CGO_ENABLED=$TRAVIS_CGO_ENABLED
|
||||||
- GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" make dco
|
- GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" make dco
|
||||||
- make fmt
|
- GOOS=linux make setup
|
||||||
- go build -i .
|
- go build -i .
|
||||||
- make setup
|
- make check
|
||||||
- make lint
|
|
||||||
- make vet
|
|
||||||
- make ineffassign
|
|
||||||
- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
|
- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
|
||||||
- make build
|
- make build
|
||||||
- make binaries
|
- make binaries
|
||||||
|
32
Makefile
32
Makefile
@ -18,7 +18,6 @@ endif
|
|||||||
|
|
||||||
WHALE = "🇩"
|
WHALE = "🇩"
|
||||||
ONI = "👹"
|
ONI = "👹"
|
||||||
FIX_PATH = $1
|
|
||||||
|
|
||||||
RELEASE=containerd-$(VERSION:v%=%).${GOOS}-${GOARCH}
|
RELEASE=containerd-$(VERSION:v%=%).${GOOS}-${GOARCH}
|
||||||
|
|
||||||
@ -61,7 +60,9 @@ TESTFLAGS_PARALLEL ?= 8
|
|||||||
|
|
||||||
all: binaries
|
all: binaries
|
||||||
|
|
||||||
check: fmt vet lint ineffassign ## run fmt, vet, lint, ineffassign
|
check: proto-fmt ## run all linters
|
||||||
|
@echo "$(WHALE) $@"
|
||||||
|
gometalinter --config .gometalinter.json ./...
|
||||||
|
|
||||||
ci: check binaries checkprotos coverage coverage-integration ## to be used by the CI
|
ci: check binaries checkprotos coverage coverage-integration ## to be used by the CI
|
||||||
|
|
||||||
@ -71,9 +72,8 @@ AUTHORS: .mailmap .git/HEAD
|
|||||||
setup: ## install dependencies
|
setup: ## install dependencies
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
# TODO(stevvooe): Install these from the vendor directory
|
# TODO(stevvooe): Install these from the vendor directory
|
||||||
@go get -u github.com/golang/lint/golint
|
@go get -u github.com/alecthomas/gometalinter
|
||||||
#@go get -u github.com/kisielk/errcheck
|
@gometalinter --install
|
||||||
@go get -u github.com/gordonklaus/ineffassign
|
|
||||||
@go get -u github.com/stevvooe/protobuild
|
@go get -u github.com/stevvooe/protobuild
|
||||||
|
|
||||||
generate: protos
|
generate: protos
|
||||||
@ -96,25 +96,13 @@ check-api-descriptors: protos ## check that protobuf changes aren't present.
|
|||||||
((git diff $$(find . -name '*.pb.txt') | cat) && \
|
((git diff $$(find . -name '*.pb.txt') | cat) && \
|
||||||
(echo "$(ONI) please run 'make protos' when making changes to proto files and check-in the generated descriptor file changes" && false))
|
(echo "$(ONI) please run 'make protos' when making changes to proto files and check-in the generated descriptor file changes" && false))
|
||||||
|
|
||||||
# Depends on binaries because vet will silently fail if it can't load compiled
|
proto-fmt: ## check format of proto files
|
||||||
# imports
|
|
||||||
vet: ## run go vet
|
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | grep -v 'unrecognized printf verb 'r'' | egrep -v '(timestamp_test.go|duration_test.go|fetch.go|exit status 1)' | tee /dev/stderr)"
|
|
||||||
|
|
||||||
fmt: ## run go fmt
|
|
||||||
@echo "$(WHALE) $@"
|
|
||||||
@test -z "$$(gofmt -s -l . | grep -Fv $(call FIX_PATH,'vendor/') | grep -v ".pb.go$$" | tee /dev/stderr)" || \
|
|
||||||
(echo "$(ONI) please format Go code with 'gofmt -s -w'" && false)
|
|
||||||
@test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
|
@test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
|
||||||
(echo "$(ONI) please indent proto files with tabs only" && false)
|
(echo "$(ONI) please indent proto files with tabs only" && false)
|
||||||
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
|
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
|
||||||
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)
|
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)
|
||||||
|
|
||||||
lint: ## run go lint
|
|
||||||
@echo "$(WHALE) $@"
|
|
||||||
@test -z "$$(golint ./... | grep -Fv $(call FIX_PATH,'vendor/') | grep -v ".pb.go:" | tee /dev/stderr)"
|
|
||||||
|
|
||||||
dco: ## dco check
|
dco: ## dco check
|
||||||
@which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found" && false)
|
@which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found" && false)
|
||||||
ifdef TRAVIS_COMMIT_RANGE
|
ifdef TRAVIS_COMMIT_RANGE
|
||||||
@ -123,14 +111,6 @@ else
|
|||||||
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
|
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ineffassign: ## run ineffassign
|
|
||||||
@echo "$(WHALE) $@"
|
|
||||||
@test -z "$$(ineffassign . | grep -Fv $(call FIX_PATH,'vendor/') | grep -v ".pb.go:" | tee /dev/stderr)"
|
|
||||||
|
|
||||||
#errcheck: ## run go errcheck
|
|
||||||
# @echo "$(WHALE) $@"
|
|
||||||
# @test -z "$$(errcheck ./... | grep -Fv $(call FIX_PATH,'vendor/') | grep -v ".pb.go:" | tee /dev/stderr)"
|
|
||||||
|
|
||||||
build: ## build the go packages
|
build: ## build the go packages
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
@go build -v ${EXTRA_FLAGS} ${GO_LDFLAGS} ${GO_GCFLAGS} ${PACKAGES}
|
@go build -v ${EXTRA_FLAGS} ${GO_LDFLAGS} ${GO_GCFLAGS} ${PACKAGES}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#Windows specific settings.
|
#Windows specific settings.
|
||||||
WHALE = "+"
|
WHALE = "+"
|
||||||
ONI = "-"
|
ONI = "-"
|
||||||
FIX_PATH = $(subst /,\,$1)
|
|
||||||
|
|
||||||
BINARY_SUFFIX=".exe"
|
BINARY_SUFFIX=".exe"
|
||||||
|
|
||||||
|
@ -5,17 +5,21 @@ package mount
|
|||||||
import "github.com/pkg/errors"
|
import "github.com/pkg/errors"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// ErrNotImplementOnUnix is returned for methods that are not implemented
|
||||||
ErrNotImplementOnUnix = errors.New("not implemented under unix")
|
ErrNotImplementOnUnix = errors.New("not implemented under unix")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Mount is not implemented on this platform
|
||||||
func (m *Mount) Mount(target string) error {
|
func (m *Mount) Mount(target string) error {
|
||||||
return ErrNotImplementOnUnix
|
return ErrNotImplementOnUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unmount is not implemented on this platform
|
||||||
func Unmount(mount string, flags int) error {
|
func Unmount(mount string, flags int) error {
|
||||||
return ErrNotImplementOnUnix
|
return ErrNotImplementOnUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmountAll is not implemented on this platform
|
||||||
func UnmountAll(mount string, flags int) error {
|
func UnmountAll(mount string, flags int) error {
|
||||||
return ErrNotImplementOnUnix
|
return ErrNotImplementOnUnix
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,17 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// StatAtime returns the access time from a stat struct
|
||||||
func StatAtime(st *syscall.Stat_t) syscall.Timespec {
|
func StatAtime(st *syscall.Stat_t) syscall.Timespec {
|
||||||
return st.Atimespec
|
return st.Atimespec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatCtime returns the created time from a stat struct
|
||||||
func StatCtime(st *syscall.Stat_t) syscall.Timespec {
|
func StatCtime(st *syscall.Stat_t) syscall.Timespec {
|
||||||
return st.Ctimespec
|
return st.Ctimespec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatMtime returns the modified time from a stat struct
|
||||||
func StatMtime(st *syscall.Stat_t) syscall.Timespec {
|
func StatMtime(st *syscall.Stat_t) syscall.Timespec {
|
||||||
return st.Mtimespec
|
return st.Mtimespec
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user