Skip to content

Commit 0c6bb03

Browse files
authored
Merge pull request #63 from sivchari/modernize-project
modernize sources
2 parents 2e78eb0 + a45bde9 commit 0c6bb03

File tree

22 files changed

+92
-76
lines changed

22 files changed

+92
-76
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: golangci-lint
1+
name: lint
22
on:
33
push:
44
branches:
@@ -11,15 +11,14 @@ permissions:
1111
# pull-requests: read
1212

1313
jobs:
14-
golangci:
15-
name: lint
14+
lint:
15+
name: golangci-lint
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
1919
- uses: actions/setup-go@v5
2020
with:
2121
go-version-file: 'go.mod'
2222
- name: golangci-lint
23-
uses: golangci/golangci-lint-action@v7
24-
with:
25-
version: v2.0.2
23+
run: |
24+
make lint

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
22
GOLANGCI_LINT = go tool -modfile tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint
3+
MODERNIZE = go tool -modfile tools/go.mod golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize
34

45
VERSION ?= $(shell git describe --always --abbrev=7)
56

@@ -34,12 +35,26 @@ vet: ## Run go vet against code.
3435
go vet ./...
3536

3637
.PHONY: lint
37-
lint: ## Run golangci-lint over the codebase.
38-
${GOLANGCI_LINT} run ./... --timeout 5m -v ${GOLANGCI_LINT_EXTRA_ARGS}
38+
lint: golangci-lint modernize
3939

4040
.PHONY: lint-fix
41-
lint-fix: GOLANGCI_LINT_EXTRA_ARGS := --fix
42-
lint-fix: lint ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
41+
lint-fix: golangci-lint-fix modernize-fix
42+
43+
.PHONY: golangci-lint
44+
golangci-lint: ## Run golangci-lint over the codebase.
45+
${GOLANGCI_LINT} run ./... --timeout 5m -v ${GOLANGCI_LINT_EXTRA_ARGS}
46+
47+
.PHONY: golangci-lint-fix
48+
golangci-lint-fix: GOLANGCI_LINT_EXTRA_ARGS := --fix
49+
golangci-lint-fix: golangci-lint ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
50+
51+
.PHONY: modernize
52+
modernize: ## Run modernize on the codebase.
53+
${MODERNIZE} -diff ./...
54+
55+
.PHONY: modernize-fix
56+
modernize-fix: ## Run modernize on the codebase and apply fixes.
57+
${MODERNIZE} -fix ./...
4358

4459
.PHONY: test
4560
test: fmt vet unit ## Run tests.

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module sigs.k8s.io/kube-api-linter
22

3-
go 1.24.0
3+
go 1.24.2
44

55
require (
66
github.com/golangci/plugin-module-register v0.1.1
7-
github.com/onsi/ginkgo/v2 v2.22.2
8-
github.com/onsi/gomega v1.36.2
7+
github.com/onsi/ginkgo/v2 v2.23.3
8+
github.com/onsi/gomega v1.36.3
99
golang.org/x/tools v0.32.0
1010
k8s.io/apimachinery v0.32.3
1111
)
@@ -23,7 +23,7 @@ require (
2323
golang.org/x/sync v0.13.0 // indirect
2424
golang.org/x/sys v0.32.0 // indirect
2525
golang.org/x/text v0.24.0 // indirect
26-
google.golang.org/protobuf v1.36.5 // indirect
26+
google.golang.org/protobuf v1.36.6 // indirect
2727
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2828
gopkg.in/yaml.v3 v3.0.1 // indirect
2929
)

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
55
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
66
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
77
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
8+
github.com/golangci/golangci-lint/v2 v2.0.0 h1:RQWk8VCuMQv9bBDy3x23yds2yf9aRZ86C9MWGIdNRuU=
9+
github.com/golangci/golangci-lint/v2 v2.0.0/go.mod h1:ptNNMeGBQrbves0Qq38xvfdJg18PzxmT+7KRCOpm6i8=
810
github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c=
911
github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc=
1012
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
@@ -18,10 +20,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1820
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1921
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2022
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
21-
github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
22-
github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
23-
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
24-
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
23+
github.com/onsi/ginkgo/v2 v2.23.3 h1:edHxnszytJ4lD9D5Jjc4tiDkPBZ3siDeJJkUZJJVkp0=
24+
github.com/onsi/ginkgo/v2 v2.23.3/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM=
25+
github.com/onsi/gomega v1.36.3 h1:hID7cr8t3Wp26+cYnfcjR6HpJ00fdogN6dqZ1t6IylU=
26+
github.com/onsi/gomega v1.36.3/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
2527
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
2628
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
2729
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -42,8 +44,8 @@ golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
4244
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
4345
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
4446
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
45-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
46-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
47+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
48+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
4749
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4850
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
4951
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

