Skip to content

Commit

Permalink
chore: bump golangci-lint to v1.61.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zoncoen committed Oct 27, 2024
1 parent eaa5bf4 commit 14bd62e
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 45 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ jobs:
uses: reviewdog/action-golangci-lint@v2
with:
reviewdog_flags: '-conf=.reviewdog.yml -diff="git diff main"'
golangci_lint_version: v1.52.2
- name: looppointer
run: make lint/looppointer
golangci_lint_version: v1.61.0
46 changes: 32 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,61 @@ linters:
enable-all: true
disable:
- containedctx
- contextcheck
- depguard
- dupl
- err113
- exhaustive
- exhaustruct
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- godox
- goerr113
- gomnd
- ifshort
- interfacebloat
- ireturn
- lll
- mnd
- nestif
- nlreturn
- nosnakecase
- paralleltest
- perfsprint
- prealloc
- scopelint
- testpackage
- tparallel
- unparam
- varnamelen
- wrapcheck
- wsl

# deplicated
- deadcode
- exhaustivestruct
- golint
- interfacer
- maligned
- scopelint
- structcheck
- varcheck
# deprecated
- execinquery
- exportloopref
- gomnd

# disabled because of generics
- rowserrcheck
- wastedassign

# TODO: fix
- copyloopvar
- cyclop
- errcheck
- forbidigo
- goconst
- gocyclo
- govet
- inamedparam
- intrange
- maintidx
- nilnil
- predeclared
- revive
- staticcheck
- stylecheck
- tagliatelle

skip-dirs:
- gen

Expand Down Expand Up @@ -85,6 +100,9 @@ linters-settings:
- 'github\.com/zoncoen/scenarigo/template/ast\..+$'
- 'github\.com/zoncoen/scenarigo/template/parser\..+$'
- 'github\.com/zoncoen/scenarigo/template\.Template$'
gosec:
excludes:
- G115
maintidx:
under: 30
stylecheck:
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $(GOCREDITS): | $(BIN_DIR)
@$(GO) install github.com/Songmu/gocredits/cmd/[email protected]

GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
GOLANGCI_LINT_VERSION := 1.57.2
GOLANGCI_LINT_VERSION := 1.61.0
GOLANGCI_LINT_OS_ARCH := $(shell echo golangci-lint-$(GOLANGCI_LINT_VERSION)-$(GOOS)-$(GOARCH))
GOLANGCI_LINT_GZIP := $(GOLANGCI_LINT_OS_ARCH).tar.gz
$(GOLANGCI_LINT): | $(BIN_DIR)
Expand All @@ -78,10 +78,6 @@ $(GOLANGCI_LINT): | $(BIN_DIR)
@tar -C $(BIN_DIR) --strip=1 -xf $(GOLANGCI_LINT_GZIP) $(GOLANGCI_LINT_OS_ARCH)/golangci-lint
@rm $(GOLANGCI_LINT_GZIP)

LOOPPOINTER := $(BIN_DIR)/looppointer
$(LOOPPOINTER): | $(BIN_DIR)
@$(GO) install github.com/kyoh86/looppointer/cmd/[email protected]

.PHONY: build
build: | $(BIN_DIR)
@$(GO) install ./cmd/scenarigo
Expand Down Expand Up @@ -146,11 +142,6 @@ test/examples/%:
.PHONY: lint
lint: $(GOLANGCI_LINT) $(LOOPPOINTER) ## run lint
@$(GOLANGCI_LINT) run
@make lint/looppointer

.PHONY: lint/looppointer
lint/looppointer: $(LOOPPOINTER)
@$(GO) vet -vettool=$(LOOPPOINTER) ./...

