Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable errcheck for the project and fix the violations discovered #65

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ linters:
disable-all: true
enable:
- bodyclose
- errcheck
- errname
- gofmt
- goimports
Expand Down
3 changes: 2 additions & 1 deletion corpus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestCorpus(t *testing.T) {
action := cedar.EntityUID(request.Action)
resource := cedar.EntityUID(request.Resource)
context := request.Context
batch.Authorize(ctx, policySet, entities, batch.Request{
err := batch.Authorize(ctx, policySet, entities, batch.Request{
Principal: batch.Variable("principal"),
Action: batch.Variable("action"),
Resource: batch.Variable("resource"),
Expand All @@ -212,6 +212,7 @@ func TestCorpus(t *testing.T) {
res = r
total++
})
testutil.OK(t, err)
testutil.Equals(t, total, 1)
testutil.Equals(t, res.Request.Principal, principal)
testutil.Equals(t, res.Request.Action, action)
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/partial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ func TestPartialBasic(t *testing.T) {
func TestPartialPanic(t *testing.T) {
t.Parallel()
testutil.Panic(t, func() {
partial(Env{}, nil)
_, _ = partial(Env{}, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way, but I think there's a //lint:noerrcheck or something to that effect that is an alternative, here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of ambivalent as well, so I guess I'll go with the more terse option, especially since this is a test.

})
}

Expand Down
11 changes: 4 additions & 7 deletions internal/json/json_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,16 @@ func (s *scopeJSON) FromNode(src ast.IsScopeNode) {
}
}

func unaryToJSON(dest **unaryJSON, src ast.UnaryNode) error {
n := ast.UnaryNode(src)
func unaryToJSON(dest **unaryJSON, src ast.UnaryNode) {
res := &unaryJSON{}
res.Arg.FromNode(n.Arg)
res.Arg.FromNode(src.Arg)
*dest = res
return nil
}

func binaryToJSON(dest **binaryJSON, src ast.BinaryNode) {
n := ast.BinaryNode(src)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor pointed out that this cast was unnecessary

res := &binaryJSON{}
res.Left.FromNode(n.Left)
res.Right.FromNode(n.Right)
res.Left.FromNode(src.Left)
res.Right.FromNode(src.Right)
*dest = res
}

Expand Down
Loading