Switch from golint to staticcheck (#457)
* Switch from golint to staticcheck * Remove unused function run_test.go:618:6: func passingStepDefWithoutReturn is unused (U1000) * Remove unused function suite.go:421:6: func isEmptyFeature is unused (U1000) * Fix unnecessary use of fmt.Sprintf test_context_test.go:45:66: unnecessary use of fmt.Sprintf (S1039) test_context_test.go:46:61: unnecessary use of fmt.Sprintf (S1039) * Fix CI error https://github.com/cucumber/godog/runs/5146601108?check_suite_focus=true#step:7:28 * Change CI to run staticcheck instead of golint * Use staticcheck that definitely pass * Fix CI staticcheck error https://github.com/cucumber/godog/runs/5147133955?check_suite_focus=true#step:6:17 * Only run staticcheck for Go 1.17 Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com> * Add staticcheck linux binary * Update Go module dependencies in _examples * Use static check binary in bin for CI * Reduce number of dependencies Also add a note to CONTRIBUTING.md about the _examples module * Pin the version of staticcheck Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com> Co-authored-by: Matt Wynne <matt@cucumber.io> Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com>
Этот коммит содержится в:
родитель
1c91e6f9ea
коммит
c95871f3ce
7 изменённых файлов: 16 добавлений и 20 удалений
11
.github/workflows/test.yml
предоставленный
11
.github/workflows/test.yml
предоставленный
|
@ -28,11 +28,14 @@ jobs:
|
||||||
${{ runner.os }}-go-cache
|
${{ runner.os }}-go-cache
|
||||||
- name: Run gofmt
|
- name: Run gofmt
|
||||||
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
|
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
|
||||||
- name: Run golint
|
- name: Run staticcheck
|
||||||
|
if: matrix.go-version == '1.17.x'
|
||||||
run: |
|
run: |
|
||||||
go install golang.org/x/lint/golint@latest
|
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog
|
||||||
golint -set_exit_status ./...
|
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog/cmd/godog
|
||||||
cd _examples && golint -set_exit_status ./... && cd ..
|
# Disable for now because of failing checks
|
||||||
|
# TODO: Add back in when fixes are made
|
||||||
|
# bin/staticcheck_linux_amd64_2021.1.2 ./...
|
||||||
- name: Run go vet
|
- name: Run go vet
|
||||||
run: |
|
run: |
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
|
|
@ -22,3 +22,7 @@ If everything passes, you're ready to hack!
|
||||||
[install go]: https://golang.org/doc/install
|
[install go]: https://golang.org/doc/install
|
||||||
[community Slack]: https://cucumber.io/community#slack
|
[community Slack]: https://cucumber.io/community#slack
|
||||||
[raise an issue]: https://github.com/cucumber/godog/issues/new/choose
|
[raise an issue]: https://github.com/cucumber/godog/issues/new/choose
|
||||||
|
|
||||||
|
## Changing dependencies
|
||||||
|
|
||||||
|
If dependencies have changed, you will also need to update the _examples module. `go mod tidy` should be sufficient.
|
4
Makefile
4
Makefile
|
@ -12,8 +12,8 @@ test: check-go-version
|
||||||
@echo "running all tests"
|
@echo "running all tests"
|
||||||
@go install ./...
|
@go install ./...
|
||||||
@go fmt ./...
|
@go fmt ./...
|
||||||
@go run golang.org/x/lint/golint@latest github.com/cucumber/godog
|
@go run honnef.co/go/tools/cmd/staticcheck@v0.2.2 github.com/cucumber/godog
|
||||||
@go run golang.org/x/lint/golint@latest github.com/cucumber/godog/cmd/godog
|
@go run honnef.co/go/tools/cmd/staticcheck@v0.2.2 github.com/cucumber/godog/cmd/godog
|
||||||
go vet ./...
|
go vet ./...
|
||||||
go test -race ./...
|
go test -race ./...
|
||||||
godog -f progress -c 4
|
godog -f progress -c 4
|
||||||
|
|
Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2
Исполняемый файл
Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2
Исполняемый файл
Двоичный файл не отображается.
|
@ -633,7 +633,6 @@ type progressOutput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func passingStepDef() error { return nil }
|
func passingStepDef() error { return nil }
|
||||||
func passingStepDefWithoutReturn() {}
|
|
||||||
|
|
||||||
func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) }
|
func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) }
|
||||||
|
|
||||||
|
|
10
suite.go
10
suite.go
|
@ -418,16 +418,6 @@ func (s *suite) shouldFail(err error) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isEmptyFeature(pickles []*messages.Pickle) bool {
|
|
||||||
for _, pickle := range pickles {
|
|
||||||
if len(pickle.Steps) > 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
|
func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
|
||||||
ctx := s.defaultContext
|
ctx := s.defaultContext
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
|
|
|
@ -42,8 +42,8 @@ func TestScenarioContext_Step(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("has more than 2 return values", func() {
|
Convey("has more than 2 return values", func() {
|
||||||
So(func() { ctx.Step(".*", nokLimitCase) }, ShouldPanicWith, fmt.Sprintf("expected handler to return either zero, one or two values, but it has: 3"))
|
So(func() { ctx.Step(".*", nokLimitCase) }, ShouldPanicWith, "expected handler to return either zero, one or two values, but it has: 3")
|
||||||
So(func() { ctx.Step(".*", nokMore) }, ShouldPanicWith, fmt.Sprintf("expected handler to return either zero, one or two values, but it has: 5"))
|
So(func() { ctx.Step(".*", nokMore) }, ShouldPanicWith, "expected handler to return either zero, one or two values, but it has: 5")
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("return type is not an error or string slice or void", func() {
|
Convey("return type is not an error or string slice or void", func() {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче