Skip to content

Commit

Permalink
feat: add .golangci-lint.yml and apply lint (#1372)
Browse files Browse the repository at this point in the history
* feat: add golangci-lint config

* ci: update lint ci config

* ci: disable noisy lint rules

* refactor: apply lint

* ci: disable lint rules for future improvement
  • Loading branch information
MuZhou233 committed Mar 10, 2024
1 parent caebc40 commit 2858196
Show file tree
Hide file tree
Showing 39 changed files with 546 additions and 224 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,8 @@ jobs:
- name: Run go test bench
run: make benchmark

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.20'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51

semantic-release:
needs: [test, lint]
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: golangci-lint

on:
push:
branches:
- master
- main
pull_request:

jobs:
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
22 changes: 0 additions & 22 deletions .github/workflows/staticcheck.yaml

This file was deleted.

344 changes: 344 additions & 0 deletions .golangci.yml

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ import (
)

var (
// DEFAULT_SECTION specifies the name of a section if no name provided
// DEFAULT_SECTION specifies the name of a section if no name provided.
DEFAULT_SECTION = "default"
// DEFAULT_COMMENT defines what character(s) indicate a comment `#`
// DEFAULT_COMMENT defines what character(s) indicate a comment `#`.
DEFAULT_COMMENT = []byte{'#'}
// DEFAULT_COMMENT_SEM defines what alternate character(s) indicate a comment `;`
// DEFAULT_COMMENT_SEM defines what alternate character(s) indicate a comment `;`.
DEFAULT_COMMENT_SEM = []byte{';'}
// DEFAULT_MULTI_LINE_SEPARATOR defines what character indicates a multi-line content
// DEFAULT_MULTI_LINE_SEPARATOR defines what character indicates a multi-line content.
DEFAULT_MULTI_LINE_SEPARATOR = []byte{'\\'}
)

// ConfigInterface defines the behavior of a Config implementation
// ConfigInterface defines the behavior of a Config implementation.
type ConfigInterface interface {
String(key string) string
Strings(key string) []string
Expand All @@ -47,7 +47,7 @@ type ConfigInterface interface {
Set(key string, value string) error
}

// Config represents an implementation of the ConfigInterface
// Config represents an implementation of the ConfigInterface.
type Config struct {
// Section:key=value
data map[string]map[string]string
Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *Config) parseBuffer(buf *bufio.Reader) error {
if err == io.EOF {
// force write when buffer is not flushed yet
if buffer.Len() > 0 {
if err := c.write(section, lineNum, &buffer); err != nil {
if err = c.write(section, lineNum, &buffer); err != nil {
return err
}
}
Expand Down Expand Up @@ -185,33 +185,33 @@ func (c *Config) write(section string, lineNum int, b *bytes.Buffer) error {
return nil
}

// Bool lookups up the value using the provided key and converts the value to a bool
// Bool lookups up the value using the provided key and converts the value to a bool.
func (c *Config) Bool(key string) (bool, error) {
return strconv.ParseBool(c.get(key))
}

// Int lookups up the value using the provided key and converts the value to a int
// Int lookups up the value using the provided key and converts the value to a int.
func (c *Config) Int(key string) (int, error) {
return strconv.Atoi(c.get(key))
}

// Int64 lookups up the value using the provided key and converts the value to a int64
// Int64 lookups up the value using the provided key and converts the value to a int64.
func (c *Config) Int64(key string) (int64, error) {
return strconv.ParseInt(c.get(key), 10, 64)
}

// Float64 lookups up the value using the provided key and converts the value to a float64
// Float64 lookups up the value using the provided key and converts the value to a float64.
func (c *Config) Float64(key string) (float64, error) {
return strconv.ParseFloat(c.get(key), 64)
}

// String lookups up the value using the provided key and converts the value to a string
// String lookups up the value using the provided key and converts the value to a string.
func (c *Config) String(key string) string {
return c.get(key)
}

// Strings lookups up the value using the provided key and converts the value to an array of string
// by splitting the string by comma
// by splitting the string by comma.
func (c *Config) Strings(key string) []string {
v := c.get(key)
if v == "" {
Expand All @@ -220,7 +220,7 @@ func (c *Config) Strings(key string) []string {
return strings.Split(v, ",")
}

// Set sets the value for the specific key in the Config
// Set sets the value for the specific key in the Config.
func (c *Config) Set(key string, value string) error {
if len(key) == 0 {
return errors.New("key is empty")
Expand All @@ -243,7 +243,7 @@ func (c *Config) Set(key string, value string) error {
return nil
}

// section.key or key
// section.key or key.
func (c *Config) get(key string) string {
var (
section string
Expand Down
34 changes: 17 additions & 17 deletions enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Enforcer struct {
logger log.Logger
}

// EnforceContext is used as the first element of the parameter "rvals" in method "enforce"
// EnforceContext is used as the first element of the parameter "rvals" in method "enforce".
type EnforceContext struct {
RType string
PType string
Expand Down Expand Up @@ -539,7 +539,7 @@ func (e *Enforcer) EnableAutoBuildRoleLinks(autoBuildRoleLinks bool) {
e.autoBuildRoleLinks = autoBuildRoleLinks
}

// EnableAcceptJsonRequest controls whether to accept json as a request parameter
// EnableAcceptJsonRequest controls whether to accept json as a request parameter.
func (e *Enforcer) EnableAcceptJsonRequest(acceptJsonRequest bool) {
e.acceptJsonRequest = acceptJsonRequest
}
Expand Down Expand Up @@ -571,7 +571,7 @@ func (e *Enforcer) BuildIncrementalConditionalRoleLinks(op model.PolicyOp, ptype
return e.model.BuildIncrementalConditionalRoleLinks(e.condRmMap, op, "g", ptype, rules)
}

// NewEnforceContext Create a default structure based on the suffix
// NewEnforceContext Create a default structure based on the suffix.
func NewEnforceContext(suffix string) EnforceContext {
return EnforceContext{
RType: "r" + suffix,
Expand Down Expand Up @@ -654,7 +654,8 @@ func (e *Enforcer) enforce(matcher string, explains *[]string, rvals ...interfac
for i, rval := range rvals {
switch rval := rval.(type) {
case string:
mapValue, err := util.JsonToMap(rval)
var mapValue map[string]interface{}
mapValue, err = util.JsonToMap(rval)
if err == nil {
rvals[i] = mapValue
}
Expand Down Expand Up @@ -757,7 +758,6 @@ func (e *Enforcer) enforce(matcher string, explains *[]string, rvals ...interfac
}
}
} else {

if hasEval && len(e.model["p"][pType].Policy) == 0 {
return false, errors.New("please make sure rule exists in policy when using eval() in matcher")
}
Expand Down Expand Up @@ -836,21 +836,21 @@ func (e *Enforcer) EnforceWithMatcher(matcher string, rvals ...interface{}) (boo
return e.enforce(matcher, nil, rvals...)
}

// EnforceEx explain enforcement by informing matched rules
// EnforceEx explain enforcement by informing matched rules.
func (e *Enforcer) EnforceEx(rvals ...interface{}) (bool, []string, error) {
explain := []string{}
result, err := e.enforce("", &explain, rvals...)
return result, explain, err
}

// EnforceExWithMatcher use a custom matcher and explain enforcement by informing matched rules
// EnforceExWithMatcher use a custom matcher and explain enforcement by informing matched rules.
func (e *Enforcer) EnforceExWithMatcher(matcher string, rvals ...interface{}) (bool, []string, error) {
explain := []string{}
result, err := e.enforce(matcher, &explain, rvals...)
return result, explain, err
}

// BatchEnforce enforce in batches
// BatchEnforce enforce in batches.
func (e *Enforcer) BatchEnforce(requests [][]interface{}) ([]bool, error) {
var results []bool
for _, request := range requests {
Expand All @@ -863,7 +863,7 @@ func (e *Enforcer) BatchEnforce(requests [][]interface{}) ([]bool, error) {
return results, nil
}

// BatchEnforceWithMatcher enforce with matcher in batches
// BatchEnforceWithMatcher enforce with matcher in batches.
func (e *Enforcer) BatchEnforceWithMatcher(matcher string, requests [][]interface{}) ([]bool, error) {
var results []bool
for _, request := range requests {
Expand All @@ -876,7 +876,7 @@ func (e *Enforcer) BatchEnforceWithMatcher(matcher string, requests [][]interfac
return results, nil
}

// AddNamedMatchingFunc add MatchingFunc by ptype RoleManager
// AddNamedMatchingFunc add MatchingFunc by ptype RoleManager.
func (e *Enforcer) AddNamedMatchingFunc(ptype, name string, fn rbac.MatchingFunc) bool {
if rm, ok := e.rmMap[ptype]; ok {
rm.AddMatchingFunc(name, fn)
Expand All @@ -885,7 +885,7 @@ func (e *Enforcer) AddNamedMatchingFunc(ptype, name string, fn rbac.MatchingFunc
return false
}

// AddNamedDomainMatchingFunc add MatchingFunc by ptype to RoleManager
// AddNamedDomainMatchingFunc add MatchingFunc by ptype to RoleManager.
func (e *Enforcer) AddNamedDomainMatchingFunc(ptype, name string, fn rbac.MatchingFunc) bool {
if rm, ok := e.rmMap[ptype]; ok {
rm.AddDomainMatchingFunc(name, fn)
Expand All @@ -895,7 +895,7 @@ func (e *Enforcer) AddNamedDomainMatchingFunc(ptype, name string, fn rbac.Matchi
}

// AddNamedLinkConditionFunc Add condition function fn for Link userName->roleName,
// when fn returns true, Link is valid, otherwise invalid
// when fn returns true, Link is valid, otherwise invalid.
func (e *Enforcer) AddNamedLinkConditionFunc(ptype, user, role string, fn rbac.LinkConditionFunc) bool {
if rm, ok := e.condRmMap[ptype]; ok {
rm.AddLinkConditionFunc(user, role, fn)
Expand All @@ -905,7 +905,7 @@ func (e *Enforcer) AddNamedLinkConditionFunc(ptype, user, role string, fn rbac.L
}

// AddNamedDomainLinkConditionFunc Add condition function fn for Link userName-> {roleName, domain},
// when fn returns true, Link is valid, otherwise invalid
// when fn returns true, Link is valid, otherwise invalid.
func (e *Enforcer) AddNamedDomainLinkConditionFunc(ptype, user, role string, domain string, fn rbac.LinkConditionFunc) bool {
if rm, ok := e.condRmMap[ptype]; ok {
rm.AddDomainLinkConditionFunc(user, role, domain, fn)
Expand All @@ -914,7 +914,7 @@ func (e *Enforcer) AddNamedDomainLinkConditionFunc(ptype, user, role string, dom
return false
}

// SetNamedLinkConditionFuncParams Sets the parameters of the condition function fn for Link userName->roleName
// SetNamedLinkConditionFuncParams Sets the parameters of the condition function fn for Link userName->roleName.
func (e *Enforcer) SetNamedLinkConditionFuncParams(ptype, user, role string, params ...string) bool {
if rm, ok := e.condRmMap[ptype]; ok {
rm.SetLinkConditionFuncParams(user, role, params...)
Expand All @@ -924,7 +924,7 @@ func (e *Enforcer) SetNamedLinkConditionFuncParams(ptype, user, role string, par
}

// SetNamedDomainLinkConditionFuncParams Sets the parameters of the condition function fn
// for Link userName->{roleName, domain}
// for Link userName->{roleName, domain}.
func (e *Enforcer) SetNamedDomainLinkConditionFuncParams(ptype, user, role, domain string, params ...string) bool {
if rm, ok := e.condRmMap[ptype]; ok {
rm.SetDomainLinkConditionFuncParams(user, role, domain, params...)
Expand All @@ -933,7 +933,7 @@ func (e *Enforcer) SetNamedDomainLinkConditionFuncParams(ptype, user, role, doma
return false
}

// assumes bounds have already been checked
// assumes bounds have already been checked.
type enforceParameters struct {
rTokens map[string]int
rVals []interface{}
Expand All @@ -942,7 +942,7 @@ type enforceParameters struct {
pVals []string
}

// implements govaluate.Parameters
// implements govaluate.Parameters.
func (p enforceParameters) Get(name string) (interface{}, error) {
if name == "" {
return nil, nil
Expand Down
4 changes: 2 additions & 2 deletions enforcer_cached.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/casbin/casbin/v2/persist/cache"
)

// CachedEnforcer wraps Enforcer and provides decision cache
// CachedEnforcer wraps Enforcer and provides decision cache.
type CachedEnforcer struct {
*Enforcer
expireTime time.Duration
Expand Down Expand Up @@ -61,7 +61,7 @@ func (e *CachedEnforcer) EnableCache(enableCache bool) {
}

// Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
// if rvals is not string , ingore the cache
// if rvals is not string , ingore the cache.
func (e *CachedEnforcer) Enforce(rvals ...interface{}) (bool, error) {
if atomic.LoadInt32(&e.enableCache) == 0 {
return e.Enforcer.Enforce(rvals...)
Expand Down
6 changes: 3 additions & 3 deletions enforcer_cached_synced.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/casbin/casbin/v2/persist/cache"
)

// SyncedCachedEnforcer wraps Enforcer and provides decision sync cache
// SyncedCachedEnforcer wraps Enforcer and provides decision sync cache.
type SyncedCachedEnforcer struct {
*SyncedEnforcer
expireTime time.Duration
Expand Down Expand Up @@ -56,7 +56,7 @@ func (e *SyncedCachedEnforcer) EnableCache(enableCache bool) {
}

// Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
// if rvals is not string , ingore the cache
// if rvals is not string , ingore the cache.
func (e *SyncedCachedEnforcer) Enforce(rvals ...interface{}) (bool, error) {
if atomic.LoadInt32(&e.enableCache) == 0 {
return e.SyncedEnforcer.Enforce(rvals...)
Expand Down Expand Up @@ -129,7 +129,7 @@ func (e *SyncedCachedEnforcer) SetExpireTime(expireTime time.Duration) {
e.expireTime = expireTime
}

// SetCache need to be sync cache
// SetCache need to be sync cache.
func (e *SyncedCachedEnforcer) SetCache(c cache.Cache) {
e.locker.Lock()
defer e.locker.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions enforcer_distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (d *DistributedEnforcer) RemovePoliciesSelf(shouldPersist func() bool, sec
d.m.Lock()
defer d.m.Unlock()
if shouldPersist != nil && shouldPersist() {
if err := d.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil {
if err = d.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil {
if err.Error() != notImplemented {
return nil, err
}
Expand All @@ -74,7 +74,7 @@ func (d *DistributedEnforcer) RemovePoliciesSelf(shouldPersist func() bool, sec
affected = d.model.RemovePoliciesWithAffected(sec, ptype, rules)

if sec == "g" {
err := d.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, affected)
err = d.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, affected)
if err != nil {
return affected, err
}
Expand Down
2 changes: 1 addition & 1 deletion enforcer_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ IEnforcer = &Enforcer{}
var _ IEnforcer = &SyncedEnforcer{}
var _ IEnforcer = &CachedEnforcer{}

// IEnforcer is the API interface of Enforcer
// IEnforcer is the API interface of Enforcer.
type IEnforcer interface {
/* Enforcer API */
InitWithFile(modelPath string, policyPath string) error
Expand Down
Loading

2 comments on commit 2858196

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 2858196 Previous: caebc40 Ratio
BenchmarkCachedRaw 17.61 ns/op 0 B/op 0 allocs/op 17.57 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkCachedRaw - ns/op 17.61 ns/op 17.57 ns/op 1.00
BenchmarkCachedRaw - B/op 0 B/op 0 B/op 1
BenchmarkCachedRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkCachedBasicModel 182.7 ns/op 104 B/op 4 allocs/op 167.1 ns/op 104 B/op 4 allocs/op 1.09
BenchmarkCachedBasicModel - ns/op 182.7 ns/op 167.1 ns/op 1.09
BenchmarkCachedBasicModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedBasicModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModel 187.8 ns/op 104 B/op 4 allocs/op 167.5 ns/op 104 B/op 4 allocs/op 1.12
BenchmarkCachedRBACModel - ns/op 187.8 ns/op 167.5 ns/op 1.12
BenchmarkCachedRBACModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelSmall 190.6 ns/op 104 B/op 4 allocs/op 191.3 ns/op 104 B/op 4 allocs/op 1.00
BenchmarkCachedRBACModelSmall - ns/op 190.6 ns/op 191.3 ns/op 1.00
BenchmarkCachedRBACModelSmall - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelSmall - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelMedium 192.1 ns/op 104 B/op 4 allocs/op 194.3 ns/op 104 B/op 4 allocs/op 0.99
BenchmarkCachedRBACModelMedium - ns/op 192.1 ns/op 194.3 ns/op 0.99
BenchmarkCachedRBACModelMedium - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelMedium - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelLarge 188.5 ns/op 96 B/op 3 allocs/op 166.9 ns/op 96 B/op 3 allocs/op 1.13
BenchmarkCachedRBACModelLarge - ns/op 188.5 ns/op 166.9 ns/op 1.13
BenchmarkCachedRBACModelLarge - B/op 96 B/op 96 B/op 1
BenchmarkCachedRBACModelLarge - allocs/op 3 allocs/op 3 allocs/op 1
BenchmarkCachedRBACModelWithResourceRoles 177.5 ns/op 104 B/op 4 allocs/op 171.1 ns/op 104 B/op 4 allocs/op 1.04
BenchmarkCachedRBACModelWithResourceRoles - ns/op 177.5 ns/op 171.1 ns/op 1.04
BenchmarkCachedRBACModelWithResourceRoles - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithResourceRoles - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDomains 187.9 ns/op 120 B/op 4 allocs/op 181.6 ns/op 120 B/op 4 allocs/op 1.03
BenchmarkCachedRBACModelWithDomains - ns/op 187.9 ns/op 181.6 ns/op 1.03
BenchmarkCachedRBACModelWithDomains - B/op 120 B/op 120 B/op 1
BenchmarkCachedRBACModelWithDomains - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedABACModel 2929 ns/op 1539 B/op 18 allocs/op 2712 ns/op 1540 B/op 18 allocs/op 1.08
BenchmarkCachedABACModel - ns/op 2929 ns/op 2712 ns/op 1.08
BenchmarkCachedABACModel - B/op 1539 B/op 1540 B/op 1.00
BenchmarkCachedABACModel - allocs/op 18 allocs/op 18 allocs/op 1
BenchmarkCachedKeyMatchModel 199.1 ns/op 152 B/op 4 allocs/op 181.2 ns/op 152 B/op 4 allocs/op 1.10
BenchmarkCachedKeyMatchModel - ns/op 199.1 ns/op 181.2 ns/op 1.10
BenchmarkCachedKeyMatchModel - B/op 152 B/op 152 B/op 1
BenchmarkCachedKeyMatchModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDeny 182.5 ns/op 104 B/op 4 allocs/op 172.3 ns/op 104 B/op 4 allocs/op 1.06
BenchmarkCachedRBACModelWithDeny - ns/op 182.5 ns/op 172.3 ns/op 1.06
BenchmarkCachedRBACModelWithDeny - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithDeny - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedPriorityModel 181.5 ns/op 104 B/op 4 allocs/op 168.4 ns/op 104 B/op 4 allocs/op 1.08
BenchmarkCachedPriorityModel - ns/op 181.5 ns/op 168.4 ns/op 1.08
BenchmarkCachedPriorityModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedPriorityModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedWithEnforceContext 323.3 ns/op 240 B/op 5 allocs/op 290.1 ns/op 240 B/op 5 allocs/op 1.11
BenchmarkCachedWithEnforceContext - ns/op 323.3 ns/op 290.1 ns/op 1.11
BenchmarkCachedWithEnforceContext - B/op 240 B/op 240 B/op 1
BenchmarkCachedWithEnforceContext - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkCachedRBACModelMediumParallel 181.6 ns/op 106 B/op 4 allocs/op 179.5 ns/op 106 B/op 4 allocs/op 1.01
BenchmarkCachedRBACModelMediumParallel - ns/op 181.6 ns/op 179.5 ns/op 1.01
BenchmarkCachedRBACModelMediumParallel - B/op 106 B/op 106 B/op 1
BenchmarkCachedRBACModelMediumParallel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkHasPolicySmall 493.2 ns/op 150 B/op 6 allocs/op 468.5 ns/op 150 B/op 6 allocs/op 1.05
BenchmarkHasPolicySmall - ns/op 493.2 ns/op 468.5 ns/op 1.05
BenchmarkHasPolicySmall - B/op 150 B/op 150 B/op 1
BenchmarkHasPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyMedium 514.2 ns/op 157 B/op 6 allocs/op 501.6 ns/op 157 B/op 6 allocs/op 1.03
BenchmarkHasPolicyMedium - ns/op 514.2 ns/op 501.6 ns/op 1.03
BenchmarkHasPolicyMedium - B/op 157 B/op 157 B/op 1
BenchmarkHasPolicyMedium - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyLarge 534.3 ns/op 165 B/op 7 allocs/op 529.6 ns/op 165 B/op 7 allocs/op 1.01
BenchmarkHasPolicyLarge - ns/op 534.3 ns/op 529.6 ns/op 1.01
BenchmarkHasPolicyLarge - B/op 165 B/op 165 B/op 1
BenchmarkHasPolicyLarge - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicySmall 501.6 ns/op 152 B/op 6 allocs/op 473.2 ns/op 152 B/op 6 allocs/op 1.06
BenchmarkAddPolicySmall - ns/op 501.6 ns/op 473.2 ns/op 1.06
BenchmarkAddPolicySmall - B/op 152 B/op 152 B/op 1
BenchmarkAddPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkAddPolicyMedium 585.4 ns/op 177 B/op 7 allocs/op 556 ns/op 176 B/op 7 allocs/op 1.05
BenchmarkAddPolicyMedium - ns/op 585.4 ns/op 556 ns/op 1.05
BenchmarkAddPolicyMedium - B/op 177 B/op 176 B/op 1.01
BenchmarkAddPolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicyLarge 1283 ns/op 470 B/op 9 allocs/op 1114 ns/op 470 B/op 9 allocs/op 1.15
BenchmarkAddPolicyLarge - ns/op 1283 ns/op 1114 ns/op 1.15
BenchmarkAddPolicyLarge - B/op 470 B/op 470 B/op 1
BenchmarkAddPolicyLarge - allocs/op 9 allocs/op 9 allocs/op 1
BenchmarkRemovePolicySmall 516.7 ns/op 166 B/op 7 allocs/op 486.8 ns/op 166 B/op 7 allocs/op 1.06
BenchmarkRemovePolicySmall - ns/op 516.7 ns/op 486.8 ns/op 1.06
BenchmarkRemovePolicySmall - B/op 166 B/op 166 B/op 1
BenchmarkRemovePolicySmall - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyMedium 572.8 ns/op 177 B/op 7 allocs/op 529.7 ns/op 177 B/op 7 allocs/op 1.08
BenchmarkRemovePolicyMedium - ns/op 572.8 ns/op 529.7 ns/op 1.08
BenchmarkRemovePolicyMedium - B/op 177 B/op 177 B/op 1
BenchmarkRemovePolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyLarge 1212 ns/op 290 B/op 13 allocs/op 1273 ns/op 287 B/op 13 allocs/op 0.95
BenchmarkRemovePolicyLarge - ns/op 1212 ns/op 1273 ns/op 0.95
BenchmarkRemovePolicyLarge - B/op 290 B/op 287 B/op 1.01
BenchmarkRemovePolicyLarge - allocs/op 13 allocs/op 13 allocs/op 1
BenchmarkRaw 17.69 ns/op 0 B/op 0 allocs/op 17.55 ns/op 0 B/op 0 allocs/op 1.01
BenchmarkRaw - ns/op 17.69 ns/op 17.55 ns/op 1.01
BenchmarkRaw - B/op 0 B/op 0 B/op 1
BenchmarkRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkBasicModel 3816 ns/op 1510 B/op 17 allocs/op 3490 ns/op 1506 B/op 17 allocs/op 1.09
BenchmarkBasicModel - ns/op 3816 ns/op 3490 ns/op 1.09
BenchmarkBasicModel - B/op 1510 B/op 1506 B/op 1.00
BenchmarkBasicModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkRBACModel 5765 ns/op 2068 B/op 35 allocs/op 5316 ns/op 2063 B/op 35 allocs/op 1.08
BenchmarkRBACModel - ns/op 5765 ns/op 5316 ns/op 1.08
BenchmarkRBACModel - B/op 2068 B/op 2063 B/op 1.00
BenchmarkRBACModel - allocs/op 35 allocs/op 35 allocs/op 1
BenchmarkRBACModelSizes/small 51015 ns/op 20287 B/op 480 allocs/op 50637 ns/op 20309 B/op 480 allocs/op 1.01
BenchmarkRBACModelSizes/small - ns/op 51015 ns/op 50637 ns/op 1.01
BenchmarkRBACModelSizes/small - B/op 20287 B/op 20309 B/op 1.00
BenchmarkRBACModelSizes/small - allocs/op 480 allocs/op 480 allocs/op 1
BenchmarkRBACModelSizes/medium 561865 ns/op 191731 B/op 4828 allocs/op 494964 ns/op 191751 B/op 4828 allocs/op 1.14
BenchmarkRBACModelSizes/medium - ns/op 561865 ns/op 494964 ns/op 1.14
BenchmarkRBACModelSizes/medium - B/op 191731 B/op 191751 B/op 1.00
BenchmarkRBACModelSizes/medium - allocs/op 4828 allocs/op 4828 allocs/op 1
BenchmarkRBACModelSizes/large 6281436 ns/op 1897729 B/op 48112 allocs/op 5269002 ns/op 1906077 B/op 48353 allocs/op 1.19
BenchmarkRBACModelSizes/large - ns/op 6281436 ns/op 5269002 ns/op 1.19
BenchmarkRBACModelSizes/large - B/op 1897729 B/op 1906077 B/op 1.00
BenchmarkRBACModelSizes/large - allocs/op 48112 allocs/op 48353 allocs/op 1.00
BenchmarkRBACModelSmall 61613 ns/op 20346 B/op 615 allocs/op 60042 ns/op 20404 B/op 615 allocs/op 1.03
BenchmarkRBACModelSmall - ns/op 61613 ns/op 60042 ns/op 1.03
BenchmarkRBACModelSmall - B/op 20346 B/op 20404 B/op 1.00
BenchmarkRBACModelSmall - allocs/op 615 allocs/op 615 allocs/op 1
BenchmarkRBACModelMedium 612743 ns/op 194839 B/op 6022 allocs/op 570297 ns/op 194647 B/op 6021 allocs/op 1.07
BenchmarkRBACModelMedium - ns/op 612743 ns/op 570297 ns/op 1.07
BenchmarkRBACModelMedium - B/op 194839 B/op 194647 B/op 1.00
BenchmarkRBACModelMedium - allocs/op 6022 allocs/op 6021 allocs/op 1.00
BenchmarkRBACModelLarge 6577122 ns/op 1941897 B/op 60656 allocs/op 6095299 ns/op 1941573 B/op 60627 allocs/op 1.08
BenchmarkRBACModelLarge - ns/op 6577122 ns/op 6095299 ns/op 1.08
BenchmarkRBACModelLarge - B/op 1941897 B/op 1941573 B/op 1.00
BenchmarkRBACModelLarge - allocs/op 60656 allocs/op 60627 allocs/op 1.00
BenchmarkRBACModelWithResourceRoles 5469 ns/op 2731 B/op 28 allocs/op 5072 ns/op 2725 B/op 28 allocs/op 1.08
BenchmarkRBACModelWithResourceRoles - ns/op 5469 ns/op 5072 ns/op 1.08
BenchmarkRBACModelWithResourceRoles - B/op 2731 B/op 2725 B/op 1.00
BenchmarkRBACModelWithResourceRoles - allocs/op 28 allocs/op 28 allocs/op 1
BenchmarkRBACModelWithDomains 5436 ns/op 1827 B/op 25 allocs/op 4936 ns/op 1822 B/op 25 allocs/op 1.10
BenchmarkRBACModelWithDomains - ns/op 5436 ns/op 4936 ns/op 1.10
BenchmarkRBACModelWithDomains - B/op 1827 B/op 1822 B/op 1.00
BenchmarkRBACModelWithDomains - allocs/op 25 allocs/op 25 allocs/op 1
BenchmarkABACModel 2902 ns/op 1537 B/op 17 allocs/op 2694 ns/op 1531 B/op 17 allocs/op 1.08
BenchmarkABACModel - ns/op 2902 ns/op 2694 ns/op 1.08
BenchmarkABACModel - B/op 1537 B/op 1531 B/op 1.00
BenchmarkABACModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkABACRuleModel 4204941 ns/op 1325613 B/op 40092 allocs/op 3886211 ns/op 1324246 B/op 40091 allocs/op 1.08
BenchmarkABACRuleModel - ns/op 4204941 ns/op 3886211 ns/op 1.08
BenchmarkABACRuleModel - B/op 1325613 B/op 1324246 B/op 1.00
BenchmarkABACRuleModel - allocs/op 40092 allocs/op 40091 allocs/op 1.00
BenchmarkKeyMatchModel 6395 ns/op 3064 B/op 37 allocs/op 5968 ns/op 3061 B/op 37 allocs/op 1.07
BenchmarkKeyMatchModel - ns/op 6395 ns/op 5968 ns/op 1.07
BenchmarkKeyMatchModel - B/op 3064 B/op 3061 B/op 1.00
BenchmarkKeyMatchModel - allocs/op 37 allocs/op 37 allocs/op 1
BenchmarkRBACModelWithDeny 7263 ns/op 2482 B/op 49 allocs/op 6751 ns/op 2474 B/op 49 allocs/op 1.08
BenchmarkRBACModelWithDeny - ns/op 7263 ns/op 6751 ns/op 1.08
BenchmarkRBACModelWithDeny - B/op 2482 B/op 2474 B/op 1.00
BenchmarkRBACModelWithDeny - allocs/op 49 allocs/op 49 allocs/op 1
BenchmarkPriorityModel 4444 ns/op 1765 B/op 22 allocs/op 4061 ns/op 1757 B/op 22 allocs/op 1.09
BenchmarkPriorityModel - ns/op 4444 ns/op 4061 ns/op 1.09
BenchmarkPriorityModel - B/op 1765 B/op 1757 B/op 1.00
BenchmarkPriorityModel - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkRBACModelWithDomainPatternLarge 23026 ns/op 16719 B/op 164 allocs/op 22937 ns/op 16770 B/op 164 allocs/op 1.00
BenchmarkRBACModelWithDomainPatternLarge - ns/op 23026 ns/op 22937 ns/op 1.00
BenchmarkRBACModelWithDomainPatternLarge - B/op 16719 B/op 16770 B/op 1.00
BenchmarkRBACModelWithDomainPatternLarge - allocs/op 164 allocs/op 164 allocs/op 1
BenchmarkRoleManagerSmall 70410 ns/op 11955 B/op 797 allocs/op 68331 ns/op 11955 B/op 797 allocs/op 1.03
BenchmarkRoleManagerSmall - ns/op 70410 ns/op 68331 ns/op 1.03
BenchmarkRoleManagerSmall - B/op 11955 B/op 11955 B/op 1
BenchmarkRoleManagerSmall - allocs/op 797 allocs/op 797 allocs/op 1
BenchmarkRoleManagerMedium 753996 ns/op 125915 B/op 8741 allocs/op 703876 ns/op 125915 B/op 8741 allocs/op 1.07
BenchmarkRoleManagerMedium - ns/op 753996 ns/op 703876 ns/op 1.07
BenchmarkRoleManagerMedium - B/op 125915 B/op 125915 B/op 1
BenchmarkRoleManagerMedium - allocs/op 8741 allocs/op 8741 allocs/op 1
BenchmarkRoleManagerLarge 8171010 ns/op 1349922 B/op 89741 allocs/op 7892084 ns/op 1349929 B/op 89741 allocs/op 1.04
BenchmarkRoleManagerLarge - ns/op 8171010 ns/op 7892084 ns/op 1.04
BenchmarkRoleManagerLarge - B/op 1349922 B/op 1349929 B/op 1.00
BenchmarkRoleManagerLarge - allocs/op 89741 allocs/op 89741 allocs/op 1
BenchmarkBuildRoleLinksWithPatternLarge 6201805485 ns/op 5339397800 B/op 60947734 allocs/op 6148545369 ns/op 5355357800 B/op 60951400 allocs/op 1.01
BenchmarkBuildRoleLinksWithPatternLarge - ns/op 6201805485 ns/op 6148545369 ns/op 1.01
BenchmarkBuildRoleLinksWithPatternLarge - B/op 5339397800 B/op 5355357800 B/op 1.00
BenchmarkBuildRoleLinksWithPatternLarge - allocs/op 60947734 allocs/op 60951400 allocs/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge 173108893 ns/op 141435628 B/op 1676456 allocs/op 167701225 ns/op 141914446 B/op 1676568 allocs/op 1.03
BenchmarkBuildRoleLinksWithDomainPatternLarge - ns/op 173108893 ns/op 167701225 ns/op 1.03
BenchmarkBuildRoleLinksWithDomainPatternLarge - B/op 141435628 B/op 141914446 B/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge - allocs/op 1676456 allocs/op 1676568 allocs/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge 6405295476 ns/op 5480109904 B/op 62558865 allocs/op 6315080386 ns/op 5493508032 B/op 62562142 allocs/op 1.01
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - ns/op 6405295476 ns/op 6315080386 ns/op 1.01
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - B/op 5480109904 B/op 5493508032 B/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - allocs/op 62558865 allocs/op 62562142 allocs/op 1.00
BenchmarkHasLinkWithPatternLarge 10457 ns/op 7604 B/op 111 allocs/op 10446 ns/op 7623 B/op 111 allocs/op 1.00
BenchmarkHasLinkWithPatternLarge - ns/op 10457 ns/op 10446 ns/op 1.00
BenchmarkHasLinkWithPatternLarge - B/op 7604 B/op 7623 B/op 1.00
BenchmarkHasLinkWithPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1
BenchmarkHasLinkWithDomainPatternLarge 495.9 ns/op 80 B/op 5 allocs/op 480.2 ns/op 80 B/op 5 allocs/op 1.03
BenchmarkHasLinkWithDomainPatternLarge - ns/op 495.9 ns/op 480.2 ns/op 1.03
BenchmarkHasLinkWithDomainPatternLarge - B/op 80 B/op 80 B/op 1
BenchmarkHasLinkWithDomainPatternLarge - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkHasLinkWithPatternAndDomainPatternLarge 10642 ns/op 7601 B/op 111 allocs/op 10305 ns/op 7612 B/op 111 allocs/op 1.03
BenchmarkHasLinkWithPatternAndDomainPatternLarge - ns/op 10642 ns/op 10305 ns/op 1.03
BenchmarkHasLinkWithPatternAndDomainPatternLarge - B/op 7601 B/op 7612 B/op 1.00
BenchmarkHasLinkWithPatternAndDomainPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 2858196 Previous: caebc40 Ratio
BenchmarkCachedRBACModel 187.8 ns/op 104 B/op 4 allocs/op 167.5 ns/op 104 B/op 4 allocs/op 1.12
BenchmarkCachedRBACModel - ns/op 187.8 ns/op 167.5 ns/op 1.12
BenchmarkCachedRBACModelLarge 188.5 ns/op 96 B/op 3 allocs/op 166.9 ns/op 96 B/op 3 allocs/op 1.13
BenchmarkCachedRBACModelLarge - ns/op 188.5 ns/op 166.9 ns/op 1.13
BenchmarkCachedWithEnforceContext 323.3 ns/op 240 B/op 5 allocs/op 290.1 ns/op 240 B/op 5 allocs/op 1.11
BenchmarkCachedWithEnforceContext - ns/op 323.3 ns/op 290.1 ns/op 1.11
BenchmarkAddPolicyLarge 1283 ns/op 470 B/op 9 allocs/op 1114 ns/op 470 B/op 9 allocs/op 1.15
BenchmarkAddPolicyLarge - ns/op 1283 ns/op 1114 ns/op 1.15
BenchmarkRBACModelSizes/medium 561865 ns/op 191731 B/op 4828 allocs/op 494964 ns/op 191751 B/op 4828 allocs/op 1.14
BenchmarkRBACModelSizes/medium - ns/op 561865 ns/op 494964 ns/op 1.14
BenchmarkRBACModelSizes/large 6281436 ns/op 1897729 B/op 48112 allocs/op 5269002 ns/op 1906077 B/op 48353 allocs/op 1.19
BenchmarkRBACModelSizes/large - ns/op 6281436 ns/op 5269002 ns/op 1.19
BenchmarkRBACModelWithDomains 5436 ns/op 1827 B/op 25 allocs/op 4936 ns/op 1822 B/op 25 allocs/op 1.10
BenchmarkRBACModelWithDomains - ns/op 5436 ns/op 4936 ns/op 1.10

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.