Passed
Push — master ( c5e27d...3c7e9a )
by Tolga
02:44 queued 54s
created

invoke.decreaseDepth   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
package invoke
2
3
import (
4
	"errors"
5
	"sync/atomic"
6
7
	base "github.com/Permify/permify/pkg/pb/base/v1"
8
)
9
10
// checkDepth - a helper function that returns an error if the depth in a PermissionCheckRequest is zero.
11
func checkDepth(request *base.PermissionCheckRequest) error {
12
	if atomic.LoadInt32(&request.GetMetadata().Depth) == 0 {
13
		return errors.New(base.ErrorCode_ERROR_CODE_DEPTH_NOT_ENOUGH.String())
14
	}
15
	return nil
16
}
17