Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-10881] Make BaseMiddleware a pointer #5914

Merged
merged 3 commits into from
Dec 29, 2023

Conversation

titpetric
Copy link
Contributor

@titpetric titpetric commented Dec 28, 2023

This resolves vet warnings about copying a mutex value.

Before: 189 warnings,
After: 7 warnings

# go vet -json ./... 2>&1 | summary vet
Warnings by message:
3 loop variable tc captured by func literal
2 func passes lock by value: github.com/TykTechnologies/tyk/gateway.APISpec
1 call of tc.reloadAPI copies lock value: github.com/TykTechnologies/tyk/gateway.APISpec
1 method Seek(offset int64, whence int64) (int64, error) should have signature Seek(int64, int) (int64, error)

Warnings by filename:
3 /root/tyk/tyk/gateway/handler_success_test.go
2 /root/tyk/tyk/apidef/oas/server_test.go
1 /root/tyk/tyk/test/util_test.go
1 /root/tyk/tyk/gateway/reverse_proxy.go

Total: 7

https://tyktech.atlassian.net/browse/TT-10881

Copy link

sweep-ai bot commented Dec 28, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

Copy link
Contributor

github-actions bot commented Dec 28, 2023

API Changes

--- prev.txt	2023-12-29 13:30:37.413646418 +0000
+++ current.txt	2023-12-29 13:30:34.661653445 +0000
@@ -6560,7 +6560,7 @@
 func CoProcessLog(CMessage, CLogLevel *C.char)
     CoProcessLog is a bridge for using Tyk log from CP.
 
-func CreateCoProcessMiddleware(hookName string, hookType coprocess.HookType, mwDriver apidef.MiddlewareDriver, baseMid BaseMiddleware) func(http.Handler) http.Handler
+func CreateCoProcessMiddleware(hookName string, hookType coprocess.HookType, mwDriver apidef.MiddlewareDriver, baseMid *BaseMiddleware) func(http.Handler) http.Handler
     CreateCoProcessMiddleware initializes a new CP middleware, takes hook type
     (pre, post, etc.), hook name ("my_hook") and driver ("python").
 
@@ -6798,7 +6798,7 @@
     where it is stored in the request (currently only "header" is supported)
 
 type AccessRightsCheck struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     AccessRightsCheck is a middleware that will check if the key bing used
     to access the API has permission to access the specific version. If no
@@ -6812,7 +6812,7 @@
     system, return an error to have the chain fail
 
 type AuthKey struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     KeyExists will check if the key being used to access the API is in the
     request data, and then if the key is in the storage engine
@@ -6824,7 +6824,8 @@
 type BaseExtractor struct {
 	Config            *apidef.MiddlewareIdExtractor
 	IDExtractorConfig apidef.IDExtractorConfig
-	BaseMiddleware
+	*BaseMiddleware
+
 	Spec *APISpec
 }
     BaseExtractor is the base structure for an ID extractor, it implements the
@@ -6847,7 +6848,7 @@
 func (e *BaseExtractor) ExtractHeader(r *http.Request) (headerValue string, err error)
     ExtractHeader is used when a HeaderSource is specified.
 
-func (e *BaseExtractor) GenerateSessionID(input string, mw BaseMiddleware) (sessionID string)
+func (e *BaseExtractor) GenerateSessionID(input string, mw *BaseMiddleware) (sessionID string)
     GenerateSessionID is a helper for generating session IDs, it takes an input
     (usually the extractor output) and a middleware pointer.
 
@@ -6861,40 +6862,40 @@
     BaseMiddleware wraps up the ApiSpec and Proxy objects to be included in a
     middleware handler, this can probably be handled better.
 
-func (t BaseMiddleware) ApplyPolicies(session *user.SessionState) error
+func (t *BaseMiddleware) ApplyPolicies(session *user.SessionState) error
     ApplyPolicies will check if any policies are loaded. If any are, it will
     overwrite the session state to use the policy values.
 
 func (t *BaseMiddleware) Base() *BaseMiddleware
 
-func (t BaseMiddleware) CheckSessionAndIdentityForValidKey(originalKey string, r *http.Request) (user.SessionState, bool)
+func (t *BaseMiddleware) CheckSessionAndIdentityForValidKey(originalKey string, r *http.Request) (user.SessionState, bool)
     CheckSessionAndIdentityForValidKey will check first the Session store for a
     valid key, if not found, it will try the Auth Handler, if not found it will
     fail
 
-func (t BaseMiddleware) Config() (interface{}, error)
+func (t *BaseMiddleware) Config() (interface{}, error)
 
-func (t BaseMiddleware) EnabledForSpec() bool
+func (t *BaseMiddleware) EnabledForSpec() bool
 
-func (t BaseMiddleware) FireEvent(name apidef.TykEvent, meta interface{})
+func (t *BaseMiddleware) FireEvent(name apidef.TykEvent, meta interface{})
     FireEvent is added to the BaseMiddleware object so it is available across
     the entire stack
 
-func (t BaseMiddleware) Init()
+func (t *BaseMiddleware) Init()
 
 func (t *BaseMiddleware) Logger() (logger *logrus.Entry)
 
-func (t BaseMiddleware) OrgSession(orgID string) (user.SessionState, bool)
+func (t *BaseMiddleware) OrgSession(orgID string) (user.SessionState, bool)
 
-func (t BaseMiddleware) OrgSessionExpiry(orgid string) int64
+func (t *BaseMiddleware) OrgSessionExpiry(orgid string) int64
 
 func (t *BaseMiddleware) SetName(name string)
 
-func (t BaseMiddleware) SetOrgExpiry(orgid string, expiry int64)
+func (t *BaseMiddleware) SetOrgExpiry(orgid string, expiry int64)
 
 func (t *BaseMiddleware) SetRequestLogger(r *http.Request)
 
-func (t BaseMiddleware) UpdateRequestSession(r *http.Request) bool
+func (t *BaseMiddleware) UpdateRequestSession(r *http.Request) bool
 
 type BaseTykResponseHandler struct {
 	Spec *APISpec `json:"-"`
@@ -6912,7 +6913,7 @@
 func (b *BaseTykResponseHandler) Name() string
 
 type BasicAuthKeyIsValid struct {
-	BaseMiddleware
+	*BaseMiddleware
 
 	// Has unexported fields.
 }
@@ -6991,7 +6992,7 @@
     BundleSaver is an interface used by bundle saver structures.
 
 type CertificateCheckMW struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     CertificateCheckMW is used if domain was not detected or multiple APIs bind
     on the same domain. In this case authentification check happens not on TLS
@@ -7027,7 +7028,8 @@
 }
 
 type CoProcessMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	HookType         coprocess.HookType
 	HookName         string
 	MiddlewareDriver apidef.MiddlewareDriver
@@ -7189,7 +7191,8 @@
 func (d *DummyProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 
 type DynamicMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	MiddlewareClassName string
 	Pre                 bool
 	UseSession          bool
@@ -7212,7 +7215,7 @@
 }
 
 type ErrorHandler struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     ErrorHandler is invoked whenever there is an issue with a proxied request,
     most middleware will invoke the ErrorHandler if something is wrong with the
@@ -7315,7 +7318,7 @@
 }
 
 type ExternalOAuthMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (k *ExternalOAuthMiddleware) EnabledForSpec() bool
@@ -7518,7 +7521,8 @@
 }
 
 type GoPluginMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	Path       string // path to .so file
 	SymbolName string // function symbol to look up
 
@@ -7543,7 +7547,7 @@
 	GranularAccessFailReasonValidationError
 )
 type GranularAccessMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     GranularAccessMiddleware will check if a URL is specifically enabled for the
     key
@@ -7555,7 +7559,7 @@
     system, return an error to have the chain fail
 
 type GraphQLComplexityMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (m *GraphQLComplexityMiddleware) EnabledForSpec() bool
@@ -7583,7 +7587,7 @@
 func DetermineGraphQLEngineTransportType(apiSpec *APISpec) GraphQLEngineTransportType
 
 type GraphQLGranularAccessMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (m *GraphQLGranularAccessMiddleware) EnabledForSpec() bool
@@ -7595,7 +7599,7 @@
     system, return an error to have the chain fail
 
 type GraphQLMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (m *GraphQLMiddleware) EnabledForSpec() bool
@@ -7694,7 +7698,8 @@
 func (h *HTTPDashboardHandler) StopBeating()
 
 type HTTPSignatureValidationMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	// Has unexported fields.
 }
     HTTPSignatureValidationMiddleware will check if the request has a signature,
@@ -7880,7 +7885,7 @@
 func (h *HostUptimeChecker) Stop()
 
 type IPBlackListMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     IPBlackListMiddleware lets you define a list of IPs to block from upstream
 
@@ -7893,7 +7898,7 @@
     system, return an error to have the chain fail
 
 type IPWhiteListMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     IPWhiteListMiddleware lets you define a list of IPs to allow upstream
 
@@ -7907,7 +7912,7 @@
 
 type IdExtractor interface {
 	ExtractAndCheck(*http.Request) (string, ReturnOverrides)
-	GenerateSessionID(string, BaseMiddleware) string
+	GenerateSessionID(string, *BaseMiddleware) string
 }
     IdExtractor is the base interface for an ID extractor.
 
@@ -7974,7 +7979,7 @@
 }
 
 type JWTMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (k *JWTMiddleware) EnabledForSpec() bool
@@ -7984,7 +7989,7 @@
 func (k *JWTMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
 
 type KeyExpired struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     KeyExpired middleware will check if the requesting key is expired or not.
     It makes use of the authManager to do so.
@@ -8092,7 +8097,7 @@
 func (m MethodNotAllowedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 
 type MiddlewareContextVars struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (m *MiddlewareContextVars) EnabledForSpec() bool
@@ -8292,7 +8297,7 @@
     OAuthNotificationType const to reduce risk of collisions
 
 type Oauth2KeyExists struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     Oauth2KeyExists will check if the key being used to access the API is in the
     request data, and then if the key is in the storage engine
@@ -8306,7 +8311,7 @@
     system, return an error to have the chain fail
 
 type OpenIDMW struct {
-	BaseMiddleware
+	*BaseMiddleware
 
 	// Has unexported fields.
 }
@@ -8326,7 +8331,7 @@
 }
 
 type OrganizationMonitor struct {
-	BaseMiddleware
+	*BaseMiddleware
 
 	// Has unexported fields.
 }
@@ -8356,7 +8361,7 @@
 func (k *OrganizationMonitor) SetOrgSentinel(orgChan chan bool, orgId string)
 
 type PersistGraphQLOperationMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     PersistGraphQLOperationMiddleware lets you convert any HTTP request into a
     GraphQL Operation
@@ -8546,7 +8551,7 @@
 func (r *RPCStorageHandler) StartRPCLoopCheck(orgId string)
 
 type RateCheckMW struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (m *RateCheckMW) Name() string
@@ -8554,7 +8559,7 @@
 func (m *RateCheckMW) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
 
 type RateLimitAndQuotaCheck struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     RateLimitAndQuotaCheck will check the incomming request and key whether
     it is within it's quota and within it's rate limit, it makes use of the
@@ -8569,7 +8574,7 @@
     system, return an error to have the chain fail
 
 type RateLimitForAPI struct {
-	BaseMiddleware
+	*BaseMiddleware
 
 	// Has unexported fields.
 }
@@ -8613,7 +8618,7 @@
     Stop stops the analytics processing
 
 type RedisCacheMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 
 	// Has unexported fields.
 }
