Skip to content

Commit c95871f

Browse files
carleetomattwynnevearutop
authored
Switch from golint to staticcheck (cucumber#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 <[email protected]> * 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 <[email protected]> Co-authored-by: Matt Wynne <[email protected]> Co-authored-by: Viacheslav Poturaev <[email protected]>
1 parent 1c91e6f commit c95871f

7 files changed

+16
-20
lines changed

.github/workflows/test.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ jobs:
2828
${{ runner.os }}-go-cache
2929
- name: Run gofmt
3030
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
31-
- name: Run golint
31+
- name: Run staticcheck
32+
if: matrix.go-version == '1.17.x'
3233
run: |
33-
go install golang.org/x/lint/golint@latest
34-
golint -set_exit_status ./...
35-
cd _examples && golint -set_exit_status ./... && cd ..
34+
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog
35+
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog/cmd/godog
36+
# Disable for now because of failing checks
37+
# TODO: Add back in when fixes are made
38+
# bin/staticcheck_linux_amd64_2021.1.2 ./...
3639
- name: Run go vet
3740
run: |
3841
go vet ./...

CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ If everything passes, you're ready to hack!
2222
[install go]: https://golang.org/doc/install
2323
[community Slack]: https://cucumber.io/community#slack
2424
[raise an issue]: https://github.com/cucumber/godog/issues/new/choose
25+
26+
## Changing dependencies
27+
28+
If dependencies have changed, you will also need to update the _examples module. `go mod tidy` should be sufficient.

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test: check-go-version
1212
@echo "running all tests"
1313
@go install ./...
1414
@go fmt ./...
15-
@go run golang.org/x/lint/golint@latest github.com/cucumber/godog
16-
@go run golang.org/x/lint/golint@latest github.com/cucumber/godog/cmd/godog
15+
@go run honnef.co/go/tools/cmd/[email protected] github.com/cucumber/godog
16+
@go run honnef.co/go/tools/cmd/[email protected] github.com/cucumber/godog/cmd/godog
1717
go vet ./...
1818
go test -race ./...
1919
godog -f progress -c 4

bin/staticcheck_linux_amd64_2021.1.2

11.3 MB
Binary file not shown.

run_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,7 @@ type progressOutput struct {
632632
bottomRows []string
633633
}
634634

635-
func passingStepDef() error { return nil }
636-
func passingStepDefWithoutReturn() {}
635+
func passingStepDef() error { return nil }
637636

638637
func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) }
639638

suite.go

-10
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,6 @@ func (s *suite) shouldFail(err error) bool {
418418
return true
419419
}
420420

421-
func isEmptyFeature(pickles []*messages.Pickle) bool {
422-
for _, pickle := range pickles {
423-
if len(pickle.Steps) > 0 {
424-
return false
425-
}
426-
}
427-
428-
return true
429-
}
430-
431421
func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
432422
ctx := s.defaultContext
433423
if ctx == nil {

test_context_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ func TestScenarioContext_Step(t *testing.T) {
4242
})
4343

4444
Convey("has more than 2 return values", func() {
45-
So(func() { ctx.Step(".*", nokLimitCase) }, ShouldPanicWith, fmt.Sprintf("expected handler to return either zero, one or two values, but it has: 3"))
46-
So(func() { ctx.Step(".*", nokMore) }, ShouldPanicWith, fmt.Sprintf("expected handler to return either zero, one or two values, but it has: 5"))
45+
So(func() { ctx.Step(".*", nokLimitCase) }, ShouldPanicWith, "expected handler to return either zero, one or two values, but it has: 3")
46+
So(func() { ctx.Step(".*", nokMore) }, ShouldPanicWith, "expected handler to return either zero, one or two values, but it has: 5")
4747
})
4848

4949
Convey("return type is not an error or string slice or void", func() {

0 commit comments

Comments
 (0)