diff --git a/.golangci.yml b/.golangci.yml index d0cfa1e0b25..87efa826882 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,12 +19,12 @@ linters: - gofmt - golint - goimports + - misspell + - bodyclose #- interfacer #- ineffassign - #- misspell #- scopelint #- structcheck - #- bodyclose #- deadcode #- depguard #- dogsled diff --git a/adapter/main.go b/adapter/main.go index b84b30fe74f..03fecd190b3 100644 --- a/adapter/main.go +++ b/adapter/main.go @@ -28,7 +28,7 @@ import ( type Adapter struct { basecmd.AdapterBase - // Message is printed on succesful startup + // Message is printed on successful startup Message string } diff --git a/controllers/hpa.go b/controllers/hpa.go index 3f0e8f06620..8e371f7be25 100644 --- a/controllers/hpa.go +++ b/controllers/hpa.go @@ -20,7 +20,7 @@ const ( defaultHPAMaxReplicas int32 = 100 ) -// createAndDeployNewHPA creates and deploy HPA in the cluster for specifed ScaledObject +// createAndDeployNewHPA creates and deploy HPA in the cluster for specified ScaledObject func (r *ScaledObjectReconciler) createAndDeployNewHPA(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject, gvkr *kedav1alpha1.GroupVersionKindResource) error { hpaName := getHPAName(scaledObject) logger.Info("Creating a new HPA", "HPA.Namespace", scaledObject.Namespace, "HPA.Name", hpaName) diff --git a/pkg/scalers/azure/azure_aad_podidentity.go b/pkg/scalers/azure/azure_aad_podidentity.go index e4dc103fb65..b4bc89ddbbe 100644 --- a/pkg/scalers/azure/azure_aad_podidentity.go +++ b/pkg/scalers/azure/azure_aad_podidentity.go @@ -22,6 +22,7 @@ func GetAzureADPodIdentityToken(audience string) (AADToken, error) { if err != nil { return token, err } + defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { diff --git a/pkg/scalers/azure_log_analytics_scaler.go b/pkg/scalers/azure_log_analytics_scaler.go index bdf5644abe6..df6c47c2209 100644 --- a/pkg/scalers/azure_log_analytics_scaler.go +++ b/pkg/scalers/azure_log_analytics_scaler.go @@ -418,7 +418,7 @@ func (s *azureLogAnalyticsScaler) getAuthorizationToken() (tokenData, error) { err = json.NewDecoder(bytes.NewReader(body)).Decode(&tokenInfo) if err != nil { - return tokenData{}, fmt.Errorf(`Can't decode responce body to JSON after getting access token. Received body: "%s". Error: "%v"`, string(body), err) + return tokenData{}, fmt.Errorf(`Can't decode response body to JSON after getting access token. Received body: "%s". Error: "%v"`, string(body), err) } if statusCode == 200 { @@ -495,7 +495,7 @@ func (s *azureLogAnalyticsScaler) runHTTP(request *http.Request, caller string) body, err := ioutil.ReadAll(resp.Body) if err != nil { - return nil, resp.StatusCode, fmt.Errorf("Error reading %s responce body: %v", caller, err) + return nil, resp.StatusCode, fmt.Errorf("Error reading %s response body: %v", caller, err) } return body, resp.StatusCode, nil diff --git a/pkg/scalers/kafka_scram_client.go b/pkg/scalers/kafka_scram_client.go index ef8f4e9c8d7..1310a859871 100644 --- a/pkg/scalers/kafka_scram_client.go +++ b/pkg/scalers/kafka_scram_client.go @@ -11,7 +11,7 @@ import ( // SHA256 hash generator function for SCRAM conversation var SHA256 scram.HashGeneratorFcn = func() hash.Hash { return sha256.New() } -// SHA512 hash generator function for SCRAM converstaion +// SHA512 hash generator function for SCRAM conversation var SHA512 scram.HashGeneratorFcn = func() hash.Hash { return sha512.New() } // XDGSCRAMClient struct to perform SCRAM conversation diff --git a/pkg/scalers/redis_streams_scaler.go b/pkg/scalers/redis_streams_scaler.go index 44a2d9df4c4..220758359f2 100644 --- a/pkg/scalers/redis_streams_scaler.go +++ b/pkg/scalers/redis_streams_scaler.go @@ -78,7 +78,7 @@ func getRedisConnection(metadata *redisStreamsMetadata) (*redis.Client, error) { } } - // this does not guarentee successful connection + // this does not guarantee successful connection c := redis.NewClient(options) // confirm if connected diff --git a/pkg/scalers/scaler.go b/pkg/scalers/scaler.go index e0d57466a76..4113a41ac82 100644 --- a/pkg/scalers/scaler.go +++ b/pkg/scalers/scaler.go @@ -14,7 +14,7 @@ type Scaler interface { // The scaler returns the metric values for a metric Name and criteria matching the selector GetMetrics(ctx context.Context, metricName string, metricSelector labels.Selector) ([]external_metrics.ExternalMetricValue, error) - // Returns the metrics based on which this scaler determines that the ScaleTarget scales. This is used to contruct the HPA spec that is created for + // Returns the metrics based on which this scaler determines that the ScaleTarget scales. This is used to construct the HPA spec that is created for // this scaled object. The labels used should match the selectors used in GetMetrics GetMetricSpecForScaling() []v2beta2.MetricSpec diff --git a/pkg/scalers/stan_scaler.go b/pkg/scalers/stan_scaler.go index d11e0db6ef1..ea57542416a 100644 --- a/pkg/scalers/stan_scaler.go +++ b/pkg/scalers/stan_scaler.go @@ -119,8 +119,11 @@ func (s *stanScaler) IsActive(ctx context.Context) (bool, error) { } if resp.StatusCode == 404 { - baseResp, _ := http.Get(s.getSTANChannelsEndpoint()) - + baseResp, err := http.Get(s.getSTANChannelsEndpoint()) + if err != nil { + return false, err + } + defer baseResp.Body.Close() if baseResp.StatusCode == 404 { stanLog.Info("Streaming broker endpoint returned 404. Please ensure it has been created", "url", monitoringEndpoint, "channelName", s.metadata.subject) diff --git a/pkg/scaling/resolver/hashicorpvault_handler.go b/pkg/scaling/resolver/hashicorpvault_handler.go index e1a0942ee48..27bd82a0c6c 100644 --- a/pkg/scaling/resolver/hashicorpvault_handler.go +++ b/pkg/scaling/resolver/hashicorpvault_handler.go @@ -146,7 +146,7 @@ func (vh *HashicorpVaultHandler) Read(path string) (*vaultApi.Secret, error) { return vh.client.Logical().Read(path) } -// Stop is responsible for stoping the renew token proccess +// Stop is responsible for stoping the renew token process func (vh *HashicorpVaultHandler) Stop() { if vh.stopCh != nil { vh.stopCh <- struct{}{}