.PHONY: lint/fix
lint/fix: $(GOLANGCI_LINT) $(LOOPPOINTER) ## fix lint errors
Expand Down
1 change: 0 additions & 1 deletion cmd/scenarigo/cmd/plugin/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ func (pb *pluginBuilder) updateReplaceDirectives(cmd *cobra.Command, goCmd strin
reason: fmt.Sprintf("change the replaced old version of %s from %s to %s", o.replace.Old.Path, o.replace.Old.Version, v.Old.Version),
}
}

}
if replace != nil {
if v, ok := requires[replace.Old.Path]; ok {
Expand Down
4 changes: 2 additions & 2 deletions cmd/scenarigo/cmd/plugin/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ func create(t *testing.T, path, content string) {
t.Fatalf("failed to create %s: %s", path, err)
}
defer f.Close()
if _, err := f.Write([]byte(content)); err != nil {
if _, err := f.WriteString(content); err != nil {
t.Fatalf("failed to write %s: %s", path, err)
}
}
Expand All @@ -2236,7 +2236,7 @@ func createExecutable(t *testing.T, path, stdout string) {
t.Fatalf("failed to create %s: %s", path, err)
}
defer f.Close()
if _, err := f.Write([]byte(fmt.Sprintf("#!%s\n%s %q", bash, echo, stdout))); err != nil {
if _, err := f.WriteString(fmt.Sprintf("#!%s\n%s %q", bash, echo, stdout)); err != nil {
t.Fatalf("failed to write %s: %s", path, err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/reflectutil/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getField(t *testing.T, v reflect.Value, name string) reflect.StructField {
}

type testStruct struct {
YAML string `yaml:"yamltag" json:"jsontag"`
YAML string `json:"jsontag" yaml:"yamltag"`
JSON string `json:"jsontag"`
Name string
}
6 changes: 3 additions & 3 deletions mock/protocol/grpc/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestUnaryHandler_failure(t *testing.T) {
svcName := protoreflect.FullName("scenarigo.testdata.test.Test")
sd, err := fds.ResolveService(svcName)
if err != nil {
t.Fatalf("failed to resovle service: %s", err)
t.Fatalf("failed to resolve service: %s", err)
}
md := sd.Methods().ByName("Echo")

Expand Down Expand Up @@ -139,7 +139,7 @@ func TestUnaryHandler_failure(t *testing.T) {
decode: func(_ any) error { return nil },
expect: ".response.message: failed to execute template of response",
},
"invalid reponse status code": {
"invalid response status code": {
mocks: []protocol.Mock{
{
Protocol: "grpc",
Expand All @@ -152,7 +152,7 @@ func TestUnaryHandler_failure(t *testing.T) {
decode: func(_ any) error { return nil },
expect: ".response.status.code: invalid status code",
},
"invalid reponse message": {
"invalid response message": {
mocks: []protocol.Mock{
{
Protocol: "grpc",
Expand Down
4 changes: 2 additions & 2 deletions protocol/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ func (*OneofMessage_A_) isOneofMessage_Value() {}
func (*OneofMessage_B_) isOneofMessage_Value() {}

type OneofMessage_A struct {
FooValue string `protobuf:"bytes,1,opt,name=foo_value,json=fooValue,proto3" json:"foo_value,omitempty"`
FooValue string `json:"foo_value,omitempty" protobuf:"bytes,1,opt,name=foo_value,json=fooValue,proto3"`
}

type OneofMessage_B struct {
BarValue string `protobuf:"bytes,1,opt,name=bar_value,json=barValue,proto3" json:"bar_value,omitempty"`
BarValue string `json:"bar_value,omitempty" protobuf:"bytes,1,opt,name=bar_value,json=barValue,proto3"`
}
12 changes: 6 additions & 6 deletions reporter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ This struct can be marshalled as JUnit-like format XML.
fmt.Println(b)
*/
type TestReport struct {
XMLName xml.Name `json:"-" xml:"testsuites"`
XMLName xml.Name `json:"-" xml:"testsuites"`
Name string `json:"name,omitempty" xml:"name,attr,omitempty"`
Result TestResult `json:"result" xml:"-"`
Files []ScenarioFileReport `json:"files" xml:"testsuite"`
Result TestResult `json:"result" xml:"-"`
Files []ScenarioFileReport `json:"files" xml:"testsuite"`
}

// ScenarioFileReport represents a result report of a test scenario file.
type ScenarioFileReport struct {
Name string `json:"name" xml:"name,attr,omitempty"`
Result TestResult `json:"result" xml:"-"`
Duration TestDuration `json:"duration" xml:"time,attr"`
Name string `json:"name" xml:"name,attr,omitempty"`
Result TestResult `json:"result" xml:"-"`
Duration TestDuration `json:"duration" xml:"time,attr"`
Scenarios []ScenarioReport `json:"scenarios" xml:"testcase"`
}

Expand Down
2 changes: 1 addition & 1 deletion schema/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *Scenario) Validate() error {

// Step represents a step of scenario.
type Step struct {
ID string `yaml:"id,omitempty" validate:"alphanum"`
ID string `validate:"alphanum" yaml:"id,omitempty"`
Title string `yaml:"title,omitempty"`
Description string `yaml:"description,omitempty"`
If string `yaml:"if,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func (s *testGRPCServer) Echo(ctx gocontext.Context, req *test.EchoRequest) (*te
return nil, sts.Err()
}
return &test.EchoResponse{
MessageId: req.MessageId,
MessageBody: req.MessageBody,
MessageId: req.GetMessageId(),
MessageBody: req.GetMessageBody(),
UserType: test.UserType_CUSTOMER,
State: test.State_ACTIVE,
}, nil
Expand Down

0 comments on commit 14bd62e

Please sign in to comment.