@@ -8798,7 +8803,7 @@
     RequestObject is marshalled to JSON string and passed into JSON middleware
 
 type RequestSigning struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (s *RequestSigning) EnabledForSpec() bool
@@ -8808,7 +8813,7 @@
 func (s *RequestSigning) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
 
 type RequestSizeLimitMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     RequestSizeLimitMiddleware is a middleware that will enforce a limit on the
     request body size. The request has already been copied to memory when this
@@ -9125,7 +9130,7 @@
 type StatsDSinkSanitizationFunc func(*bytes.Buffer, string)
 
 type StripAuth struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (sa *StripAuth) EnabledForSpec() bool
@@ -9135,7 +9140,7 @@
 func (sa *StripAuth) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int)
 
 type SuccessHandler struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     SuccessHandler represents the final ServeHTTP() request for a proxied API
     request
@@ -9242,7 +9247,7 @@
 func (tr TraceMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int)
 
 type TrackEndpointMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     TrackEndpointMiddleware sets context variables to enable or disable whether
     Tyk should record analytitcs for a specific path.
@@ -9256,7 +9261,7 @@
     system, return an error to have the chain fail
 
 type TransformHeaders struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     TransformMiddleware is a middleware that will apply a template to a request
     body to transform it's contents ready for an upstream API
@@ -9270,7 +9275,7 @@
     system, return an error to have the chain fail
 
 type TransformJQMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (t *TransformJQMiddleware) EnabledForSpec() bool
@@ -9286,7 +9291,7 @@
 }
 
 type TransformMethod struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     TransformMiddleware is a middleware that will apply a template to a request
     body to transform it's contents ready for an upstream API
@@ -9300,7 +9305,7 @@
     system, return an error to have the chain fail
 
 type TransformMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     TransformMiddleware is a middleware that will apply a template to a request
     body to transform it's contents ready for an upstream API
@@ -9346,6 +9351,7 @@
 type TykMiddleware interface {
 	Init()
 	Base() *BaseMiddleware
+
 	SetName(string)
 	SetRequestLogger(*http.Request)
 	Logger() *logrus.Entry
@@ -9382,7 +9388,7 @@
 func (rt *TykRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)
 
 type URLRewriteMiddleware struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
     URLRewriteMiddleware Will rewrite an inbund URL to a matching outbound one,
     it can also handle dynamic variable substitution
@@ -9496,7 +9502,7 @@
 }
 
 type ValidateJSON struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (k *ValidateJSON) EnabledForSpec() bool
@@ -9508,7 +9514,7 @@
     system, return an error to have the chain fail
 
 type ValidateRequest struct {
-	BaseMiddleware
+	*BaseMiddleware
 }
 
 func (k *ValidateRequest) EnabledForSpec() bool
@@ -9528,7 +9534,8 @@
 func (e *ValueExtractor) ExtractAndCheck(r *http.Request) (sessionID string, returnOverrides ReturnOverrides)
 
 type VersionCheck struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	// Has unexported fields.
 }
     VersionCheck will check whether the version of the requested API the request
