Skip to content

Commit

Permalink
enable gofmt,golint and fix lint errors (#1159)
Browse files Browse the repository at this point in the history
* enable gofmt,golint and fix lint errors

Signed-off-by: silenceper <[email protected]>

* fix Makefile: change to golangci

Signed-off-by: silenceper <[email protected]>
  • Loading branch information
silenceper authored Sep 16, 2020
1 parent cb84728 commit f5489b8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ linters:
- govet
- nolintlint
- rowserrcheck
#- gofmt
- gofmt
- golint
#- interfacer
#- golint
#- goimports
#- ineffassign
#- misspell
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,17 @@ pkg/scalers/liiklus/mocks/mock_liiklus.go: pkg/scalers/liiklus/LiiklusService.pb
# Run go fmt against code
.PHONY: gofmt
gofmt:
go fmt ./...
gofmt -l -w -s .

# Run go vet against code
.PHONY: govet
govet:
go vet ./...

# Run revive against code
.PHONY: revive
revive:
revive -config revive.toml -formatter friendly \
-exclude pkg/scalers/liiklus/mocks/mock_liiklus.go \
-exclude vendor/... \
./...
# Run golangci against code
.PHONY: golangci
golangci:
golangci-lint run

##################################################
# Clientset #
Expand Down
8 changes: 4 additions & 4 deletions pkg/scalers/artemis_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type artemisMetadata struct {
brokerAddress string
username string
password string
restApiTemplate string
restAPITemplate string
queueLength int
}

Expand Down Expand Up @@ -70,9 +70,9 @@ func parseArtemisMetadata(resolvedEnv, metadata, authParams map[string]string) (
meta.queueLength = defaultArtemisQueueLength

if val, ok := metadata["restApiTemplate"]; ok && val != "" {
meta.restApiTemplate = metadata["restApiTemplate"]
meta.restAPITemplate = metadata["restApiTemplate"]
} else {
meta.restApiTemplate = defaultRestAPITemplate
meta.restAPITemplate = defaultRestAPITemplate
}

if metadata["managementEndpoint"] == "" {
Expand Down Expand Up @@ -156,7 +156,7 @@ func (s *artemisScaler) getMonitoringEndpoint() string {
"<<brokerName>>", s.metadata.brokerName,
"<<brokerAddress>>", s.metadata.brokerAddress)

monitoringEndpoint := replacer.Replace(s.metadata.restApiTemplate)
monitoringEndpoint := replacer.Replace(s.metadata.restAPITemplate)

return monitoringEndpoint
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/scalers/azure/azure_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ type testExtractAzMonitorTestData struct {

var testExtractAzMonitordata = []testExtractAzMonitorTestData{
{"nothing returned", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{}}},
{"timeseries null", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: nil}}}},
{"timeseries empty", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{}}}}},
{"data nil", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: nil}}}}}},
{"data empty", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{}}}}}}},
{"Total Aggregation requested", false, 40, azureExternalMetricRequest{Aggregation: "Total"}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{insights.MetricValue{Total: returnFloat64Ptr(40)}}}}}}}},
{"Average Aggregation requested", false, 41, azureExternalMetricRequest{Aggregation: "Average"}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{insights.MetricValue{Average: returnFloat64Ptr(41)}}}}}}}},
{"Maximum Aggregation requested", false, 42, azureExternalMetricRequest{Aggregation: "Maximum"}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{insights.MetricValue{Maximum: returnFloat64Ptr(42)}}}}}}}},
{"Minimum Aggregation requested", false, 43, azureExternalMetricRequest{Aggregation: "Minimum"}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{insights.MetricValue{Minimum: returnFloat64Ptr(43)}}}}}}}},
{"Count Aggregation requested", false, 44, azureExternalMetricRequest{Aggregation: "Count"}, insights.Response{Value: &[]insights.Metric{insights.Metric{Timeseries: &[]insights.TimeSeriesElement{insights.TimeSeriesElement{Data: &[]insights.MetricValue{insights.MetricValue{Count: returnFloat64Ptr(44)}}}}}}}},
{"timeseries null", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{{Timeseries: nil}}}},
{"timeseries empty", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{}}}}},
{"data nil", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: nil}}}}}},
{"data empty", true, -1, azureExternalMetricRequest{}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{}}}}}}},
{"Total Aggregation requested", false, 40, azureExternalMetricRequest{Aggregation: "Total"}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{{Total: returnFloat64Ptr(40)}}}}}}}},
{"Average Aggregation requested", false, 41, azureExternalMetricRequest{Aggregation: "Average"}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{{Average: returnFloat64Ptr(41)}}}}}}}},
{"Maximum Aggregation requested", false, 42, azureExternalMetricRequest{Aggregation: "Maximum"}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{{Maximum: returnFloat64Ptr(42)}}}}}}}},
{"Minimum Aggregation requested", false, 43, azureExternalMetricRequest{Aggregation: "Minimum"}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{{Minimum: returnFloat64Ptr(43)}}}}}}}},
{"Count Aggregation requested", false, 44, azureExternalMetricRequest{Aggregation: "Count"}, insights.Response{Value: &[]insights.Metric{{Timeseries: &[]insights.TimeSeriesElement{{Data: &[]insights.MetricValue{{Count: returnFloat64Ptr(44)}}}}}}}},
}

func returnFloat64Ptr(x float64) *float64 {
Expand Down

0 comments on commit f5489b8

Please sign in to comment.