Skip to content

Commit 4a752b5

Browse files
authored
fix!: Enable var names lint rule and fix issues (#88)
We have a bunch of useful lint rules disable since it would have taken a lot of work to fix all the issues. With the new SDK we can start fixing the issues gradually ---
1 parent 514fba4 commit 4a752b5

File tree

8 files changed

+23
-26
lines changed

8 files changed

+23
-26
lines changed

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ linters-settings:
4747
disabled: true
4848
- name: unhandled-error
4949
disabled: true
50-
- name: var-naming
51-
disabled: true
5250
- name: deep-exit
5351
disabled: true
5452
- name: nested-structs

faker/faker.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
)
99

1010
type faker struct {
11-
max_depth int
12-
// logger zerolog.Logger
11+
maxDepth int
1312
}
1413

1514
type Option func(*faker)
@@ -19,8 +18,8 @@ func (f faker) getFakedValue(a interface{}) (reflect.Value, error) {
1918
if t == nil {
2019
return reflect.Value{}, fmt.Errorf("interface{} not allowed")
2120
}
22-
f.max_depth--
23-
if f.max_depth < 0 {
21+
f.maxDepth--
22+
if f.maxDepth < 0 {
2423
return reflect.Value{}, fmt.Errorf("max_depth reached")
2524
}
2625
k := t.Kind()
@@ -145,7 +144,7 @@ func (f faker) getFakedValue(a interface{}) (reflect.Value, error) {
145144

146145
func WithMaxDepth(depth int) Option {
147146
return func(f *faker) {
148-
f.max_depth = depth
147+
f.maxDepth = depth
149148
}
150149
}
151150

@@ -160,7 +159,7 @@ func FakeObject(obj interface{}, opts ...Option) error {
160159
return fmt.Errorf("object is nil %s", reflectType.Elem().String())
161160
}
162161
f := &faker{
163-
max_depth: 12,
162+
maxDepth: 12,
164163
}
165164
for _, o := range opts {
166165
o(f)

plugins/source.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ func WithSourceLogger(logger zerolog.Logger) SourceOption {
5050
// Add internal columns
5151
func addInternalColumns(tables []*schema.Table) {
5252
for _, table := range tables {
53-
cqId := schema.CqIdColumn
53+
cqID := schema.CqIDColumn
5454
if len(table.PrimaryKeys()) == 0 {
55-
cqId.CreationOptions.PrimaryKey = true
55+
cqID.CreationOptions.PrimaryKey = true
5656
}
57-
table.Columns = append(table.Columns, cqId, schema.CqFetchTime)
57+
table.Columns = append(table.Columns, cqID, schema.CqFetchTime)
5858
addInternalColumns(table.Relations)
5959
}
6060
}

schema/filters.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package schema
22

3-
// DeleteParentIdFilter is mostly used for table relations to delete table data based on parent's cq_id
4-
func DeleteParentIdFilter(id string) func(meta ClientMeta, parent *Resource) []interface{} {
3+
// DeleteParentIDFilter is mostly used for table relations to delete table data based on parent's cq_id
4+
func DeleteParentIDFilter(id string) func(meta ClientMeta, parent *Resource) []interface{} {
55
return func(meta ClientMeta, parent *Resource) []interface{} {
66
if parent == nil {
77
return nil
88
}
9-
return []interface{}{id, parent.Id()}
9+
return []interface{}{id, parent.ID()}
1010
}
1111
}

schema/meta.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ type ClientMeta interface {
1212

1313
type Meta struct {
1414
LastUpdate time.Time `json:"last_updated"`
15-
FetchId string `json:"fetch_id,omitempty"`
15+
FetchID string `json:"fetch_id,omitempty"`
1616
}
1717

18-
const FetchIdMetaKey = "cq_fetch_id"
18+
const FetchIDMetaKey = "cq_fetch_id"
1919

20-
var CqIdColumn = Column{Name: "_cq_id", Type: TypeUUID, Description: "Internal CQ ID of the row", Resolver: CQUUIDResolver()}
20+
var CqIDColumn = Column{Name: "_cq_id", Type: TypeUUID, Description: "Internal CQ ID of the row", Resolver: CQUUIDResolver()}
2121
var CqFetchTime = Column{Name: "_cq_fetch_time", Type: TypeTimestamp, Description: "Internal CQ row of when fetch was started (this will be the same for all rows in a single fetch)"}
2222

2323
var CqColumns = []Column{
24-
CqIdColumn,
24+
CqIDColumn,
2525
CqFetchTime,
2626
}

schema/resolvers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ func CQUUIDResolver() ColumnResolver {
2626
}
2727
}
2828

29-
// ParentIdResolver resolves the cq_id from the parent
29+
// ParentIDResolver resolves the cq_id from the parent
3030
// if you want to reference the parent's primary keys use ParentResourceFieldResolver as required.
31-
func ParentIdResolver(_ context.Context, _ ClientMeta, r *Resource, c Column) error {
32-
return r.Set(c.Name, r.Parent.Id())
31+
func ParentIDResolver(_ context.Context, _ ClientMeta, r *Resource, c Column) error {
32+
return r.Set(c.Name, r.Parent.ID())
3333
}
3434

3535
// ParentResourceFieldResolver resolves a field from the parent's resource, the value is expected to be set

schema/resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ func (r *Resource) SetItem(item interface{}) {
7777
r.Item = item
7878
}
7979

80-
func (r *Resource) Id() uuid.UUID {
81-
if r.Data[CqIdColumn.Name] == nil {
80+
func (r *Resource) ID() uuid.UUID {
81+
if r.Data[CqIDColumn.Name] == nil {
8282
return uuid.UUID{}
8383
}
84-
return r.Data[CqIdColumn.Name].(uuid.UUID)
84+
return r.Data[CqIDColumn.Name].(uuid.UUID)
8585
}
8686

8787
func (r *Resource) Columns() []string {
@@ -91,7 +91,7 @@ func (r *Resource) Columns() []string {
9191
func (rr Resources) GetIds() []uuid.UUID {
9292
rids := make([]uuid.UUID, len(rr))
9393
for i, r := range rr {
94-
rids[i] = r.Id()
94+
rids[i] = r.ID()
9595
}
9696
return rids
9797
}

specs/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (s *Spec) UnmarshalJSON(data []byte) error {
7878
return json.Unmarshal(b, s.Spec)
7979
}
8080

81-
func UnmarshalJsonStrict(b []byte, out interface{}) error {
81+
func UnmarshalJSONStrict(b []byte, out interface{}) error {
8282
dec := json.NewDecoder(bytes.NewReader(b))
8383
dec.DisallowUnknownFields()
8484
dec.UseNumber()

0 commit comments

Comments
 (0)