Skip to content

Commit 9f4bbb7

Browse files
jpogranradeksimko
andauthored
Apply suggestions from code review
Co-authored-by: Radek Simko <[email protected]>
1 parent 512c5b7 commit 9f4bbb7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

decoder/candidates_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"testing"
99

1010
"github.com/google/go-cmp/cmp"
11-
1211
"github.com/hashicorp/hcl-lang/lang"
1312
"github.com/hashicorp/hcl-lang/schema"
1413
"github.com/hashicorp/hcl/v2"

decoder/hover.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ func (d *PathDecoder) hoverDataForExpr(ctx context.Context, expr hcl.Expression,
248248
}, nil
249249
}
250250

251-
address, _ := lang.TraversalToAddress(e.AsTraversal())
251+
address, err := lang.TraversalToAddress(e.AsTraversal())
252+
if err != nil {
253+
return nil, err
254+
}
252255
if address.Equals(lang.Address{
253256
lang.RootStep{
254257
Name: "count",

decoder/hover_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,10 @@ func TestDecoder_HoverAtPos_extension(t *testing.T) {
974974
}
975975
`)
976976

977-
f, _ := hclsyntax.ParseConfig(testConfig, "test.tf", hcl.InitialPos)
977+
f, err := hclsyntax.ParseConfig(testConfig, "test.tf", hcl.InitialPos)
978+
if err != nil {
979+
t.Fatal(err)
980+
}
978981

979982
d := testPathDecoder(t, &PathContext{
980983
Schema: bodySchema,

decoder/semantic_tokens.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex
160160
}
161161
}
162162

163-
address, _ := lang.TraversalToAddress(eType.AsTraversal())
163+
address, err := lang.TraversalToAddress(eType.AsTraversal())
164+
if err != nil {
165+
return tokens
166+
}
164167
countAvailable := schema.ActiveCountFromContext(ctx)
165168
countIndexAttr := lang.Address{
166169
lang.RootStep{

0 commit comments

Comments
 (0)