From a4317bf0ecab10f4cc21057243d8d65312875c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 3 Mar 2022 16:21:05 +0000 Subject: [PATCH] Run gofumpt on all files (#10392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Run gofumpt on all files Getting golangci-lint errors when building on my laptop, possibly because I have newer version of gofumpt then what it was formatted with. Run gofumpt -w -extra on all files as it will be needed in the future anyway. * Update golangci-lint to v1.44.2 v1.44.0 upgraded gofumpt so bumping version in CI will help keep formatting correct for everyone * Address golangci-lint error Getting 'error-strings: error strings should not be capitalized or end with punctuation or a newline' from revive here. Drop new line. Signed-off-by: Ɓukasz Mierzwa --- .github/workflows/golangci-lint.yml | 2 +- Makefile.common | 2 +- cmd/promtool/rules.go | 3 +- discovery/openstack/hypervisor.go | 3 +- discovery/openstack/instance.go | 3 +- discovery/targetgroup/targetgroup_test.go | 28 +++++++++---------- .../examples/custom-sd/adapter/adapter.go | 1 - promql/parser/lex_test.go | 2 -- storage/interface.go | 1 - tsdb/wal/checkpoint_test.go | 2 +- tsdb/wal/watcher.go | 1 - util/runtime/statfs_linux_386.go | 1 - util/runtime/statfs_uint32.go | 1 - web/api/v1/api.go | 1 - 14 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 793aa62e7..99a9ab486 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -28,4 +28,4 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v2 with: - version: v1.42.0 + version: v1.44.2 diff --git a/Makefile.common b/Makefile.common index bf7304e58..5ab1b142f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -83,7 +83,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.42.0 +GOLANGCI_LINT_VERSION ?= v1.44.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) diff --git a/cmd/promtool/rules.go b/cmd/promtool/rules.go index 7afca02f1..5d0633074 100644 --- a/cmd/promtool/rules.go +++ b/cmd/promtool/rules.go @@ -95,7 +95,8 @@ func (importer *ruleImporter) importAll(ctx context.Context) (errs []error) { // importRule queries a prometheus API to evaluate rules at times in the past. func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName string, ruleLabels labels.Labels, start, end time.Time, - maxBlockDuration int64, grp *rules.Group) (err error) { + maxBlockDuration int64, grp *rules.Group, +) (err error) { blockDuration := getCompatibleBlockDuration(maxBlockDuration) startInMs := start.Unix() * int64(time.Second/time.Millisecond) endInMs := end.Unix() * int64(time.Second/time.Millisecond) diff --git a/discovery/openstack/hypervisor.go b/discovery/openstack/hypervisor.go index 877b3eb9b..94d47d360 100644 --- a/discovery/openstack/hypervisor.go +++ b/discovery/openstack/hypervisor.go @@ -50,7 +50,8 @@ type HypervisorDiscovery struct { // newHypervisorDiscovery returns a new hypervisor discovery. func newHypervisorDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions, - port int, region string, availability gophercloud.Availability, l log.Logger) *HypervisorDiscovery { + port int, region string, availability gophercloud.Availability, l log.Logger, +) *HypervisorDiscovery { return &HypervisorDiscovery{ provider: provider, authOpts: opts, region: region, port: port, availability: availability, logger: l, diff --git a/discovery/openstack/instance.go b/discovery/openstack/instance.go index fa4039bea..b4e67825a 100644 --- a/discovery/openstack/instance.go +++ b/discovery/openstack/instance.go @@ -59,7 +59,8 @@ type InstanceDiscovery struct { // NewInstanceDiscovery returns a new instance discovery. func newInstanceDiscovery(provider *gophercloud.ProviderClient, opts *gophercloud.AuthOptions, - port int, region string, allTenants bool, availability gophercloud.Availability, l log.Logger) *InstanceDiscovery { + port int, region string, allTenants bool, availability gophercloud.Availability, l log.Logger, +) *InstanceDiscovery { if l == nil { l = log.NewNopLogger() } diff --git a/discovery/targetgroup/targetgroup_test.go b/discovery/targetgroup/targetgroup_test.go index 3843d3156..7045e4426 100644 --- a/discovery/targetgroup/targetgroup_test.go +++ b/discovery/targetgroup/targetgroup_test.go @@ -176,21 +176,19 @@ func TestTargetGroupYamlUnmarshal(t *testing.T) { func TestString(t *testing.T) { // String() should return only the source, regardless of other attributes. - group1 := - Group{ - Targets: []model.LabelSet{ - {"__address__": "localhost:9090"}, - {"__address__": "localhost:9091"}, - }, - Source: "", - Labels: model.LabelSet{"foo": "bar", "bar": "baz"}, - } - group2 := - Group{ - Targets: []model.LabelSet{}, - Source: "", - Labels: model.LabelSet{}, - } + group1 := Group{ + Targets: []model.LabelSet{ + {"__address__": "localhost:9090"}, + {"__address__": "localhost:9091"}, + }, + Source: "", + Labels: model.LabelSet{"foo": "bar", "bar": "baz"}, + } + group2 := Group{ + Targets: []model.LabelSet{}, + Source: "", + Labels: model.LabelSet{}, + } require.Equal(t, "", group1.String()) require.Equal(t, "", group2.String()) require.Equal(t, group1.String(), group2.String()) diff --git a/documentation/examples/custom-sd/adapter/adapter.go b/documentation/examples/custom-sd/adapter/adapter.go index 564a4e83b..abaad7dc7 100644 --- a/documentation/examples/custom-sd/adapter/adapter.go +++ b/documentation/examples/custom-sd/adapter/adapter.go @@ -84,7 +84,6 @@ func generateTargetGroups(allTargetGroups map[string][]*targetgroup.Group) map[s } sdGroup := customSD{ - Targets: newTargets, Labels: newLabels, } diff --git a/promql/parser/lex_test.go b/promql/parser/lex_test.go index 8e22f41d9..25c6abfb6 100644 --- a/promql/parser/lex_test.go +++ b/promql/parser/lex_test.go @@ -611,7 +611,6 @@ var tests = []struct { { // Nested Subquery. input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:])[4m:3s]`, expected: []Item{ - {IDENTIFIER, 0, `min_over_time`}, {LEFT_PAREN, 13, `(`}, {IDENTIFIER, 14, `rate`}, @@ -660,7 +659,6 @@ var tests = []struct { { input: `min_over_time(rate(foo{bar="baz"}[2s])[5m:] offset 6m)[4m:3s]`, expected: []Item{ - {IDENTIFIER, 0, `min_over_time`}, {LEFT_PAREN, 13, `(`}, {IDENTIFIER, 14, `rate`}, diff --git a/storage/interface.go b/storage/interface.go index 986f0f54e..47af6c2c3 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -191,7 +191,6 @@ type Appender interface { // Rollback rolls back all modifications made in the appender so far. // Appender has to be discarded after rollback. Rollback() error - ExemplarAppender } diff --git a/tsdb/wal/checkpoint_test.go b/tsdb/wal/checkpoint_test.go index 554a4b5d2..3f8ca25e0 100644 --- a/tsdb/wal/checkpoint_test.go +++ b/tsdb/wal/checkpoint_test.go @@ -252,7 +252,7 @@ func TestCheckpointNoTmpFolderAfterError(t *testing.T) { // Walk the wal dir to make sure there are no tmp folder left behind after the error. err = filepath.Walk(w.Dir(), func(path string, info os.FileInfo, err error) error { if err != nil { - return errors.Wrapf(err, "access err %q: %v\n", path, err) + return errors.Wrapf(err, "access err %q: %v", path, err) } if info.IsDir() && strings.HasSuffix(info.Name(), ".tmp") { return fmt.Errorf("wal dir contains temporary folder:%s", info.Name()) diff --git a/tsdb/wal/watcher.go b/tsdb/wal/watcher.go index 2c80e676f..cdd20626a 100644 --- a/tsdb/wal/watcher.go +++ b/tsdb/wal/watcher.go @@ -50,7 +50,6 @@ type WriteTo interface { // Once returned, the WAL Watcher will not attempt to pass that data again. Append([]record.RefSample) bool AppendExemplars([]record.RefExemplar) bool - StoreSeries([]record.RefSeries, int) // Next two methods are intended for garbage-collection: first we call diff --git a/util/runtime/statfs_linux_386.go b/util/runtime/statfs_linux_386.go index b45eecdd3..7494a0adf 100644 --- a/util/runtime/statfs_linux_386.go +++ b/util/runtime/statfs_linux_386.go @@ -23,7 +23,6 @@ import ( // Statfs returns the file system type (Unix only) func Statfs(path string) string { - // Types of file systems that may be returned by `statfs` fsTypes := map[int32]string{ 0xadf5: "ADFS_SUPER_MAGIC", diff --git a/util/runtime/statfs_uint32.go b/util/runtime/statfs_uint32.go index fa10ebc96..72d670a39 100644 --- a/util/runtime/statfs_uint32.go +++ b/util/runtime/statfs_uint32.go @@ -23,7 +23,6 @@ import ( // Statfs returns the file system type (Unix only) func Statfs(path string) string { - // Types of file systems that may be returned by `statfs` fsTypes := map[uint32]string{ 0xadf5: "ADFS_SUPER_MAGIC", diff --git a/web/api/v1/api.go b/web/api/v1/api.go index bd2519f0a..0faae93f3 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -150,7 +150,6 @@ type TSDBAdminStats interface { CleanTombstones() error Delete(mint, maxt int64, ms ...*labels.Matcher) error Snapshot(dir string, withHead bool) error - Stats(statsByLabelName string) (*tsdb.Stats, error) WALReplayStatus() (tsdb.WALReplayStatus, error) }