diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr-workflow.yaml index c5562a8..8cf6698 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/pr-workflow.yaml @@ -34,9 +34,9 @@ jobs: files=$(gofmt -l .) && echo $files && [ -z "$files" ] - name: Golang CI Lint - uses: golangci/golangci-lint-action@v7 + uses: golangci/golangci-lint-action@v8 with: - version: v2.0.1 + version: v2.1.6 args: --timeout 10m unit-tests: diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..8ee4342 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,51 @@ +version: "2" +linters: + enable: + - bodyclose + - containedctx + - contextcheck + - errorlint + - goconst + - godot + - importas + - nilerr + - promlinter + - revive + - sloglint + - testifylint + - unparam + - usestdlibvars + settings: + importas: + alias: + - pkg: ^k8s\.io/apimachinery/pkg/apis/(\w+)/(v[\w\d]+)$ + alias: $1$2 + revive: + rules: + - name: exported + exclusions: + generated: lax + paths: + - generated.*\.go$ + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - goimports + settings: + gci: + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(github.com/qdrant) # Custom section: groups all imports with the specified Prefix (our company, but our own component). + - prefix(github.com/qdrant/qdrant-cloud-buf-plugin/) # Custom section: groups all imports with the specified Prefix (this component). + exclusions: + generated: lax + paths: + - generated.*\.go$ + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 2ffa2ae..2faf1b6 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint GCI = $(LOCALBIN)/gci ## Tool Versions -GOLANGCI_LINT_VERSION ?= v2.0.1 +GOLANGCI_LINT_VERSION ?= v2.1.6 GCI_VERSION ?= v0.13.5 .PHONY: bootstrap diff --git a/cmd/buf-plugin-required-fields/main.go b/cmd/buf-plugin-required-fields/main.go index b6afb6d..1150bce 100644 --- a/cmd/buf-plugin-required-fields/main.go +++ b/cmd/buf-plugin-required-fields/main.go @@ -137,7 +137,7 @@ func getRequiredEntityFields(request check.Request) ([]string, error) { // extractEntityNames returns a set of entity names inferred from the name of // the service methods. -// e.g: [ListBooks, GetBook] -> {Book} +// e.g: [ListBooks, GetBook] -> {Book}. func extractEntityNames(fileDescriptor descriptor.FileDescriptor) map[string]struct{} { entityNames := make(map[string]struct{}) services := fileDescriptor.FileDescriptorProto().GetService() @@ -152,7 +152,7 @@ func extractEntityNames(fileDescriptor descriptor.FileDescriptor) map[string]str return entityNames } -// inferEntityFromMethodName extracts the entity name by stripping CRUD prefixes +// inferEntityFromMethodName extracts the entity name by stripping CRUD prefixes. func inferEntityFromMethodName(methodName string) string { p := pluralize.NewClient() for _, prefix := range crudMethodPrefixes {