From e4cbe1caef07ade000667049416a15214e5d30eb Mon Sep 17 00:00:00 2001 From: esuwu Date: Mon, 16 Feb 2026 16:09:39 +0100 Subject: [PATCH 1/3] Added modernize to makefile --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1cc45c1830..e2e9ac87cb 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,9 @@ DEB_HASH=$(shell git rev-parse HEAD) export GO111MODULE=on -.PHONY: vendor vetcheck fmtcheck clean build gotest update-go-deps +.PHONY: vendor vetcheck modernize-check fmtcheck clean build gotest update-go-deps -all: vendor vetcheck fmtcheck gotest mod-clean build-node-native +all: vendor vetcheck modernize-check fmtcheck gotest mod-clean build-node-native ci: vendor vetcheck fmtcheck release-node build-importer-native gotest-race-coverage mod-clean @@ -71,6 +71,9 @@ vetcheck: golangci-lint run -c .golangci.yml golangci-lint run -c .golangci-strict.yml --new-from-rev=origin/master +modernize-check: + go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 ./... + strict-vet-check: golangci-lint run -c .golangci-strict.yml From 048cd229bf1e51525ef95c253bc252739aabe66d Mon Sep 17 00:00:00 2001 From: esuwu Date: Mon, 16 Feb 2026 16:14:31 +0100 Subject: [PATCH 2/3] Added filtering --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e2e9ac87cb..a2a2583ca4 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,10 @@ vetcheck: golangci-lint run -c .golangci-strict.yml --new-from-rev=origin/master modernize-check: - go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 ./... + @bash -lc 'set -o pipefail; \ + output=$$(go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest ./... 2>&1 | \ + grep -vE "\.(pb|gen)\.go|mock|_string.go|^exit status|^go: downloading"); \ + [ -n "$$output" ] && { echo "$$output"; exit 1; } || exit 0;' strict-vet-check: golangci-lint run -c .golangci-strict.yml From 2130dd7a80316626fb9fe01d9540253238de06d7 Mon Sep 17 00:00:00 2001 From: esuwu Date: Mon, 16 Feb 2026 16:15:33 +0100 Subject: [PATCH 3/3] Fixed a modernize issue --- pkg/ride/functions_strings.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/ride/functions_strings.go b/pkg/ride/functions_strings.go index 6ed7170cff..0be10d814e 100644 --- a/pkg/ride/functions_strings.go +++ b/pkg/ride/functions_strings.go @@ -457,10 +457,11 @@ func contains(_ environment, args ...rideType) (rideType, error) { } func runesIndex(s, sub string) int { - if i := strings.Index(s, sub); i >= 0 { - return utf8.RuneCountInString(s[:i]) + before, _, ok := strings.Cut(s, sub) + if !ok { + return -1 } - return -1 + return utf8.RuneCountInString(before) } func runesDrop(s string, n int) string {