Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75ed8ef

Browse files
committed
Linting
1 parent 5698938 commit 75ed8ef

17 files changed

+59
-29
lines changed

coderd/authz/authz.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ func Authorize(subj Subject, obj Resource, action Action) error {
77
}
88

99
// AuthorizePermissions runs the authorize function with the raw permissions in a single list.
10-
func AuthorizePermissions(subjID string, permissions []Permission, object Resource, action Action) error {
11-
10+
func AuthorizePermissions(_ string, _ []Permission, _ Resource, _ Action) error {
1211
return nil
1312
}

coderd/authz/authz_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ func Test_ExhaustiveAuthorize(t *testing.T) {
7979
// Result: func(pv string) bool {
8080
// return strings.Contains(pv, "+")
8181
// },
82-
//},
82+
// },
8383
}
8484

8585
var failedTests int
86+
//nolint:paralleltest
8687
for _, c := range testCases {
8788
t.Run(c.Name, func(t *testing.T) {
8889
for _, o := range c.Objs {
@@ -106,7 +107,7 @@ func Test_ExhaustiveAuthorize(t *testing.T) {
106107
})
107108
}
108109
// TODO: @emyrk when we implement the correct authorize, we can enable this check.
109-
//require.Equal(t, 0, failedTests, fmt.Sprintf("%d tests failed", failedTests))
110+
// require.Equal(t, 0, failedTests, fmt.Sprintf("%d tests failed", failedTests))
110111
}
111112

112113
func permissionVariants(all authztest.SetGroup) map[string]*authztest.Role {
@@ -248,7 +249,8 @@ func noise(f noiseBits, lvls ...authztest.LevelGroup) *authztest.Role {
248249
}
249250

250251
if len(rs) == 1 {
251-
return rs[0].(*authztest.Role)
252+
role, _ := rs[0].(*authztest.Role)
253+
return role
252254
}
253255
return authztest.NewRole(rs...)
254256
}

coderd/authz/authztest/iterator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type unionIterator struct {
3232
N int
3333
}
3434

35+
//nolint:revive
3536
func Union(sets ...Set) *unionIterator {
3637
var n int
3738
for _, s := range sets {
@@ -68,7 +69,7 @@ func (si *unionIterator) Reset() {
6869
si.offset = 0
6970
}
7071

71-
func (si *unionIterator) ReturnSize() int {
72+
func (unionIterator) ReturnSize() int {
7273
return 1
7374
}
7475

coderd/authz/authztest/iterator_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package authztest_test
33
import (
44
"testing"
55

6+
"github.com/google/uuid"
7+
"github.com/stretchr/testify/require"
8+
69
"github.com/coder/coder/coderd/authz"
710
"github.com/coder/coder/coderd/authz/authztest"
811
crand "github.com/coder/coder/cryptorand"
9-
"github.com/google/uuid"
10-
"github.com/stretchr/testify/require"
1112
)
1213

1314
func TestUnion(t *testing.T) {

coderd/authz/authztest/level.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (lg LevelGroup) All() Set {
2525
var i int
2626
i += copy(all[i:], pos)
2727
i += copy(all[i:], neg)
28-
i += copy(all[i:], net)
28+
copy(all[i:], net)
2929
return all
3030
}
3131

coderd/authz/authztest/level_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package authztest_test
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/require"
7+
68
"github.com/coder/coder/coderd/authz"
79
"github.com/coder/coder/coderd/authz/authztest"
8-
"github.com/stretchr/testify/require"
910
)
1011

1112
func Test_GroupedPermissions(t *testing.T) {
@@ -81,7 +82,9 @@ func Test_GroupedPermissions(t *testing.T) {
8182
}
8283

8384
for _, c := range cases {
85+
c := c
8486
t.Run(c.Name, func(t *testing.T) {
87+
t.Parallel()
8588
require.Equal(t, c.ExpPos+c.ExpNeg+c.ExpAbs, len(c.Lvl.All()), "set size")
8689
require.Equal(t, c.ExpPos, len(c.Lvl.Positive()), "correct num pos")
8790
require.Equal(t, c.ExpNeg, len(c.Lvl.Negative()), "correct num neg")

coderd/authz/authztest/permissions_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package authztest_test
33
import (
44
"testing"
55

6-
"github.com/coder/coder/coderd/authz/authztest"
76
"github.com/stretchr/testify/require"
7+
8+
"github.com/coder/coder/coderd/authz/authztest"
89
)
910

1011
func Test_AllPermissions(t *testing.T) {

coderd/authz/authztest/role.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Role struct {
2121
func NewRole(sets ...Iterable) *Role {
2222
setInterfaces := make([]Iterator, 0, len(sets))
2323
var retSize int
24-
var size int = 1
24+
size := 1
2525
for _, s := range sets {
2626
v := s.Iterator()
2727
setInterfaces = append(setInterfaces, v)
@@ -71,11 +71,11 @@ func (r *Role) Next() bool {
7171
for i := range r.PermissionSets {
7272
if r.PermissionSets[i].Next() {
7373
break
74-
} else {
75-
r.PermissionSets[i].Reset()
76-
if i == len(r.PermissionSets)-1 {
77-
return false
78-
}
74+
}
75+
76+
r.PermissionSets[i].Reset()
77+
if i == len(r.PermissionSets)-1 {
78+
return false
7979
}
8080
}
8181
return true

coderd/authz/authztest/role_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ package authztest_test
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/require"
7+
68
"github.com/coder/coder/coderd/authz/authztest"
79
crand "github.com/coder/coder/cryptorand"
8-
"github.com/stretchr/testify/require"
910
)
1011

1112
func Test_NewRole(t *testing.T) {
13+
t.Parallel()
14+
1215
for i := 0; i < 50; i++ {
1316
sets := make([]authztest.Iterable, 1+(i%4))
14-
var total int = 1
17+
total := 1
1518
for j := range sets {
1619
size := 1 + must(crand.Intn(3))
1720
if i < 5 {

coderd/authz/authztest/set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func (s Set) String() string {
3333
if v == nil {
3434
continue
3535
}
36-
str.WriteString(sep)
37-
str.WriteString(v.String())
36+
_, _ = str.WriteString(sep)
37+
_, _ = str.WriteString(v.String())
3838
sep = ", "
3939
}
4040
return str.String()

0 commit comments

Comments
 (0)