@@ -9567,7 +9574,8 @@
 func (h *VersionsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 
 type VirtualEndpoint struct {
-	BaseMiddleware
+	*BaseMiddleware
+
 	// Has unexported fields.
 }
     DynamicMiddleware is a generic middleware that will execute JS code before

Copy link
Contributor

PR Analysis

  • 🎯 Main theme: Refactoring BaseMiddleware to be a pointer
  • 📝 PR summary: This PR is focused on resolving warnings about copying a mutex value by changing the BaseMiddleware from a value to a pointer. This change is applied across multiple files in the codebase.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 4, because the changes are spread across a large number of files and the impact of changing BaseMiddleware to a pointer needs to be carefully reviewed to ensure it doesn't introduce any unexpected behavior.
  • 🔒 Security concerns: No security concerns found

PR Feedback

💡 General suggestions: The PR is well-structured and the changes are consistent across all files. However, it would be beneficial to add tests to ensure that the change from a value to a pointer for BaseMiddleware doesn't introduce any unexpected behavior or bugs.

🤖 Code feedback:
relevant filegateway/middleware.go
suggestion      

Please ensure that all methods that now receive a pointer are properly handling nil values to avoid potential panics. [important]

relevant linefunc (t *BaseMiddleware) Init() {}

relevant filegateway/api.go
suggestion      

Please ensure that the change from a value to a pointer for BaseMiddleware doesn't affect the behavior of the middleware in the applyPoliciesAndSave function. [important]

relevant linemw := &BaseMiddleware{Gw: gw}

relevant filegateway/middleware_test.go
suggestion      

Please ensure that the change from a value to a pointer for BaseMiddleware doesn't affect the behavior of the middleware in the TestBaseMiddleware_getAuthToken function. [important]

relevant linebaseMid := &BaseMiddleware{Spec: spec, Gw: ts.Gw}

relevant filegateway/coprocess.go
suggestion      

Please ensure that the change from a value to a pointer for BaseMiddleware doesn't affect the behavior of the middleware in the CreateCoProcessMiddleware function. [important]

relevant linefunc CreateCoProcessMiddleware(hookName string, hookType coprocess.HookType, mwDriver apidef.MiddlewareDriver, baseMid *BaseMiddleware) func(http.Handler) http.Handler {

✨ Usage tips:

To invoke the PR-Agent, add a comment using one of the following commands:

  • /review: Request a review of your Pull Request.
  • /describe: Update the PR title and description based on the contents of the PR.
  • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
  • /ask <QUESTION>: Ask a question about the PR.
  • /update_changelog: Update the changelog based on the PR's contents.
  • /add_docs 💎: Generate docstring for new components introduced in the PR.
  • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
  • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

See the tools guide for more details.
To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

@buger
Copy link
Member

buger commented Dec 28, 2023

API tests result - postgres15-murmur64 env: success
Branch used: refs/heads/master
Commit: 58ff0e0 TT-10881 Make BaseMiddleware a pointer (#5914)

This resolves vet warnings about copying a mutex value.

Before: 189 warnings,
After: 7 warnings

# go vet -json ./... 2>&1 | summary vet
Warnings by message:
3 loop variable tc captured by func literal
2 func passes lock by value: github.com/TykTechnologies/tyk/gateway.APISpec
1 call of tc.reloadAPI copies lock value: github.com/TykTechnologies/tyk/gateway.APISpec
1 method Seek(offset int64, whence int64) (int64, error) should have signature Seek(int64, int) (int64, error)

Warnings by filename:
3 /root/tyk/tyk/gateway/handler_success_test.go
2 /root/tyk/tyk/apidef/oas/server_test.go
1 /root/tyk/tyk/test/util_test.go
1 /root/tyk/tyk/gateway/reverse_proxy.go

Total: 7

https://tyktech.atlassian.net/browse/TT-10881


Co-authored-by: Tit Petric tit@tyk.io
Triggered by: push (@titpetric)
Execution page

@buger
Copy link
Member

buger commented Dec 28, 2023

API tests result - mongo44-sha256 env: success
Branch used: refs/heads/master
Commit: 58ff0e0 TT-10881 Make BaseMiddleware a pointer (#5914)

This resolves vet warnings about copying a mutex value.

Before: 189 warnings,
After: 7 warnings

# go vet -json ./... 2>&1 | summary vet
Warnings by message:
3 loop variable tc captured by func literal
2 func passes lock by value: github.com/TykTechnologies/tyk/gateway.APISpec
1 call of tc.reloadAPI copies lock value: github.com/TykTechnologies/tyk/gateway.APISpec
1 method Seek(offset int64, whence int64) (int64, error) should have signature Seek(int64, int) (int64, error)

Warnings by filename:
3 /root/tyk/tyk/gateway/handler_success_test.go
2 /root/tyk/tyk/apidef/oas/server_test.go
1 /root/tyk/tyk/test/util_test.go
1 /root/tyk/tyk/gateway/reverse_proxy.go

Total: 7

https://tyktech.atlassian.net/browse/TT-10881


Co-authored-by: Tit Petric tit@tyk.io
Triggered by: push (@titpetric)
Execution page

@buger
Copy link
Member

buger commented Dec 28, 2023

API tests result - postgres15-sha256 env: success
Branch used: refs/heads/master
Commit: 58ff0e0 TT-10881 Make BaseMiddleware a pointer (#5914)

This resolves vet warnings about copying a mutex value.

Before: 189 warnings,
After: 7 warnings

# go vet -json ./... 2>&1 | summary vet
Warnings by message:
3 loop variable tc captured by func literal
2 func passes lock by value: github.com/TykTechnologies/tyk/gateway.APISpec
1 call of tc.reloadAPI copies lock value: github.com/TykTechnologies/tyk/gateway.APISpec
1 method Seek(offset int64, whence int64) (int64, error) should have signature Seek(int64, int) (int64, error)

Warnings by filename:
3 /root/tyk/tyk/gateway/handler_success_test.go
2 /root/tyk/tyk/apidef/oas/server_test.go
1 /root/tyk/tyk/test/util_test.go
1 /root/tyk/tyk/gateway/reverse_proxy.go

Total: 7

https://tyktech.atlassian.net/browse/TT-10881


Co-authored-by: Tit Petric tit@tyk.io
Triggered by: push (@titpetric)
Execution page

Copy link
Contributor

💥 CI tests failed 🙈

git-state

all ok

Please look at the run or in the Checks tab.

@buger
Copy link
Member

buger commented Dec 28, 2023

API tests result - mongo44-murmur64 env: success
Branch used: refs/heads/master
Commit: 58ff0e0 TT-10881 Make BaseMiddleware a pointer (#5914)

This resolves vet warnings about copying a mutex value.

Before: 189 warnings,
After: 7 warnings

# go vet -json ./... 2>&1 | summary vet
Warnings by message:
3 loop variable tc captured by func literal
2 func passes lock by value: github.com/TykTechnologies/tyk/gateway.APISpec
1 call of tc.reloadAPI copies lock value: github.com/TykTechnologies/tyk/gateway.APISpec
1 method Seek(offset int64, whence int64) (int64, error) should have signature Seek(int64, int) (int64, error)

Warnings by filename:
3 /root/tyk/tyk/gateway/handler_success_test.go
2 /root/tyk/tyk/apidef/oas/server_test.go
1 /root/tyk/tyk/test/util_test.go
1 /root/tyk/tyk/gateway/reverse_proxy.go

Total: 7

https://tyktech.atlassian.net/browse/TT-10881


Co-authored-by: Tit Petric tit@tyk.io
Triggered by: push (@titpetric)
Execution page

Copy link
Contributor

💥 CI tests failed 🙈

git-state

all ok

Please look at the run or in the Checks tab.

@@ -46,6 +46,7 @@ var (
type TykMiddleware interface {
Init()
Base() *BaseMiddleware

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary line break?

@titpetric titpetric enabled auto-merge (squash) December 29, 2023 13:29
@titpetric titpetric force-pushed the fix/TT-10881/make-basemiddleware-a-pointer branch from 5867d8d to 96c26cf Compare December 29, 2023 13:29
Copy link

sonarcloud bot commented Dec 29, 2023

Quality Gate Failed Quality Gate failed

Failed conditions

70.6% Coverage on New Code (required ≥ 80%)
C Maintainability Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

@titpetric titpetric merged commit 58ff0e0 into master Dec 29, 2023
19 of 20 checks passed
@titpetric titpetric deleted the fix/TT-10881/make-basemiddleware-a-pointer branch December 29, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants