From 23cdb349e0aee2eb70dc8c157eb5c0aaab0672d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Toledano?= Date: Tue, 24 Sep 2024 11:24:29 +0200 Subject: [PATCH] fix: lint (#157) --- .golangci.yml | 2 +- Makefile | 19 +++++++++++++++---- plugins.go | 8 ++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 408fd9a..cc5e4f9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,7 +11,7 @@ linters: - dogsled - errcheck - errorlint - - exportloopref + - copyloopvar - gci - goconst - gocritic diff --git a/Makefile b/Makefile index 60cb3b6..9899ddf 100644 --- a/Makefile +++ b/Makefile @@ -28,15 +28,26 @@ test-rosetta-ci: ### Linting ### ############################################################################### -golangci_lint_cmd=golangci-lint -golangci_version=v1.51.2 +golangci_version=v1.61.0 +golangci_installed_version=$(shell golangci-lint version --format short 2>/dev/null) + +#? lint-install: Install golangci-lint +lint-install: +ifneq ($(golangci_installed_version),$(golangci_version)) + @echo "--> Installing golangci-lint $(golangci_version)" + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) +endif + +#? lint: Run golangci-lint lint: @echo "--> Running linter" - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + $(MAKE) lint-install @./scripts/go-lint-all.bash --timeout=15m + +#? lint: Run golangci-lint and fix lint-fix: @echo "--> Running linter" - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + $(MAKE) lint-install @./scripts/go-lint-all.bash --fix .PHONY: all build rosetta test lint lint-fix diff --git a/plugins.go b/plugins.go index 50f83ed..1ba22a5 100644 --- a/plugins.go +++ b/plugins.go @@ -12,24 +12,24 @@ func LoadPlugin(ir codectypes.InterfaceRegistry, pluginLocation string) (err err pluginPathMain := fmt.Sprintf("./plugins/%s/main.so", pluginLocation) if _, err := os.Stat(pluginPathMain); os.IsExist(err) { - return fmt.Errorf(fmt.Sprintf("Plugin file '%s' does not exist %s", pluginPathMain, err.Error())) + return fmt.Errorf("plugin file '%s' does not exist %s", pluginPathMain, err.Error()) } // load module plug, err := plugin.Open(pluginPathMain) if err != nil { - return fmt.Errorf(fmt.Sprintf("There was an error while opening plugin on %s - %s", pluginPathMain, err.Error())) + return fmt.Errorf("there was an error while opening plugin on %s - %s", pluginPathMain, err.Error()) } initZone, err := plug.Lookup("InitZone") if err != nil { - return fmt.Errorf(fmt.Sprintf("There was an error while initializing the zone %s", err.Error())) + return fmt.Errorf("there was an error while initializing the zone %s", err.Error()) } initZone.(func())() registerInterfaces, err := plug.Lookup("RegisterInterfaces") if err != nil { - return fmt.Errorf(fmt.Sprintf("There was an error while registering interfaces %s", err.Error())) + return fmt.Errorf("there was an error while registering interfaces %s", err.Error()) } registerInterfaces.(func(codectypes.InterfaceRegistry))(ir)