From 60c75b659111ed4fc56af2f798627001a6d61819 Mon Sep 17 00:00:00 2001 From: adam jones Date: Tue, 26 Aug 2025 15:16:43 +0100 Subject: [PATCH] Disable ireturn linter rule (#307) ## Summary - Disable the `ireturn` linter rule in golangci-lint configuration - Remove all related `nolint:ireturn` comments from the codebase The `ireturn` rule was flagging factory functions that intentionally return interfaces for dependency injection, which is a common and valid Go pattern. Since this pattern is used extensively throughout the codebase for good architectural reasons, it makes sense to disable this rule entirely. It also seems buggy, and seems to conflict with other lint rules - causing unnecessary toil.See: https://stackoverflow.com/questions/72385337/golang-linter-always-complains --- .golangci.yml | 1 - internal/api/router/router.go | 2 -- internal/service/fake_service.go | 6 ++---- internal/service/registry_service.go | 2 -- tools/publisher/auth/dns.go | 2 -- tools/publisher/auth/github-at.go | 2 -- tools/publisher/auth/github-oidc.go | 2 -- tools/publisher/auth/http.go | 1 - tools/publisher/auth/none.go | 1 - 9 files changed, 2 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 81a2485..0d70d2d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -27,7 +27,6 @@ linters: - gosec - grouper - importas - - ireturn - makezero - misspell - nakedret diff --git a/internal/api/router/router.go b/internal/api/router/router.go index cb18a69..0609f80 100644 --- a/internal/api/router/router.go +++ b/internal/api/router/router.go @@ -92,8 +92,6 @@ func WithSkipPaths(paths ...string) MiddlewareOption { } // NewHumaAPI creates a new Huma API with all routes registered -// -//nolint:ireturn // huma.API is the expected interface type for Huma APIs func NewHumaAPI(cfg *config.Config, registry service.RegistryService, mux *http.ServeMux, metrics *telemetry.Metrics) huma.API { // Create Huma API configuration humaConfig := huma.DefaultConfig("MCP Registry API", "1.0.0") diff --git a/internal/service/fake_service.go b/internal/service/fake_service.go index 61f6908..3f33322 100644 --- a/internal/service/fake_service.go +++ b/internal/service/fake_service.go @@ -15,8 +15,6 @@ type fakeRegistryService struct { } // NewFakeRegistryService creates a new fake registry service with pre-populated data -// -//nolint:ireturn // Factory function intentionally returns interface for dependency injection func NewFakeRegistryService() RegistryService { // Sample registry entries with updated model structure using ServerDetail serverDetails := []*model.ServerDetail{ @@ -81,7 +79,7 @@ func (s *fakeRegistryService) List(cursor string, limit int) ([]model.ServerResp if err != nil { return nil, "", err } - + // Convert ServerRecord to ServerResponse format result := make([]model.ServerResponse, len(serverRecords)) for i, record := range serverRecords { @@ -151,4 +149,4 @@ func (s *fakeRegistryService) Publish(req model.PublishRequest) (*model.ServerRe // Close closes the in-memory database connection func (s *fakeRegistryService) Close() error { return s.db.Close() -} \ No newline at end of file +} diff --git a/internal/service/registry_service.go b/internal/service/registry_service.go index b703846..6fc76c5 100644 --- a/internal/service/registry_service.go +++ b/internal/service/registry_service.go @@ -18,8 +18,6 @@ type registryServiceImpl struct { } // NewRegistryServiceWithDB creates a new registry service with the provided database -// -//nolint:ireturn // Factory function intentionally returns interface for dependency injection func NewRegistryServiceWithDB(db database.Database) RegistryService { return ®istryServiceImpl{ db: db, diff --git a/tools/publisher/auth/dns.go b/tools/publisher/auth/dns.go index ce245ce..7618318 100644 --- a/tools/publisher/auth/dns.go +++ b/tools/publisher/auth/dns.go @@ -5,8 +5,6 @@ type DNSProvider struct { } // NewDNSProvider creates a new DNS-based auth provider -// -//nolint:ireturn // Factory function intentionally returns interface for dependency injection func NewDNSProvider(registryURL, domain, hexSeed string) Provider { return &DNSProvider{ CryptoProvider: &CryptoProvider{ diff --git a/tools/publisher/auth/github-at.go b/tools/publisher/auth/github-at.go index 69a78fb..fb51a9f 100644 --- a/tools/publisher/auth/github-at.go +++ b/tools/publisher/auth/github-at.go @@ -63,8 +63,6 @@ type ServerHealthResponse struct { } // NewGitHubATProvider creates a new GitHub OAuth provider -// -//nolint:ireturn // Factory function intentionally returns interface for dependency injection func NewGitHubATProvider(forceLogin bool, registryURL string) Provider { return &GitHubATProvider{ forceLogin: forceLogin, diff --git a/tools/publisher/auth/github-oidc.go b/tools/publisher/auth/github-oidc.go index 6668d9b..7caebfe 100644 --- a/tools/publisher/auth/github-oidc.go +++ b/tools/publisher/auth/github-oidc.go @@ -15,8 +15,6 @@ type GitHubOIDCProvider struct { } // NewGitHubOIDCProvider creates a new GitHub OIDC provider -// -//nolint:ireturn // Factory function intentionally returns interface for dependency injection func NewGitHubOIDCProvider(registryURL string) Provider { return &GitHubOIDCProvider{ registryURL: registryURL, diff --git a/tools/publisher/auth/http.go b/tools/publisher/auth/http.go index cb40ac6..c4a26d1 100644 --- a/tools/publisher/auth/http.go +++ b/tools/publisher/auth/http.go @@ -5,7 +5,6 @@ type HTTPProvider struct { } // NewHTTPProvider creates a new HTTP-based auth provider -//nolint:ireturn // Factory function returns interface by design func NewHTTPProvider(registryURL, domain, hexSeed string) Provider { return &HTTPProvider{ CryptoProvider: &CryptoProvider{ diff --git a/tools/publisher/auth/none.go b/tools/publisher/auth/none.go index d7a1823..a822cba 100644 --- a/tools/publisher/auth/none.go +++ b/tools/publisher/auth/none.go @@ -19,7 +19,6 @@ type TokenResponse struct { ExpiresAt int64 `json:"expires_at"` } -//nolint:ireturn // Factory function returns interface by design func NewNoneProvider(registryURL string) Provider { return &NoneProvider{ registryURL: registryURL,