pkg/analysis/commentstart/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var Analyzer = &analysis.Analyzer{
4040
Requires: []*analysis.Analyzer{inspector.Analyzer},
4141
}
4242

43-
func run(pass *analysis.Pass) (interface{}, error) {
43+
func run(pass *analysis.Pass) (any, error) {
4444
inspect, ok := pass.ResultOf[inspector.Analyzer].(inspector.Inspector)
4545
if !ok {
4646
return nil, kalerrors.ErrCouldNotGetInspector

pkg/analysis/conditions/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func newAnalyzer(cfg config.ConditionsConfig) *analysis.Analyzer {
8686
}
8787
}
8888

89-
func (a *analyzer) run(pass *analysis.Pass) (interface{}, error) {
89+
func (a *analyzer) run(pass *analysis.Pass) (any, error) {
9090
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
9191
if !ok {
9292
return nil, kalerrors.ErrCouldNotGetInspector

pkg/analysis/helpers/extractjsontags/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var Analyzer = &analysis.Analyzer{
6464
ResultType: reflect.TypeOf(newStructFieldTags()),
6565
}
6666

67-
func run(pass *analysis.Pass) (interface{}, error) {
67+
func run(pass *analysis.Pass) (any, error) {
6868
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
6969
if !ok {
7070
return nil, kalerrors.ErrCouldNotGetInspector

pkg/analysis/helpers/inspector/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var Analyzer = &analysis.Analyzer{
4040
ResultType: reflect.TypeOf(newInspector(nil, nil, nil)),
4141
}
4242

43-
func run(pass *analysis.Pass) (interface{}, error) {
43+
func run(pass *analysis.Pass) (any, error) {
4444
astinspector, ok := pass.ResultOf[inspect.Analyzer].(*astinspector.Inspector)
4545
if !ok {
4646
return nil, kalerrors.ErrCouldNotGetInspector

pkg/analysis/helpers/inspector/analyzer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var testAnalyzer = &analysis.Analyzer{
4242
Requires: []*analysis.Analyzer{inspector.Analyzer},
4343
}
4444

45-
func run(pass *analysis.Pass) (interface{}, error) {
45+
func run(pass *analysis.Pass) (any, error) {
4646
inspect, ok := pass.ResultOf[inspector.Analyzer].(inspector.Inspector)
4747
if !ok {
4848
return nil, errCouldNotGetInspector

pkg/analysis/helpers/markers/analyzer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var Analyzer = &analysis.Analyzer{
113113
ResultType: reflect.TypeOf(newMarkers()),
114114
}
115115

116-
func run(pass *analysis.Pass) (interface{}, error) {
116+
func run(pass *analysis.Pass) (any, error) {
117117
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
118118
if !ok {
119119
return nil, kalerrors.ErrCouldNotGetInspector
@@ -239,8 +239,8 @@ func extractExpressions(expressions string) map[string]string {
239239

240240
// split expression string on commas (,) to handle multiple expressions
241241
// in a single marker
242-
chainedExpressions := strings.Split(expressions, ",")
243-
for _, chainedExpression := range chainedExpressions {
242+
chainedExpressions := strings.SplitSeq(expressions, ",")
243+
for chainedExpression := range chainedExpressions {
244244
exps := strings.SplitN(chainedExpression, "=", 2)
245245
if len(exps) < 2 {
246246
continue

0 commit comments

Comments
 (0)