Skip to content

Commit

Permalink
linter: update & use revive instead of golint (#1901)
Browse files Browse the repository at this point in the history
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
  • Loading branch information
zroubalik authored Jun 24, 2021
1 parent 9cf3937 commit 6530be7
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RUN apt-get update \
github.com/mgechev/revive \
github.com/derekparker/delve/cmd/dlv 2>&1 \
# Install golangci-lint
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 \
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1 \
#
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
&& groupadd --gid $USER_GID $USERNAME \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
go-version: 1.15.13
- name: Get golangci
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1
- uses: pre-commit/action@v2.0.3

codeScanning:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ linters:
- nolintlint
- rowserrcheck
- gofmt
- golint
- revive
- goimports
- misspell
- bodyclose
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ For more installation options visit the [pre-commits](https://pre-commit.com).

Before running pre-commit, you must install the [golangci-lint](https://golangci-lint.run/) tool as a static check tool for golang code (contains a series of linter)
```shell script
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1
# or
brew install golangci/tap/golangci-lint
```
Expand Down
10 changes: 3 additions & 7 deletions controllers/scaledjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,11 @@ func (r *ScaledJobReconciler) deletePreviousVersionScaleJobs(logger logr.Logger,
// requestScaleLoop request ScaleLoop handler for the respective ScaledJob
func (r *ScaledJobReconciler) requestScaleLoop(logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
logger.V(1).Info("Starting a new ScaleLoop")

return r.scaleHandler.HandleScalableObject(scaledJob)
}

// stopScaleLoop stops ScaleLoop handler for the respective ScaledJob
func (r *ScaledJobReconciler) stopScaleLoop(scaledJob *kedav1alpha1.ScaledJob) error {
if err := r.scaleHandler.DeleteScalableObject(scaledJob); err != nil {
return err
}

return nil
func (r *ScaledJobReconciler) stopScaleLoop(logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
logger.V(1).Info("Stopping a ScaleLoop")
return r.scaleHandler.DeleteScalableObject(scaledJob)
}
2 changes: 1 addition & 1 deletion controllers/scaledjob_finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (r *ScaledJobReconciler) finalizeScaledJob(logger logr.Logger, scaledJob *k
// Run finalization logic for scaledJobFinalizer. If the
// finalization logic fails, don't remove the finalizer so
// that we can retry during the next reconciliation.
if err := r.stopScaleLoop(scaledJob); err != nil {
if err := r.stopScaleLoop(logger, scaledJob); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/scaledobject_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("ScaledObjectController", func() {
mockStatusWriter *mock_client.MockStatusWriter
)

var triggerMeta []map[string]string = []map[string]string{
var triggerMeta = []map[string]string{
{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total", "threshold": "100", "query": "up", "disableScaleToZero": "true"},
{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total2", "threshold": "100", "query": "up"},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/azure_pipelines_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *azurePipelinesScaler) GetAzurePipelinesQueueLength(ctx context.Context)
return -1, err
}

var count int = 0
var count = 0
jobs, ok := result["value"].([]interface{})

if !ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/influxdb_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func parseInfluxDBMetadata(config *ScalerConfig) (*influxDBMetadata, error) {
}

if val, ok := config.TriggerMetadata["thresholdValue"]; ok {
value, err := strconv.ParseFloat(val, 10)
value, err := strconv.ParseFloat(val, 64)
if err != nil {
return nil, fmt.Errorf("thresholdValue: failed to parse thresholdValue length %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/openstack_metrics_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (a *openstackMetricScaler) Close() error {

// Gets measureament from API as float64, converts it to int and return the value.
func (a *openstackMetricScaler) readOpenstackMetrics() (float64, error) {
var metricURL string = a.metadata.metricsURL
var metricURL = a.metadata.metricsURL

isValid, validationError := a.metricClient.IsTokenValid()

Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/openstack_swift_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *openstackSwiftScaler) getOpenstackSwiftContainerObjectCount() (int, err

// If onlyFiles is set to "true", return the total amount of files (excluding empty objects/folders)
if s.metadata.onlyFiles {
var count int = 0
var count = 0
for i := 0; i < len(objectsList); i++ {
if !strings.HasSuffix(objectsList[i], "/") {
count++
Expand Down

0 comments on commit 6530be7

Please sign in to comment.