Skip to content

Commit 5e532b0

Browse files
committed
fix: resolve all lint issues
1 parent 677ede5 commit 5e532b0

5 files changed

Lines changed: 11 additions & 55 deletions

File tree

cli/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ var (
3232
},
3333
}
3434

35-
namespaceID string
3635
)
3736

3837
func New(cliConfig *config.Config) *cobra.Command {

cli/utils.go

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,12 @@ package cli
22

33
import (
44
"encoding/json"
5-
"errors"
6-
"fmt"
7-
"os"
8-
"path/filepath"
9-
"strings"
10-
11-
"google.golang.org/protobuf/encoding/protojson"
12-
"google.golang.org/protobuf/reflect/protoreflect"
135
)
146

15-
func parseFile(filePath string, v protoreflect.ProtoMessage) error {
16-
b, err := os.ReadFile(filePath)
7+
func prettyPrint(v interface{}) string {
8+
b, err := json.MarshalIndent(v, "", " ")
179
if err != nil {
18-
return err
19-
}
20-
21-
switch filepath.Ext(filePath) {
22-
case ".json":
23-
if err := protojson.Unmarshal(b, v); err != nil {
24-
return fmt.Errorf("invalid json: %w", err)
25-
}
26-
case ".yaml", ".yml":
27-
if err := protojson.Unmarshal(b, v); err != nil {
28-
return fmt.Errorf("invalid yaml: %w", err)
29-
}
30-
default:
31-
return errors.New("unsupported file type")
32-
}
33-
34-
return nil
35-
}
36-
37-
func prettyPrint(i interface{}) string {
38-
s, _ := json.MarshalIndent(i, "", "\t")
39-
return string(s)
40-
}
41-
42-
func makeMapFromString(commaSepStr string) map[string]string {
43-
m := make(map[string]string)
44-
keyValArray := strings.Split(commaSepStr, ",")
45-
for _, s := range keyValArray {
46-
arr := strings.Split(s, ":")
47-
m[arr[0]] = arr[1]
10+
return ""
4811
}
49-
return m
12+
return string(b)
5013
}

core/entity/service.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ func (s *Service) GetContext(ctx context.Context, ns *namespace.Namespace, urn s
112112
cg := &ContextGraph{Entity: ent}
113113

114114
if s.edges != nil {
115-
if depth <= 0 {
116-
depth = 2
117-
}
115+
_ = depth // TODO: use depth for multi-hop traversal
118116
outgoing, _ := s.edges.GetBySource(ctx, ns, urn, EdgeFilter{Current: true})
119117
incoming, _ := s.edges.GetByTarget(ctx, ns, urn, EdgeFilter{Current: true})
120118
cg.Edges = append(outgoing, incoming...)

core/entity/service_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestService_Delete(t *testing.T) {
110110
ctx := context.Background()
111111
ns := namespace.DefaultNamespace
112112

113-
svc.Upsert(ctx, ns, &Entity{URN: "urn:x", Type: TypeJob, Name: "x"})
113+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:x", Type: TypeJob, Name: "x"})
114114

115115
err := svc.Delete(ctx, ns, "urn:x")
116116
if err != nil {
@@ -129,8 +129,8 @@ func TestService_GetAll(t *testing.T) {
129129
ctx := context.Background()
130130
ns := namespace.DefaultNamespace
131131

132-
svc.Upsert(ctx, ns, &Entity{URN: "urn:a", Type: TypeTable, Name: "a"})
133-
svc.Upsert(ctx, ns, &Entity{URN: "urn:b", Type: TypeJob, Name: "b"})
132+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:a", Type: TypeTable, Name: "a"})
133+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:b", Type: TypeJob, Name: "b"})
134134

135135
entities, count, err := svc.GetAll(ctx, ns, Filter{})
136136
if err != nil {
@@ -150,9 +150,9 @@ func TestService_GetTypes(t *testing.T) {
150150
ctx := context.Background()
151151
ns := namespace.DefaultNamespace
152152

153-
svc.Upsert(ctx, ns, &Entity{URN: "urn:a", Type: TypeTable, Name: "a"})
154-
svc.Upsert(ctx, ns, &Entity{URN: "urn:b", Type: TypeTable, Name: "b"})
155-
svc.Upsert(ctx, ns, &Entity{URN: "urn:c", Type: TypeJob, Name: "c"})
153+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:a", Type: TypeTable, Name: "a"})
154+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:b", Type: TypeTable, Name: "b"})
155+
_, _ = svc.Upsert(ctx, ns, &Entity{URN: "urn:c", Type: TypeJob, Name: "c"})
156156

157157
types, err := svc.GetTypes(ctx, ns)
158158
if err != nil {

handler/handler.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,3 @@ func internalServerError(ctx context.Context, msg string, err error) error {
6969
ref,
7070
))
7171
}
72-
73-
func bodyParserErrorMsg(err error) string {
74-
return fmt.Sprintf("error parsing request body: %v", err)
75-
}

0 commit comments

Comments
 (0)