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>
Этот коммит содержится в:
Carl Menezes 2022-02-16 10:37:27 +13:00 коммит произвёл GitHub
родитель 1c91e6f9ea
коммит c95871f3ce
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 16 добавлений и 20 удалений

11
.github/workflows/test.yml предоставленный
Просмотреть файл

@ -28,11 +28,14 @@ jobs:
${{ runner.os }}-go-cache
- name: Run gofmt
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: |
go install golang.org/x/lint/golint@latest
golint -set_exit_status ./...
cd _examples && golint -set_exit_status ./... && cd ..
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog/cmd/godog
# 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
run: |
go vet ./...

Просмотреть файл

@ -22,3 +22,7 @@ If everything passes, you're ready to hack!
[install go]: https://golang.org/doc/install
[community Slack]: https://cucumber.io/community#slack
[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.

Просмотреть файл

@ -12,8 +12,8 @@ test: check-go-version
@echo "running all tests"
@go install ./...
@go fmt ./...
@go run golang.org/x/lint/golint@latest 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
@go run honnef.co/go/tools/cmd/staticcheck@v0.2.2 github.com/cucumber/godog/cmd/godog
go vet ./...
go test -race ./...
godog -f progress -c 4

Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2 Исполняемый файл

Двоичный файл не отображается.

Просмотреть файл

@ -633,7 +633,6 @@ type progressOutput struct {
}
func passingStepDef() error { return nil }
func passingStepDefWithoutReturn() {}
func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) }

Просмотреть файл

@ -418,16 +418,6 @@ func (s *suite) shouldFail(err error) bool {
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) {
ctx := s.defaultContext
if ctx == nil {

Просмотреть файл

@ -42,8 +42,8 @@ func TestScenarioContext_Step(t *testing.T) {
})
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(".*", nokMore) }, ShouldPanicWith, fmt.Sprintf("expected handler to return either zero, one or two values, but it has: 5"))
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, "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() {