From e0d9212678a032a38fc33225bc4cca3144ada0f6 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Mon, 26 Dec 2022 20:09:34 +0600 Subject: [PATCH] :art: Format GolangCI-Lint comments --- internal/auth/delivery/http/auth_http.go | 4 ++-- internal/auth/delivery/http/auth_http_test.go | 2 +- internal/client/delivery/http/client_http.go | 2 +- internal/client/repository/http/http_client.go | 2 +- internal/domain/action.go | 4 ++-- internal/domain/action_test.go | 2 +- internal/domain/client_id.go | 7 ++++--- internal/domain/code_challenge_method.go | 6 +++--- internal/domain/code_challenge_method_test.go | 4 ++-- internal/domain/config.go | 3 ++- internal/domain/email_test.go | 2 +- internal/domain/error.go | 4 ++-- internal/domain/grant_type.go | 4 ++-- internal/domain/grant_type_test.go | 2 +- internal/domain/me.go | 3 ++- internal/domain/provider.go | 2 +- internal/domain/response_type.go | 2 +- internal/domain/response_type_test.go | 2 +- internal/domain/scope.go | 4 ++-- internal/domain/scope_test.go | 1 - internal/domain/session.go | 5 +++-- internal/domain/token.go | 9 ++++++--- internal/httputil/httputil.go | 2 +- internal/metadata/delivery/http/metadata_http.go | 8 ++++---- internal/metadata/repository/http/http_metadata.go | 4 ++-- internal/profile/repository/http/http_profile.go | 2 +- .../session/repository/sqlite3/sqlite3_session.go | 6 +++--- internal/testing/httptest/httptest.go | 10 +++++----- internal/ticket/delivery/http/ticket_http.go | 2 +- internal/ticket/repository/sqlite3/sqlite3_ticket.go | 2 +- internal/ticket/usecase/ticket_ucase.go | 2 +- internal/token/delivery/http/token_http.go | 8 ++++---- internal/token/delivery/http/token_http_test.go | 2 +- .../token/repository/sqlite3/sqlite3_token_test.go | 2 +- internal/token/usecase/token_ucase.go | 4 ++-- internal/user/delivery/http/user_http.go | 10 +++++----- internal/user/repository/http/http_user.go | 2 +- main.go | 12 ++++++------ 38 files changed, 80 insertions(+), 74 deletions(-) diff --git a/internal/auth/delivery/http/auth_http.go b/internal/auth/delivery/http/auth_http.go index 6b95c33..f106352 100644 --- a/internal/auth/delivery/http/auth_http.go +++ b/internal/auth/delivery/http/auth_http.go @@ -347,7 +347,7 @@ func NewAuthAuthorizationRequest() *AuthAuthorizationRequest { } } -//nolint: cyclop +//nolint:cyclop func (r *AuthAuthorizationRequest) bind(ctx *http.RequestCtx) error { indieAuthError := new(domain.Error) if err := form.Unmarshal(ctx.QueryArgs().QueryString(), r); err != nil { @@ -384,7 +384,7 @@ func NewAuthVerifyRequest() *AuthVerifyRequest { } } -//nolint: funlen,cyclop +//nolint:funlen,cyclop func (r *AuthVerifyRequest) bind(ctx *http.RequestCtx) error { indieAuthError := new(domain.Error) diff --git a/internal/auth/delivery/http/auth_http_test.go b/internal/auth/delivery/http/auth_http_test.go index 4b2d905..7d11b48 100644 --- a/internal/auth/delivery/http/auth_http_test.go +++ b/internal/auth/delivery/http/auth_http_test.go @@ -50,7 +50,7 @@ func TestAuthorize(t *testing.T) { deps.store.Store(path.Join(userrepo.DefaultPathPrefix, me.String()), user) r := router.New() - //nolint: exhaustivestruct + //nolint:exhaustivestruct delivery.NewRequestHandler(delivery.NewRequestHandlerOptions{ Auth: deps.authService, Clients: deps.clientService, diff --git a/internal/client/delivery/http/client_http.go b/internal/client/delivery/http/client_http.go index 6eb0da6..e553d85 100644 --- a/internal/client/delivery/http/client_http.go +++ b/internal/client/delivery/http/client_http.go @@ -87,7 +87,7 @@ func (h *RequestHandler) handleRender(ctx *http.RequestCtx) { }) } -//nolint: funlen +//nolint:unlen func (h *RequestHandler) handleCallback(ctx *http.RequestCtx) { ctx.SetContentType(common.MIMETextHTMLCharsetUTF8) diff --git a/internal/client/repository/http/http_client.go b/internal/client/repository/http/http_client.go index e7f9b2d..7fe2391 100644 --- a/internal/client/repository/http/http_client.go +++ b/internal/client/repository/http/http_client.go @@ -76,7 +76,7 @@ func (repo *httpClientRepository) Get(ctx context.Context, cid *domain.ClientID) return client, nil } -//nolint: gocognit, cyclop +//nolint:gocognit,cyclop func extract(dst *domain.Client, src *http.Response) { for _, endpoint := range httputil.ExtractEndpoints(src, relRedirectURI) { if !containsURL(dst.RedirectURI, endpoint) { diff --git a/internal/domain/action.go b/internal/domain/action.go index e8b7516..34ce890 100644 --- a/internal/domain/action.go +++ b/internal/domain/action.go @@ -15,7 +15,7 @@ type Action struct { uid string } -//nolint: gochecknoglobals // structs cannot be constants +//nolint:gochecknoglobals // structs cannot be constants var ( ActionUnd = Action{uid: ""} // "und" @@ -28,7 +28,7 @@ var ( var ErrActionSyntax error = NewError(ErrorCodeInvalidRequest, "unknown action method", "") -//nolint: gochecknoglobals +//nolint:gochecknoglobals var uidsActions = map[string]Action{ ActionRevoke.uid: ActionRevoke, ActionTicket.uid: ActionTicket, diff --git a/internal/domain/action_test.go b/internal/domain/action_test.go index d32a320..5d3ec07 100644 --- a/internal/domain/action_test.go +++ b/internal/domain/action_test.go @@ -1,4 +1,4 @@ -//nolint: dupl +//nolint:dupl package domain_test import ( diff --git a/internal/domain/client_id.go b/internal/domain/client_id.go index 8bc5179..f100b9e 100644 --- a/internal/domain/client_id.go +++ b/internal/domain/client_id.go @@ -16,14 +16,15 @@ type ClientID struct { clientID *http.URI } -//nolint: gochecknoglobals // slices cannot be constants +//nolint:gochecknoglobals // slices cannot be constants var ( localhostIPv4 = netaddr.MustParseIP("127.0.0.1") localhostIPv6 = netaddr.MustParseIP("::1") ) // ParseClientID parse string as client ID URL identifier. -//nolint: funlen, cyclop +// +//nolint:funlen,cyclop func ParseClientID(src string) (*ClientID, error) { cid := http.AcquireURI() if err := cid.Parse(nil, []byte(src)); err != nil { @@ -82,7 +83,7 @@ func ParseClientID(src string) (*ClientID, error) { if err != nil { ipPort, err := netaddr.ParseIPPort(domain) if err != nil { - //nolint: nilerr // ClientID does not contain an IP address, so it is valid + //nolint:nilerr // ClientID does not contain an IP address, so it is valid return &ClientID{clientID: cid}, nil } diff --git a/internal/domain/code_challenge_method.go b/internal/domain/code_challenge_method.go index dc0fd96..f2618a0 100644 --- a/internal/domain/code_challenge_method.go +++ b/internal/domain/code_challenge_method.go @@ -1,6 +1,6 @@ package domain -//nolint: gosec // support old clients +//nolint:gosec // support old clients import ( "crypto/md5" "crypto/sha1" @@ -23,7 +23,7 @@ type CodeChallengeMethod struct { uid string } -//nolint: gochecknoglobals // structs cannot be constants +//nolint:gochecknoglobals // structs cannot be constants var ( CodeChallengeMethodUnd = CodeChallengeMethod{uid: ""} // "und" CodeChallengeMethodPLAIN = CodeChallengeMethod{uid: "plain"} // "PLAIN" @@ -39,7 +39,7 @@ var ErrCodeChallengeMethodUnknown error = NewError( "https://indieauth.net/source/#authorization-request", ) -//nolint: gochecknoglobals // maps cannot be constants +//nolint:gochecknoglobals // maps cannot be constants var uidsMethods = map[string]CodeChallengeMethod{ CodeChallengeMethodMD5.uid: CodeChallengeMethodMD5, CodeChallengeMethodPLAIN.uid: CodeChallengeMethodPLAIN, diff --git a/internal/domain/code_challenge_method_test.go b/internal/domain/code_challenge_method_test.go index a5392f8..71d6dfa 100644 --- a/internal/domain/code_challenge_method_test.go +++ b/internal/domain/code_challenge_method_test.go @@ -1,6 +1,6 @@ package domain_test -//nolint: gosec // support old clients +//nolint:gosec // support old clients import ( "crypto/md5" "crypto/sha1" @@ -110,7 +110,7 @@ func TestCodeChallengeMethod_String(t *testing.T) { } } -//nolint: gosec // support old clients +//nolint:gosec // support old clients func TestCodeChallengeMethod_Validate(t *testing.T) { t.Parallel() diff --git a/internal/domain/config.go b/internal/domain/config.go index 210ee4e..8ff61d9 100644 --- a/internal/domain/config.go +++ b/internal/domain/config.go @@ -78,7 +78,8 @@ type ( ) // TestConfig returns a valid config for tests. -//nolint: gomnd // testing domain can contains non-standart values +// +//nolint:gomnd // testing domain can contains non-standart values func TestConfig(tb testing.TB) *Config { tb.Helper() diff --git a/internal/domain/email_test.go b/internal/domain/email_test.go index 959e973..64e8ce8 100644 --- a/internal/domain/email_test.go +++ b/internal/domain/email_test.go @@ -39,7 +39,7 @@ func TestParseEmail(t *testing.T) { func TestEmail_String(t *testing.T) { t.Parallel() - email := domain.TestEmail(t) //nolint: ifshort + email := domain.TestEmail(t) //nolint:ifshort if result := email.String(); result != fmt.Sprint(email) { t.Errorf("String() = %v, want %v", result, email) } diff --git a/internal/domain/error.go b/internal/domain/error.go index 37842fd..03302ce 100644 --- a/internal/domain/error.go +++ b/internal/domain/error.go @@ -13,7 +13,7 @@ import ( type ( // Error describes the format of a typical IndieAuth error. - //nolint: tagliatelle // RFC 6749 section 5.2 + //nolint:tagliatelle // RFC 6749 section 5.2 Error struct { // A single error code. Code ErrorCode `json:"error"` @@ -150,7 +150,7 @@ var ( var ErrErrorCodeUnknown error = NewError(ErrorCodeInvalidRequest, "unknown error code", "") -//nolint: gochecknoglobals // maps cannot be constants +//nolint:gochecknoglobals // maps cannot be constants var uidsErrorCodes = map[string]ErrorCode{ ErrorCodeAccessDenied.uid: ErrorCodeAccessDenied, ErrorCodeInsufficientScope.uid: ErrorCodeInsufficientScope, diff --git a/internal/domain/grant_type.go b/internal/domain/grant_type.go index 2ac1b05..899c28d 100644 --- a/internal/domain/grant_type.go +++ b/internal/domain/grant_type.go @@ -16,7 +16,7 @@ type GrantType struct { uid string } -//nolint: gochecknoglobals // structs cannot be constants +//nolint:gochecknoglobals // structs cannot be constants var ( GrantTypeUnd = GrantType{uid: ""} // "und" GrantTypeAuthorizationCode = GrantType{uid: "authorization_code"} // "authorization_code" @@ -32,7 +32,7 @@ var ErrGrantTypeUnknown error = NewError( "", ) -//nolint: gochecknoglobals // maps cannot be constants +//nolint:gochecknoglobals // maps cannot be constants var uidsGrantTypes = map[string]GrantType{ GrantTypeAuthorizationCode.uid: GrantTypeAuthorizationCode, GrantTypeRefreshToken.uid: GrantTypeRefreshToken, diff --git a/internal/domain/grant_type_test.go b/internal/domain/grant_type_test.go index 49e1d1f..0d359a7 100644 --- a/internal/domain/grant_type_test.go +++ b/internal/domain/grant_type_test.go @@ -1,4 +1,4 @@ -//nolint: dupl +//nolint:dupl package domain_test import ( diff --git a/internal/domain/me.go b/internal/domain/me.go index 9ce6c18..d89d870 100644 --- a/internal/domain/me.go +++ b/internal/domain/me.go @@ -17,7 +17,8 @@ type Me struct { } // ParseMe parse string as me URL identifier. -//nolint: funlen, cyclop +// +//nolint:funlen,cyclop func ParseMe(raw string) (*Me, error) { id := http.AcquireURI() if err := id.Parse(nil, []byte(raw)); err != nil { diff --git a/internal/domain/provider.go b/internal/domain/provider.go index 33970e0..377bac1 100644 --- a/internal/domain/provider.go +++ b/internal/domain/provider.go @@ -21,7 +21,7 @@ type Provider struct { URL string } -//nolint: gochecknoglobals // structs cannot be contants +//nolint:gochecknoglobals // structs cannot be contants var ( ProviderDirect = Provider{ AuthURL: "/authorize", diff --git a/internal/domain/response_type.go b/internal/domain/response_type.go index 1bcda95..c610a88 100644 --- a/internal/domain/response_type.go +++ b/internal/domain/response_type.go @@ -14,7 +14,7 @@ type ResponseType struct { uid string } -//nolint: gochecknoglobals // structs cannot be constants +//nolint:gochecknoglobals // structs cannot be constants var ( ResponseTypeUnd = ResponseType{uid: ""} // "und" diff --git a/internal/domain/response_type_test.go b/internal/domain/response_type_test.go index 9b7ca99..91a8619 100644 --- a/internal/domain/response_type_test.go +++ b/internal/domain/response_type_test.go @@ -1,4 +1,4 @@ -//nolint: dupl +//nolint:dupl package domain_test import ( diff --git a/internal/domain/scope.go b/internal/domain/scope.go index ac6199a..6c7adb3 100644 --- a/internal/domain/scope.go +++ b/internal/domain/scope.go @@ -23,7 +23,7 @@ type ( var ErrScopeUnknown error = NewError(ErrorCodeInvalidRequest, "unknown scope", "https://indieweb.org/scope") -//nolint: gochecknoglobals // structs cannot be constants +//nolint:gochecknoglobals // structs cannot be constants var ( ScopeUnd = Scope{uid: ""} // "und" @@ -59,7 +59,7 @@ var ( ScopeEmail = Scope{uid: "email"} // "email" ) -//nolint: gochecknoglobals // maps cannot be constants +//nolint:gochecknoglobals // maps cannot be constants var uidsScopes = map[string]Scope{ ScopeBlock.uid: ScopeBlock, ScopeChannels.uid: ScopeChannels, diff --git a/internal/domain/scope_test.go b/internal/domain/scope_test.go index ed3cf5a..5f4fac7 100644 --- a/internal/domain/scope_test.go +++ b/internal/domain/scope_test.go @@ -95,7 +95,6 @@ func TestScopes_MarshalJSON(t *testing.T) { func TestScope_String(t *testing.T) { t.Parallel() - //nolint: paralleltest // false positive, in is used for _, tc := range []struct { in domain.Scope out string diff --git a/internal/domain/session.go b/internal/domain/session.go index c4036e3..23869d7 100644 --- a/internal/domain/session.go +++ b/internal/domain/session.go @@ -6,7 +6,7 @@ import ( "source.toby3d.me/toby3d/auth/internal/random" ) -//nolint: tagliatelle +//nolint:tagliatelle type Session struct { ClientID *ClientID `json:"client_id"` RedirectURI *URL `json:"redirect_uri"` @@ -19,7 +19,8 @@ type Session struct { } // TestSession returns valid random generated session for tests. -//nolint: gomnd // testing domain can contains non-standart values +// +//nolint:gomnd // testing domain can contains non-standart values func TestSession(tb testing.TB) *Session { tb.Helper() diff --git a/internal/domain/token.go b/internal/domain/token.go index c8303f8..8acd927 100644 --- a/internal/domain/token.go +++ b/internal/domain/token.go @@ -37,7 +37,8 @@ type ( ) // DefaultNewTokenOptions describes the default settings for NewToken. -//nolint: gochecknoglobals, gomnd +// +//nolint:gochecknoglobals,gomnd var DefaultNewTokenOptions = NewTokenOptions{ Expiration: 0, Scope: nil, @@ -49,7 +50,8 @@ var DefaultNewTokenOptions = NewTokenOptions{ } // NewToken create a new token by provided options. -//nolint: cyclop +// +//nolint:cyclop func NewToken(opts NewTokenOptions) (*Token, error) { if opts.NonceLength == 0 { opts.NonceLength = DefaultNewTokenOptions.NonceLength @@ -109,7 +111,8 @@ func NewToken(opts NewTokenOptions) (*Token, error) { } // TestToken returns valid random generated token for tests. -//nolint: gomnd // testing domain can contains non-standart values +// +//nolint:gomnd // testing domain can contains non-standart values func TestToken(tb testing.TB) *Token { tb.Helper() diff --git a/internal/httputil/httputil.go b/internal/httputil/httputil.go index 009cd0f..9b22a36 100644 --- a/internal/httputil/httputil.go +++ b/internal/httputil/httputil.go @@ -95,7 +95,7 @@ func ExtractMetadata(resp *http.Response, client *http.Client) (*domain.Metadata } func ExtractProperty(resp *http.Response, itemType, key string) []interface{} { - //nolint: exhaustivestruct // only Host part in url.URL is needed + //nolint:exhaustivestruct // only Host part in url.URL is needed data := microformats.Parse(bytes.NewReader(resp.Body()), &url.URL{ Host: string(resp.Header.Peek(http.HeaderHost)), }) diff --git a/internal/metadata/delivery/http/metadata_http.go b/internal/metadata/delivery/http/metadata_http.go index a28b988..d65d553 100644 --- a/internal/metadata/delivery/http/metadata_http.go +++ b/internal/metadata/delivery/http/metadata_http.go @@ -11,7 +11,7 @@ import ( ) type ( - //nolint: tagliatelle // https://indieauth.net/source/#indieauth-server-metadata + //nolint:tagliatelle // https://indieauth.net/source/#indieauth-server-metadata MetadataResponse struct { // The server's issuer identifier. Issuer string `json:"issuer"` @@ -27,13 +27,13 @@ type ( // JSON array containing a list of client authentication methods // supported by this introspection endpoint. - IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"` //nolint: lll + IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"` //nolint:lll // The Revocation Endpoint. RevocationEndpoint string `json:"revocation_endpoint,omitempty"` // JSON array containing the value "none". - RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"` //nolint: lll + RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"` //nolint:lll // JSON array containing scope values supported by the // IndieAuth server. @@ -54,7 +54,7 @@ type ( // Boolean parameter indicating whether the authorization server // provides the iss parameter. - AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"` //nolint: lll + AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"` //nolint:lll // The User Info Endpoint. UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"` diff --git a/internal/metadata/repository/http/http_metadata.go b/internal/metadata/repository/http/http_metadata.go index 6b40123..b35d622 100644 --- a/internal/metadata/repository/http/http_metadata.go +++ b/internal/metadata/repository/http/http_metadata.go @@ -13,7 +13,7 @@ import ( ) type ( - //nolint: tagliatelle,lll + //nolint:tagliatelle,lll Metadata struct { Issuer *domain.ClientID `json:"issuer"` AuthorizationEndpoint *domain.URL `json:"authorization_endpoint"` @@ -72,7 +72,7 @@ func (repo *httpMetadataRepository) Get(ctx context.Context, me *domain.Me) (*do return nil, fmt.Errorf("cannot unmarshal metadata configuration: %w", err) } - //nolint: exhaustivestruct // TODO(toby3d) + //nolint:exhaustivestruct // TODO(toby3d) return &domain.Metadata{ AuthorizationEndpoint: data.AuthorizationEndpoint, AuthorizationResponseIssParameterSupported: data.AuthorizationResponseIssParameterSupported, diff --git a/internal/profile/repository/http/http_profile.go b/internal/profile/repository/http/http_profile.go index 0e670e6..d6eccb2 100644 --- a/internal/profile/repository/http/http_profile.go +++ b/internal/profile/repository/http/http_profile.go @@ -32,7 +32,7 @@ func NewHTPPClientRepository(client *http.Client) profile.Repository { } } -//nolint: cyclop +//nolint:cyclop func (repo *httpProfileRepository) Get(ctx context.Context, me *domain.Me) (*domain.Profile, error) { req := http.AcquireRequest() defer http.ReleaseRequest(req) diff --git a/internal/session/repository/sqlite3/sqlite3_session.go b/internal/session/repository/sqlite3/sqlite3_session.go index e342197..3aadfac 100644 --- a/internal/session/repository/sqlite3/sqlite3_session.go +++ b/internal/session/repository/sqlite3/sqlite3_session.go @@ -67,7 +67,7 @@ func (repo *sqlite3SessionRepository) Create(ctx context.Context, session *domai } func (repo *sqlite3SessionRepository) Get(ctx context.Context, code string) (*domain.Session, error) { - s := new(Session) //nolint: varnamelen // cannot redaclare import + s := new(Session) //nolint:varnamelen // cannot redaclare import if err := repo.db.GetContext(ctx, s, QueryGet, code); err != nil { return nil, fmt.Errorf("cannot find session in db: %w", err) } @@ -83,7 +83,7 @@ func (repo *sqlite3SessionRepository) Get(ctx context.Context, code string) (*do } func (repo *sqlite3SessionRepository) GetAndDelete(ctx context.Context, code string) (*domain.Session, error) { - s := new(Session) //nolint: varnamelen // cannot redaclare import + s := new(Session) //nolint:varnamelen // cannot redaclare import tx, err := repo.db.Beginx() if err != nil { @@ -93,7 +93,7 @@ func (repo *sqlite3SessionRepository) GetAndDelete(ctx context.Context, code str } if err = tx.GetContext(ctx, s, QueryGet, code); err != nil { - //nolint: errcheck // deffered method + //nolint:errcheck // deffered method defer tx.Rollback() if errors.Is(err, sql.ErrNoRows) { diff --git a/internal/testing/httptest/httptest.go b/internal/testing/httptest/httptest.go index b549cca..ca22ce1 100644 --- a/internal/testing/httptest/httptest.go +++ b/internal/testing/httptest/httptest.go @@ -24,7 +24,7 @@ var ( func New(tb testing.TB, handler http.RequestHandler) (*http.Client, *http.Server, func()) { tb.Helper() - //nolint: exhaustivestruct + //nolint:exhaustivestruct server := &http.Server{ CloseOnShutdown: true, DisableKeepalive: true, @@ -34,16 +34,16 @@ func New(tb testing.TB, handler http.RequestHandler) (*http.Client, *http.Server ln := httputil.NewInmemoryListener() - //nolint: errcheck + //nolint:errcheck go server.ServeTLSEmbed(ln, certData, keyData) - //nolint: exhaustivestruct + //nolint:exhaustivestruct client := &http.Client{ TLSConfig: &tls.Config{ - InsecureSkipVerify: true, //nolint: gosec + InsecureSkipVerify: true, //nolint:gosec }, Dial: func(addr string) (net.Conn, error) { - return ln.Dial() //nolint: wrapcheck + return ln.Dial() //nolint:wrapcheck }, } diff --git a/internal/ticket/delivery/http/ticket_http.go b/internal/ticket/delivery/http/ticket_http.go index 83350b0..59c6ce3 100644 --- a/internal/ticket/delivery/http/ticket_http.go +++ b/internal/ticket/delivery/http/ticket_http.go @@ -57,7 +57,7 @@ func NewRequestHandler(tickets ticket.UseCase, matcher language.Matcher, config } func (h *RequestHandler) Register(r *router.Router) { - //nolint: exhaustivestruct + //nolint:exhaustivestruct chain := middleware.Chain{ middleware.CSRFWithConfig(middleware.CSRFConfig{ Skipper: func(ctx *http.RequestCtx) bool { diff --git a/internal/ticket/repository/sqlite3/sqlite3_ticket.go b/internal/ticket/repository/sqlite3/sqlite3_ticket.go index eefc823..bcd64cc 100644 --- a/internal/ticket/repository/sqlite3/sqlite3_ticket.go +++ b/internal/ticket/repository/sqlite3/sqlite3_ticket.go @@ -73,7 +73,7 @@ func (repo *sqlite3TicketRepository) GetAndDelete(ctx context.Context, rawTicket tkt := new(Ticket) if err = tx.GetContext(ctx, tkt, QueryGet, rawTicket); err != nil { - //nolint: errcheck // deffered method + //nolint:errcheck // deffered method defer tx.Rollback() if errors.Is(err, sql.ErrNoRows) { diff --git a/internal/ticket/usecase/ticket_ucase.go b/internal/ticket/usecase/ticket_ucase.go index cf6c1c8..cb74ea1 100644 --- a/internal/ticket/usecase/ticket_ucase.go +++ b/internal/ticket/usecase/ticket_ucase.go @@ -15,7 +15,7 @@ import ( ) type ( - //nolint: tagliatelle // https://indieauth.net/source/#access-token-response + //nolint:tagliatelle // https://indieauth.net/source/#access-token-response AccessToken struct { Me *domain.Me `json:"me"` Profile *Profile `json:"profile,omitempty"` diff --git a/internal/token/delivery/http/token_http.go b/internal/token/delivery/http/token_http.go index 26d60a9..6139cbc 100644 --- a/internal/token/delivery/http/token_http.go +++ b/internal/token/delivery/http/token_http.go @@ -55,7 +55,7 @@ type ( Token string `form:"token"` } - //nolint: tagliatelle // https://indieauth.net/source/#access-token-response + //nolint:tagliatelle // https://indieauth.net/source/#access-token-response TokenExchangeResponse struct { // The OAuth 2.0 Bearer Token RFC6750. AccessToken string `json:"access_token"` @@ -90,7 +90,7 @@ type ( Email string `json:"email,omitempty"` } - //nolint: tagliatelle // https://indieauth.net/source/#access-token-verification-response + //nolint:tagliatelle // https://indieauth.net/source/#access-token-verification-response TokenIntrospectResponse struct { // Boolean indicator of whether or not the presented token is // currently active. @@ -138,7 +138,7 @@ func NewRequestHandler(tokens token.UseCase, tickets ticket.UseCase, config *dom func (h *RequestHandler) Register(r *router.Router) { chain := middleware.Chain{ - //nolint: exhaustivestruct + //nolint:exhaustivestruct middleware.JWTWithConfig(middleware.JWTConfig{ AuthScheme: "Bearer", ContextKey: "token", @@ -227,7 +227,7 @@ func (h *RequestHandler) handleAction(ctx *http.RequestCtx) { } } -//nolint: funlen +//nolint:funlen func (h *RequestHandler) handleExchange(ctx *http.RequestCtx) { ctx.SetContentType(common.MIMEApplicationJSONCharsetUTF8) diff --git a/internal/token/delivery/http/token_http_test.go b/internal/token/delivery/http/token_http_test.go index f075d7c..e32b5f3 100644 --- a/internal/token/delivery/http/token_http_test.go +++ b/internal/token/delivery/http/token_http_test.go @@ -117,7 +117,7 @@ func TestRevocation(t *testing.T) { t.Errorf("POST %s = %d, want %d", requestURL, result, http.StatusOK) } - expBody := []byte("{}") //nolint: ifshort + expBody := []byte("{}") //nolint:ifshort if result := bytes.TrimSpace(resp.Body()); !bytes.Equal(result, expBody) { t.Errorf("POST %s = %s, want %s", requestURL, result, expBody) } diff --git a/internal/token/repository/sqlite3/sqlite3_token_test.go b/internal/token/repository/sqlite3/sqlite3_token_test.go index 863eeb9..04c216d 100644 --- a/internal/token/repository/sqlite3/sqlite3_token_test.go +++ b/internal/token/repository/sqlite3/sqlite3_token_test.go @@ -12,7 +12,7 @@ import ( repository "source.toby3d.me/toby3d/auth/internal/token/repository/sqlite3" ) -//nolint: gochecknoglobals // slices cannot be contants +//nolint:gochecknoglobals // slices cannot be contants var tableColumns = []string{"created_at", "access_token", "client_id", "me", "scope"} func TestCreate(t *testing.T) { diff --git a/internal/token/usecase/token_ucase.go b/internal/token/usecase/token_ucase.go index a5d552f..1b49423 100644 --- a/internal/token/usecase/token_ucase.go +++ b/internal/token/usecase/token_ucase.go @@ -41,7 +41,7 @@ func NewTokenUseCase(config Config) token.UseCase { } } -//nolint: cyclop +//nolint:cyclop func (uc *tokenUseCase) Exchange(ctx context.Context, opts token.ExchangeOptions) (*domain.Token, *domain.Profile, error, ) { @@ -129,7 +129,7 @@ func (uc *tokenUseCase) Verify(ctx context.Context, accessToken string) (*domain profile, err := uc.profiles.Get(ctx, result.Me) if err != nil { - return result, nil, nil //nolint: nilerr // it's okay to return result without profile + return result, nil, nil //nolint:nilerr // it's okay to return result without profile } if !result.Scope.Has(domain.ScopeEmail) && len(profile.Email) > 0 { diff --git a/internal/user/delivery/http/user_http.go b/internal/user/delivery/http/user_http.go index 272d84d..542e9ee 100644 --- a/internal/user/delivery/http/user_http.go +++ b/internal/user/delivery/http/user_http.go @@ -37,7 +37,7 @@ func NewRequestHandler(tokens token.UseCase, config *domain.Config) *RequestHand func (h *RequestHandler) Register(r *router.Router) { chain := middleware.Chain{ - //nolint: exhaustivestruct + //nolint:exhaustivestruct middleware.JWTWithConfig(middleware.JWTConfig{ AuthScheme: "Bearer", ContextKey: "token", @@ -63,7 +63,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) { if err != nil || tkn == nil { // WARN(toby3d): If the token is not valid, the endpoint still // MUST return a 200 Response. - _ = encoder.Encode(err) //nolint: errchkjson + _ = encoder.Encode(err) //nolint:errchkjson return } @@ -71,7 +71,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) { if !tkn.Scope.Has(domain.ScopeProfile) { ctx.SetStatusCode(http.StatusForbidden) - //nolint: errchkjson + //nolint:errchkjson _ = encoder.Encode(domain.NewError( domain.ErrorCodeInsufficientScope, "token with 'profile' scope is required to view profile data", @@ -83,7 +83,7 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) { resp := new(UserInformationResponse) if userInfo == nil { - _ = encoder.Encode(resp) //nolint: errchkjson + _ = encoder.Encode(resp) //nolint:errchkjson return } @@ -104,5 +104,5 @@ func (h *RequestHandler) handleUserInformation(ctx *http.RequestCtx) { resp.Email = userInfo.GetEmail().String() } - _ = encoder.Encode(resp) //nolint: errchkjson + _ = encoder.Encode(resp) //nolint:errchkjson } diff --git a/internal/user/repository/http/http_user.go b/internal/user/repository/http/http_user.go index d3b7e86..0fac2d7 100644 --- a/internal/user/repository/http/http_user.go +++ b/internal/user/repository/http/http_user.go @@ -78,7 +78,7 @@ func (repo *httpUserRepository) Get(ctx context.Context, me *domain.Me) (*domain return user, nil } -//nolint: cyclop +//nolint:cyclop func extractUser(dst *domain.User, src *http.Response) { if dst.IndieAuthMetadata != nil { if endpoints := httputil.ExtractEndpoints(src, relIndieAuthMetadata); len(endpoints) > 0 { diff --git a/main.go b/main.go index 6cc037a..0f0cdbf 100644 --- a/main.go +++ b/main.go @@ -87,7 +87,7 @@ const ( DefaultWriteTimeout time.Duration = 10 * time.Second ) -//nolint: gochecknoglobals +//nolint:gochecknoglobals var ( // NOTE(toby3d): write logs in stdout, see: https://12factor.net/logs logger = log.New(os.Stdout, "IndieAuth\t", log.Lmsgprefix|log.LstdFlags|log.LUTC) @@ -100,7 +100,7 @@ var ( enablePprof bool ) -//nolint: gochecknoinits +//nolint:gochecknoinits func init() { flag.StringVar(&configPath, "config", filepath.Join(".", "config.yml"), "load specific config") flag.BoolVar(&enablePprof, "pprof", false, "enable pprof mode") @@ -157,7 +157,7 @@ func init() { indieAuthClient.RedirectURI = []*domain.URL{redirectURI} } -//nolint: funlen, cyclop // "god object" and the entry point of all modules +//nolint:funlen,cyclop // "god object" and the entry point of all modules func main() { var opts NewAppOptions @@ -186,7 +186,7 @@ func main() { go opts.Sessions.GC() - //nolint: exhaustivestruct // too many options + //nolint:exhaustivestruct // too many options opts.Client = &http.Client{ Name: fmt.Sprintf("%s/0.1 (+%s)", config.Name, config.Server.GetAddress()), ReadTimeout: DefaultReadTimeout, @@ -197,7 +197,7 @@ func main() { r := router.New() NewApp(opts).Register(r) - //nolint: exhaustivestruct// too many options + //nolint:exhaustivestruct // too many options r.ServeFilesCustom(path.Join(config.Server.StaticURLPrefix, "{filepath:*}"), &http.FS{ Root: config.Server.StaticRootPath, CacheDuration: DefaultCacheDuration, @@ -211,7 +211,7 @@ func main() { r.GET("/debug/pprof/{filepath:*}", pprofhandler.PprofHandler) } - //nolint: exhaustivestruct + //nolint:exhaustivestruct server := &http.Server{ Name: fmt.Sprintf("IndieAuth/0.1 (+%s)", config.Server.GetAddress()), Handler: r.Handler,