Skip to content

Commit 625a40f

Browse files
committed
style: Lint
1 parent e96c800 commit 625a40f

File tree

13 files changed

+46
-36
lines changed

13 files changed

+46
-36
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ linters:
8686
- unconvert
8787
- unparam
8888
- unused
89+
issues:
90+
max-issues-per-linter: 0
91+
max-same-issues: 0

configtype/time.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package configtype
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"math"
78
"regexp"
@@ -212,13 +213,13 @@ func parseTimeDuration(s string) (timeDuration, error) {
212213
inValue = false
213214
case part == "ago":
214215
if d.sign != 0 {
215-
return timeDuration{}, fmt.Errorf("invalid duration format: more than one sign specifier")
216+
return timeDuration{}, errors.New("invalid duration format: more than one sign specifier")
216217
}
217218

218219
d.sign = -1
219220
case part == "from":
220221
if d.sign != 0 {
221-
return timeDuration{}, fmt.Errorf("invalid duration format: more than one sign specifier")
222+
return timeDuration{}, errors.New("invalid duration format: more than one sign specifier")
222223
}
223224

224225
inSign = true

faker/faker.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package faker
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"math/rand"
78
"reflect"
@@ -15,7 +16,7 @@ type faker struct {
1516
logger zerolog.Logger
1617
}
1718

18-
var errEFaceNotAllowed = fmt.Errorf("any not allowed")
19+
var errEFaceNotAllowed = errors.New("any not allowed")
1920

2021
func (f faker) getFakedValue(a any) (reflect.Value, error) {
2122
t := reflect.TypeOf(a)
@@ -24,7 +25,7 @@ func (f faker) getFakedValue(a any) (reflect.Value, error) {
2425
}
2526
f.maxDepth--
2627
if f.maxDepth < 0 {
27-
return reflect.Value{}, fmt.Errorf("max_depth reached")
28+
return reflect.Value{}, errors.New("max_depth reached")
2829
}
2930
k := t.Kind()
3031
switch k {
@@ -176,7 +177,7 @@ func FakeObject(obj any, opts ...Option) error {
176177
reflectType := reflect.TypeOf(obj)
177178

178179
if reflectType.Kind() != reflect.Ptr {
179-
return fmt.Errorf("object is not a pointer")
180+
return errors.New("object is not a pointer")
180181
}
181182

182183
if reflect.ValueOf(obj).IsNil() {

helpers/remoteoauth/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (t *cloudTokenSource) retrieveToken(ctx context.Context) (*oauth2.Token, er
114114
}
115115

116116
if oauthResp == nil {
117-
return nil, fmt.Errorf("missing oauth credentials in response")
117+
return nil, errors.New("missing oauth credentials in response")
118118
}
119119

120120
tok := &oauth2.Token{

internal/memdb/memdb.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package memdb
22

33
import (
44
"context"
5-
"fmt"
5+
"errors"
66
"sync"
77

88
"github.com/apache/arrow-go/v18/arrow"
@@ -108,7 +108,7 @@ func NewMemDBClient(ctx context.Context, l zerolog.Logger, spec []byte, options
108108
}
109109

110110
func NewMemDBClientErrOnNew(context.Context, zerolog.Logger, []byte, plugin.NewClientOptions) (plugin.Client, error) {
111-
return nil, fmt.Errorf("newTestDestinationMemDBClientErrOnNew")
111+
return nil, errors.New("newTestDestinationMemDBClientErrOnNew")
112112
}
113113

114114
func (c *client) overwrite(table *schema.Table, record arrow.Record) {
@@ -211,12 +211,12 @@ func (c *client) migrate(_ context.Context, table *schema.Table) {
211211

212212
func (c *client) Write(ctx context.Context, msgs <-chan message.WriteMessage) error {
213213
if c.errOnWrite {
214-
return fmt.Errorf("errOnWrite")
214+
return errors.New("errOnWrite")
215215
}
216216
if c.blockingWrite {
217217
<-ctx.Done()
218218
if c.errOnWrite {
219-
return fmt.Errorf("errOnWrite")
219+
return errors.New("errOnWrite")
220220
}
221221
return nil
222222
}
@@ -235,7 +235,7 @@ func (c *client) Write(ctx context.Context, msgs <-chan message.WriteMessage) er
235235
sc := msg.Record.Schema()
236236
tableName, ok := sc.Metadata().GetValue(schema.MetadataTableName)
237237
if !ok {
238-
return fmt.Errorf("table name not found in schema metadata")
238+
return errors.New("table name not found in schema metadata")
239239
}
240240
table := c.tables[tableName]
241241
c.overwrite(table, msg.Record)

plugin/plugin.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"sync"
78

@@ -13,7 +14,7 @@ import (
1314
"github.com/santhosh-tekuri/jsonschema/v6"
1415
)
1516

16-
var ErrNotImplemented = fmt.Errorf("not implemented")
17+
var ErrNotImplemented = errors.New("not implemented")
1718

1819
type NewClientOptions struct {
1920
NoConnection bool
@@ -215,7 +216,7 @@ func (p *Plugin) SetLogger(logger zerolog.Logger) {
215216

216217
func (p *Plugin) Tables(ctx context.Context, options TableOptions) (schema.Tables, error) {
217218
if p.client == nil {
218-
return nil, fmt.Errorf("plugin not initialized")
219+
return nil, errors.New("plugin not initialized")
219220
}
220221
tables, err := p.client.Tables(ctx, options)
221222
if err != nil {
@@ -227,7 +228,7 @@ func (p *Plugin) Tables(ctx context.Context, options TableOptions) (schema.Table
227228
// Init initializes the plugin with the given spec.
228229
func (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions) error {
229230
if !p.mu.TryLock() {
230-
return fmt.Errorf("plugin already in use")
231+
return errors.New("plugin already in use")
231232
}
232233
defer p.mu.Unlock()
233234
var err error
@@ -257,7 +258,7 @@ func (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions
257258

258259
func (p *Plugin) Close(ctx context.Context) error {
259260
if !p.mu.TryLock() {
260-
return fmt.Errorf("plugin already in use")
261+
return errors.New("plugin already in use")
261262
}
262263
defer p.mu.Unlock()
263264
if p.client == nil {

plugin/plugin_destination.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/apache/arrow-go/v18/arrow"
@@ -33,19 +34,19 @@ func (p *Plugin) WriteAll(ctx context.Context, resources []message.WriteMessage)
3334

3435
func (p *Plugin) Write(ctx context.Context, res <-chan message.WriteMessage) error {
3536
if p.client == nil {
36-
return fmt.Errorf("plugin is not initialized. call Init first")
37+
return errors.New("plugin is not initialized. call Init first")
3738
}
3839
return p.client.Write(ctx, res)
3940
}
4041

4142
// Read is read data from the requested table to the given channel, returned in the same format as the table
4243
func (p *Plugin) Read(ctx context.Context, table *schema.Table, res chan<- arrow.Record) error {
4344
if !p.mu.TryLock() {
44-
return fmt.Errorf("plugin already in use")
45+
return errors.New("plugin already in use")
4546
}
4647
defer p.mu.Unlock()
4748
if p.client == nil {
48-
return fmt.Errorf("plugin not initialized. call Init() first")
49+
return errors.New("plugin not initialized. call Init() first")
4950
}
5051
if err := p.client.Read(ctx, table, res); err != nil {
5152
return fmt.Errorf("failed to read: %w", err)

plugin/plugin_source.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/cloudquery/plugin-sdk/v4/glob"
@@ -88,11 +89,11 @@ func (p *Plugin) SyncAll(ctx context.Context, options SyncOptions) (message.Sync
8889
// Sync is syncing data from the requested tables in spec to the given channel
8990
func (p *Plugin) Sync(ctx context.Context, options SyncOptions, res chan<- message.SyncMessage) error {
9091
if !p.mu.TryLock() {
91-
return fmt.Errorf("plugin already in use")
92+
return errors.New("plugin already in use")
9293
}
9394
defer p.mu.Unlock()
9495
if p.client == nil {
95-
return fmt.Errorf("plugin not initialized. call Init() first")
96+
return errors.New("plugin not initialized. call Init() first")
9697
}
9798

9899
if err := p.client.Sync(ctx, options, res); err != nil {

premium/usage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,15 @@ func awsMarketplaceProductCode() string {
334334

335335
func (u *BatchUpdater) Increase(rows uint32) error {
336336
if u.usageIncreaseMethod == UsageIncreaseMethodBreakdown {
337-
return fmt.Errorf("mixing usage increase methods is not allowed, use IncreaseForTable instead")
337+
return errors.New("mixing usage increase methods is not allowed, use IncreaseForTable instead")
338338
}
339339

340340
if rows <= 0 {
341341
return fmt.Errorf("rows must be greater than zero got %d", rows)
342342
}
343343

344344
if u.isClosed {
345-
return fmt.Errorf("usage updater is closed")
345+
return errors.New("usage updater is closed")
346346
}
347347

348348
u.Lock()
@@ -364,15 +364,15 @@ func (u *BatchUpdater) Increase(rows uint32) error {
364364

365365
func (u *BatchUpdater) IncreaseForTable(table string, rows uint32) error {
366366
if u.usageIncreaseMethod == UsageIncreaseMethodTotal {
367-
return fmt.Errorf("mixing usage increase methods is not allowed, use Increase instead")
367+
return errors.New("mixing usage increase methods is not allowed, use Increase instead")
368368
}
369369

370370
if rows <= 0 {
371371
return fmt.Errorf("rows must be greater than zero got %d", rows)
372372
}
373373

374374
if u.isClosed {
375-
return fmt.Errorf("usage updater is closed")
375+
return errors.New("usage updater is closed")
376376
}
377377

378378
u.Lock()
@@ -696,7 +696,7 @@ func (u *BatchUpdater) getTeamNameByTokenType(tokenType auth.TokenType) (string,
696696
return "", fmt.Errorf("failed to get team name from config: %w", err)
697697
}
698698
if teamName == "" {
699-
return "", fmt.Errorf("team name not set. Hint: use `cloudquery switch <team>`")
699+
return "", errors.New("team name not set. Hint: use `cloudquery switch <team>`")
700700
}
701701
return teamName, nil
702702
case auth.APIKey:
@@ -716,7 +716,7 @@ func (u *BatchUpdater) getTeamNameByTokenType(tokenType auth.TokenType) (string,
716716
if team == "" {
717717
switch tokenType {
718718
case auth.SyncRunAPIKey, auth.SyncTestConnectionAPIKey:
719-
return "", fmt.Errorf("_CQ_TEAM_NAME environment variable not set")
719+
return "", errors.New("_CQ_TEAM_NAME environment variable not set")
720720
}
721721
return "", fmt.Errorf("unsupported token type: %v", tokenType)
722722
}

schema/table.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package schema
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"regexp"
89
"slices"
@@ -177,7 +178,7 @@ func NewTableFromArrowSchema(sc *arrow.Schema) (*Table, error) {
177178
tableMD := sc.Metadata()
178179
name, found := tableMD.GetValue(MetadataTableName)
179180
if !found {
180-
return nil, fmt.Errorf("missing table name")
181+
return nil, errors.New("missing table name")
181182
}
182183
description, _ := tableMD.GetValue(MetadataTableDescription)
183184
constraintName, _ := tableMD.GetValue(MetadataConstraintName)

0 commit comments

Comments
 (0)