From 9fd9da41cfd9dd92f1dbd75933a3231914f0483a Mon Sep 17 00:00:00 2001 From: CloudQuery Bot <102256036+cq-bot@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:38:52 +0200 Subject: [PATCH] chore(deps): Update dependency golangci/golangci-lint to v1.64.5 (#2087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Update | Change | Pending | |---|---|---|---| | [golangci/golangci-lint](https://redirect.github.com/golangci/golangci-lint) | minor | `v1.63.4` -> `v1.64.5` | `v1.64.6` | --- ### Release Notes
golangci/golangci-lint (golangci/golangci-lint) ### [`v1.64.5`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1645) [Compare Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.64.4...v1.64.5) 1. Bug fixes - Add missing flag `new-from-merge-base-flag` 2. Linters bug fixes - `asciicheck`: from 0.3.0 to 0.4.0 - `forcetypeassert`: from 0.1.0 to 0.2.0 - `gosec`: from 2.22.0 to 2.22.1 ### [`v1.64.4`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1644) [Compare Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.64.3...v1.64.4) 1. Linters bug fixes - `gci`: fix standard packages list for go1.24 ### [`v1.64.3`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1643) [Compare Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.64.2...v1.64.3) 1. Linters bug fixes - `ginkgolinter`: from 0.18.4 to 0.19.0 - `go-critic`: from 0.11.5 to 0.12.0 - `revive`: from 1.6.0 to 1.6.1 - `gci`: fix standard packages list for go1.24 2. Misc. - Build Docker images with go1.24 ### [`v1.64.2`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1642) [Compare Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.63.4...v1.64.2) This is the last minor release of golangci-lint v1. The next release will be golangci-lint [v2](https://redirect.github.com/golangci/golangci-lint/issues/5300). 1. Enhancements - 🎉 go1.24 support - New `issues.new-from-merge-base` option - New `run.relative-path-mode` option 2. Linters new features - `copyloopvar`: from 1.1.0 to 1.2.1 (support suggested fixes) - `exptostd`: from 0.3.1 to 0.4.1 (handles `golang.org/x/exp/constraints.Ordered`) - `fatcontext`: from 0.5.3 to 0.7.1 (new option: `check-struct-pointers`) - `perfsprint`: from 0.7.1 to 0.8.1 (new options: `integer-format`, `error-format`, `string-format`, `bool-format`, and `hex-format`) - `revive`: from 1.5.1 to 1.6.0 (new rules: `redundant-build-tag`, `use-errors-new`. New option `early-return.early-return`) 3. Linters bug fixes - `go-errorlint`: from 1.7.0 to 1.7.1 - `gochecknoglobals`: from 0.2.1 to 0.2.2 - `godox`: from [`006bad1`](https://redirect.github.com/golangci/golangci-lint/commit/006bad1f9d26) to 1.1.0 - `gosec`: from 2.21.4 to 2.22.0 - `iface`: from 1.3.0 to 1.3.1 - `nilnesserr`: from 0.1.1 to 0.1.2 - `protogetter`: from 0.3.8 to 0.3.9 - `sloglint`: from 0.7.2 to 0.9.0 - `spancheck`: fix default `StartSpanMatchersSlice` values - `staticcheck`: from 0.5.1 to 0.6.0 4. Deprecations - ⚠️ `tenv` is deprecated and replaced by `usetesting.os-setenv: true`. - ⚠️ `exportloopref` deprecation step 2 5. Misc. - Sanitize severities by output format - Avoid panic with plugin without description 6. Documentation - Clarify `depguard` configuration
--- ### Configuration 📅 **Schedule**: Branch creation - "* 0-3 1 * *" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://redirect.github.com/renovatebot/renovate). --- .github/workflows/lint_golang.yml | 2 +- .golangci.yml | 3 + configtype/time.go | 5 +- faker/faker.go | 9 +-- faker/faker_test.go | 62 +++++++++++++++++++ helpers/remoteoauth/token.go | 2 +- internal/memdb/memdb.go | 10 +-- plugin/plugin.go | 9 +-- plugin/plugin_destination.go | 7 ++- plugin/plugin_source.go | 5 +- premium/usage.go | 12 ++-- schema/table.go | 3 +- serve/package.go | 12 ++-- writers/batchwriter/batchwriter.go | 4 +- .../streamingbatchwriter.go | 3 +- 15 files changed, 110 insertions(+), 38 deletions(-) diff --git a/.github/workflows/lint_golang.yml b/.github/workflows/lint_golang.yml index f97872d79f..61d73b626f 100644 --- a/.github/workflows/lint_golang.yml +++ b/.github/workflows/lint_golang.yml @@ -20,4 +20,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.63.4 + version: v1.64.5 diff --git a/.golangci.yml b/.golangci.yml index 445fee393a..949eb93a20 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -86,3 +86,6 @@ linters: - unconvert - unparam - unused +issues: + max-issues-per-linter: 0 + max-same-issues: 0 \ No newline at end of file diff --git a/configtype/time.go b/configtype/time.go index 18357de23b..de91105b99 100644 --- a/configtype/time.go +++ b/configtype/time.go @@ -2,6 +2,7 @@ package configtype import ( "encoding/json" + "errors" "fmt" "math" "regexp" @@ -212,13 +213,13 @@ func parseTimeDuration(s string) (timeDuration, error) { inValue = false case part == "ago": if d.sign != 0 { - return timeDuration{}, fmt.Errorf("invalid duration format: more than one sign specifier") + return timeDuration{}, errors.New("invalid duration format: more than one sign specifier") } d.sign = -1 case part == "from": if d.sign != 0 { - return timeDuration{}, fmt.Errorf("invalid duration format: more than one sign specifier") + return timeDuration{}, errors.New("invalid duration format: more than one sign specifier") } inSign = true diff --git a/faker/faker.go b/faker/faker.go index 00c3dce134..e475aeb4bc 100644 --- a/faker/faker.go +++ b/faker/faker.go @@ -2,6 +2,7 @@ package faker import ( "encoding/json" + "errors" "fmt" "math/rand" "reflect" @@ -15,16 +16,16 @@ type faker struct { logger zerolog.Logger } -var errEFaceNotAllowed = fmt.Errorf("any not allowed") +var errEFaceNotAllowed = errors.New("any not allowed") -func (f faker) getFakedValue(a any) (reflect.Value, error) { +func (f *faker) getFakedValue(a any) (reflect.Value, error) { t := reflect.TypeOf(a) if t == nil { return reflect.Value{}, errEFaceNotAllowed } f.maxDepth-- if f.maxDepth < 0 { - return reflect.Value{}, fmt.Errorf("max_depth reached") + return reflect.Value{}, errors.New("max_depth reached") } k := t.Kind() switch k { @@ -176,7 +177,7 @@ func FakeObject(obj any, opts ...Option) error { reflectType := reflect.TypeOf(obj) if reflectType.Kind() != reflect.Ptr { - return fmt.Errorf("object is not a pointer") + return errors.New("object is not a pointer") } if reflect.ValueOf(obj).IsNil() { diff --git a/faker/faker_test.go b/faker/faker_test.go index f21e16407d..b9cdb4dc77 100644 --- a/faker/faker_test.go +++ b/faker/faker_test.go @@ -6,7 +6,9 @@ import ( "testing" "time" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type testFakerStruct struct { @@ -97,3 +99,63 @@ func TestFakerCanFakeNetIP(t *testing.T) { assert.NotEmpty(t, a.NestedComplex.IPAddress) assert.Equal(t, "1.1.1.1", a.NestedComplex.IPAddress.String()) } + +func TestMaxDepth(t *testing.T) { + // Struct with nested structs + a := struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A struct { + A string + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }{} + + sink := &testLogSink{} + testLogger := zerolog.New(sink) + require.NoError(t, FakeObject(&a, WithLogger(testLogger)), "max depth reached") + require.Equal(t, 1, len(sink.getLogs())) + require.Contains(t, sink.getLogs()[0], "max_depth reached") +} + +type testLogSink struct { + logs []string +} + +func (sink *testLogSink) Write(p []byte) (n int, err error) { + sink.logs = append(sink.logs, string(p)) + return len(p), nil +} + +func (sink *testLogSink) getLogs() []string { + return sink.logs +} diff --git a/helpers/remoteoauth/token.go b/helpers/remoteoauth/token.go index 43ac432c20..667fef4abd 100644 --- a/helpers/remoteoauth/token.go +++ b/helpers/remoteoauth/token.go @@ -114,7 +114,7 @@ func (t *cloudTokenSource) retrieveToken(ctx context.Context) (*oauth2.Token, er } if oauthResp == nil { - return nil, fmt.Errorf("missing oauth credentials in response") + return nil, errors.New("missing oauth credentials in response") } tok := &oauth2.Token{ diff --git a/internal/memdb/memdb.go b/internal/memdb/memdb.go index 60af1ee694..f2323e0816 100644 --- a/internal/memdb/memdb.go +++ b/internal/memdb/memdb.go @@ -2,7 +2,7 @@ package memdb import ( "context" - "fmt" + "errors" "sync" "github.com/apache/arrow-go/v18/arrow" @@ -108,7 +108,7 @@ func NewMemDBClient(ctx context.Context, l zerolog.Logger, spec []byte, options } func NewMemDBClientErrOnNew(context.Context, zerolog.Logger, []byte, plugin.NewClientOptions) (plugin.Client, error) { - return nil, fmt.Errorf("newTestDestinationMemDBClientErrOnNew") + return nil, errors.New("newTestDestinationMemDBClientErrOnNew") } func (c *client) overwrite(table *schema.Table, record arrow.Record) { @@ -211,12 +211,12 @@ func (c *client) migrate(_ context.Context, table *schema.Table) { func (c *client) Write(ctx context.Context, msgs <-chan message.WriteMessage) error { if c.errOnWrite { - return fmt.Errorf("errOnWrite") + return errors.New("errOnWrite") } if c.blockingWrite { <-ctx.Done() if c.errOnWrite { - return fmt.Errorf("errOnWrite") + return errors.New("errOnWrite") } return nil } @@ -235,7 +235,7 @@ func (c *client) Write(ctx context.Context, msgs <-chan message.WriteMessage) er sc := msg.Record.Schema() tableName, ok := sc.Metadata().GetValue(schema.MetadataTableName) if !ok { - return fmt.Errorf("table name not found in schema metadata") + return errors.New("table name not found in schema metadata") } table := c.tables[tableName] c.overwrite(table, msg.Record) diff --git a/plugin/plugin.go b/plugin/plugin.go index 9815be2557..2d0771d42f 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "errors" "fmt" "sync" @@ -13,7 +14,7 @@ import ( "github.com/santhosh-tekuri/jsonschema/v6" ) -var ErrNotImplemented = fmt.Errorf("not implemented") +var ErrNotImplemented = errors.New("not implemented") type NewClientOptions struct { NoConnection bool @@ -215,7 +216,7 @@ func (p *Plugin) SetLogger(logger zerolog.Logger) { func (p *Plugin) Tables(ctx context.Context, options TableOptions) (schema.Tables, error) { if p.client == nil { - return nil, fmt.Errorf("plugin not initialized") + return nil, errors.New("plugin not initialized") } tables, err := p.client.Tables(ctx, options) if err != nil { @@ -227,7 +228,7 @@ func (p *Plugin) Tables(ctx context.Context, options TableOptions) (schema.Table // Init initializes the plugin with the given spec. func (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions) error { if !p.mu.TryLock() { - return fmt.Errorf("plugin already in use") + return errors.New("plugin already in use") } defer p.mu.Unlock() var err error @@ -257,7 +258,7 @@ func (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions func (p *Plugin) Close(ctx context.Context) error { if !p.mu.TryLock() { - return fmt.Errorf("plugin already in use") + return errors.New("plugin already in use") } defer p.mu.Unlock() if p.client == nil { diff --git a/plugin/plugin_destination.go b/plugin/plugin_destination.go index a6db85efe7..a75c719d9e 100644 --- a/plugin/plugin_destination.go +++ b/plugin/plugin_destination.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "errors" "fmt" "github.com/apache/arrow-go/v18/arrow" @@ -33,7 +34,7 @@ func (p *Plugin) WriteAll(ctx context.Context, resources []message.WriteMessage) func (p *Plugin) Write(ctx context.Context, res <-chan message.WriteMessage) error { if p.client == nil { - return fmt.Errorf("plugin is not initialized. call Init first") + return errors.New("plugin is not initialized. call Init first") } return p.client.Write(ctx, res) } @@ -41,11 +42,11 @@ func (p *Plugin) Write(ctx context.Context, res <-chan message.WriteMessage) err // Read is read data from the requested table to the given channel, returned in the same format as the table func (p *Plugin) Read(ctx context.Context, table *schema.Table, res chan<- arrow.Record) error { if !p.mu.TryLock() { - return fmt.Errorf("plugin already in use") + return errors.New("plugin already in use") } defer p.mu.Unlock() if p.client == nil { - return fmt.Errorf("plugin not initialized. call Init() first") + return errors.New("plugin not initialized. call Init() first") } if err := p.client.Read(ctx, table, res); err != nil { return fmt.Errorf("failed to read: %w", err) diff --git a/plugin/plugin_source.go b/plugin/plugin_source.go index 6bdbfc8e1b..f626244c10 100644 --- a/plugin/plugin_source.go +++ b/plugin/plugin_source.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "errors" "fmt" "github.com/cloudquery/plugin-sdk/v4/glob" @@ -88,11 +89,11 @@ func (p *Plugin) SyncAll(ctx context.Context, options SyncOptions) (message.Sync // Sync is syncing data from the requested tables in spec to the given channel func (p *Plugin) Sync(ctx context.Context, options SyncOptions, res chan<- message.SyncMessage) error { if !p.mu.TryLock() { - return fmt.Errorf("plugin already in use") + return errors.New("plugin already in use") } defer p.mu.Unlock() if p.client == nil { - return fmt.Errorf("plugin not initialized. call Init() first") + return errors.New("plugin not initialized. call Init() first") } if err := p.client.Sync(ctx, options, res); err != nil { diff --git a/premium/usage.go b/premium/usage.go index 7b48afa91b..bd624fadc6 100644 --- a/premium/usage.go +++ b/premium/usage.go @@ -334,7 +334,7 @@ func awsMarketplaceProductCode() string { func (u *BatchUpdater) Increase(rows uint32) error { if u.usageIncreaseMethod == UsageIncreaseMethodBreakdown { - return fmt.Errorf("mixing usage increase methods is not allowed, use IncreaseForTable instead") + return errors.New("mixing usage increase methods is not allowed, use IncreaseForTable instead") } if rows <= 0 { @@ -342,7 +342,7 @@ func (u *BatchUpdater) Increase(rows uint32) error { } if u.isClosed { - return fmt.Errorf("usage updater is closed") + return errors.New("usage updater is closed") } u.Lock() @@ -364,7 +364,7 @@ func (u *BatchUpdater) Increase(rows uint32) error { func (u *BatchUpdater) IncreaseForTable(table string, rows uint32) error { if u.usageIncreaseMethod == UsageIncreaseMethodTotal { - return fmt.Errorf("mixing usage increase methods is not allowed, use Increase instead") + return errors.New("mixing usage increase methods is not allowed, use Increase instead") } if rows <= 0 { @@ -372,7 +372,7 @@ func (u *BatchUpdater) IncreaseForTable(table string, rows uint32) error { } if u.isClosed { - return fmt.Errorf("usage updater is closed") + return errors.New("usage updater is closed") } u.Lock() @@ -696,7 +696,7 @@ func (u *BatchUpdater) getTeamNameByTokenType(tokenType auth.TokenType) (string, return "", fmt.Errorf("failed to get team name from config: %w", err) } if teamName == "" { - return "", fmt.Errorf("team name not set. Hint: use `cloudquery switch `") + return "", errors.New("team name not set. Hint: use `cloudquery switch `") } return teamName, nil case auth.APIKey: @@ -716,7 +716,7 @@ func (u *BatchUpdater) getTeamNameByTokenType(tokenType auth.TokenType) (string, if team == "" { switch tokenType { case auth.SyncRunAPIKey, auth.SyncTestConnectionAPIKey: - return "", fmt.Errorf("_CQ_TEAM_NAME environment variable not set") + return "", errors.New("_CQ_TEAM_NAME environment variable not set") } return "", fmt.Errorf("unsupported token type: %v", tokenType) } diff --git a/schema/table.go b/schema/table.go index d094e04b54..c523fb9a4e 100644 --- a/schema/table.go +++ b/schema/table.go @@ -3,6 +3,7 @@ package schema import ( "context" "encoding/json" + "errors" "fmt" "regexp" "slices" @@ -177,7 +178,7 @@ func NewTableFromArrowSchema(sc *arrow.Schema) (*Table, error) { tableMD := sc.Metadata() name, found := tableMD.GetValue(MetadataTableName) if !found { - return nil, fmt.Errorf("missing table name") + return nil, errors.New("missing table name") } description, _ := tableMD.GetValue(MetadataTableDescription) constraintName, _ := tableMD.GetValue(MetadataConstraintName) diff --git a/serve/package.go b/serve/package.go index 5b1f520f0d..581b09c407 100644 --- a/serve/package.go +++ b/serve/package.go @@ -215,7 +215,7 @@ func (*PluginServe) getModuleName(pluginDirectory string) (string, error) { reMod := regexp.MustCompile(`module\s+(.+)\n`) importPathMatches := reMod.FindStringSubmatch(string(goMod)) if len(importPathMatches) != 2 { - return "", fmt.Errorf("failed to parse import path from go.mod") + return "", errors.New("failed to parse import path from go.mod") } importPath := importPathMatches[1] return strings.TrimSpace(importPath), nil @@ -336,7 +336,7 @@ func (s *PluginServe) validatePluginExports(pluginPath string) error { } } if !foundVersion { - return fmt.Errorf("could not find `Version` global variable in package") + return errors.New("could not find `Version` global variable in package") } return nil @@ -389,7 +389,7 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command { } message := "" if !cmd.Flag("message").Changed { - return fmt.Errorf("message is required") + return errors.New("message is required") } message = cmd.Flag("message").Value.String() if strings.HasPrefix(message, "@") { @@ -407,13 +407,13 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command { } if s.plugin.Name() == "" { - return fmt.Errorf("plugin name is required for packaging") + return errors.New("plugin name is required for packaging") } if s.plugin.Team() == "" { - return fmt.Errorf("plugin team is required (hint: use the plugin.WithTeam() option)") + return errors.New("plugin team is required (hint: use the plugin.WithTeam() option)") } if s.plugin.Kind() == "" { - return fmt.Errorf("plugin kind is required (hint: use the plugin.WithKind() option)") + return errors.New("plugin kind is required (hint: use the plugin.WithKind() option)") } if err := s.validatePluginExports(pluginDirectory); err != nil { diff --git a/writers/batchwriter/batchwriter.go b/writers/batchwriter/batchwriter.go index 657b7ccd88..af1b0bcb23 100644 --- a/writers/batchwriter/batchwriter.go +++ b/writers/batchwriter/batchwriter.go @@ -2,7 +2,7 @@ package batchwriter import ( "context" - "fmt" + "errors" "sync" "time" @@ -338,7 +338,7 @@ func (w *BatchWriter) startWorker(_ context.Context, msg *message.WriteInsert) e tableName, ok := md.GetValue(schema.MetadataTableName) if !ok { w.workersLock.RUnlock() - return fmt.Errorf("table name not found in metadata") + return errors.New("table name not found in metadata") } wr, ok := w.workers[tableName] w.workersLock.RUnlock() diff --git a/writers/streamingbatchwriter/streamingbatchwriter.go b/writers/streamingbatchwriter/streamingbatchwriter.go index 23b6e8c139..e6b8ea3a63 100644 --- a/writers/streamingbatchwriter/streamingbatchwriter.go +++ b/writers/streamingbatchwriter/streamingbatchwriter.go @@ -21,6 +21,7 @@ package streamingbatchwriter import ( "context" + "errors" "fmt" "sync" "time" @@ -211,7 +212,7 @@ func (w *StreamingBatchWriter) startWorker(ctx context.Context, errCh chan<- err md := mi.Record.Schema().Metadata() tableName, ok = md.GetValue(schema.MetadataTableName) if !ok { - return fmt.Errorf("table name not found in metadata") + return errors.New("table name not found in metadata") } } else { tableName = msg.GetTable().Name