Skip to content

Commit 9dde080

Browse files
authored
chore: fix lint (#531)
1 parent cf8b50b commit 9dde080

21 files changed

Lines changed: 61 additions & 5 deletions

.golangci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ linters:
1313
- mnd
1414
- testpackage
1515
- usetesting
16+
- noinlineerr
17+
- wsl
1618
settings:
1719
depguard:
1820
rules:
@@ -63,6 +65,10 @@ linters:
6365
rules:
6466
json: snake
6567
use-field-name: true
68+
wsl_v5:
69+
allow-first-in-block: true
70+
allow-whole-block: false
71+
branch-max-lines: 2
6672
exclusions:
6773
generated: lax
6874
presets:

cmd/model/get_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestGetModelNoAuthModelID(t *testing.T) {
2222

2323
mockCtrl := gomock.NewController(t)
2424
defer mockCtrl.Finish()
25+
2526
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
2627

2728
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)
@@ -56,6 +57,7 @@ func TestGetModelAuthModelID(t *testing.T) {
5657

5758
mockCtrl := gomock.NewController(t)
5859
defer mockCtrl.Finish()
60+
5961
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
6062

6163
mockExecute := mock_client.NewMockSdkClientReadAuthorizationModelRequestInterface(mockCtrl)
@@ -94,6 +96,7 @@ func TestGetModelNoAuthModelIDError(t *testing.T) {
9496

9597
mockCtrl := gomock.NewController(t)
9698
defer mockCtrl.Finish()
99+
97100
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
98101

99102
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)

cmd/model/list_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestListModelsEmpty(t *testing.T) {
2121

2222
mockCtrl := gomock.NewController(t)
2323
defer mockCtrl.Finish()
24+
2425
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
2526

2627
mockExecute := mockclient.NewMockSdkClientReadAuthorizationModelsRequestInterface(mockCtrl)
@@ -62,6 +63,7 @@ func TestListModelsFail(t *testing.T) {
6263

6364
mockCtrl := gomock.NewController(t)
6465
defer mockCtrl.Finish()
66+
6567
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
6668

6769
mockExecute := mockclient.NewMockSdkClientReadAuthorizationModelsRequestInterface(mockCtrl)
@@ -86,6 +88,7 @@ func TestListModelsSinglePage(t *testing.T) {
8688

8789
mockCtrl := gomock.NewController(t)
8890
defer mockCtrl.Finish()
91+
8992
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
9093

9194
mockExecute := mockclient.NewMockSdkClientReadAuthorizationModelsRequestInterface(mockCtrl)
@@ -134,6 +137,7 @@ func TestListModelsMultiPage(t *testing.T) {
134137

135138
mockCtrl := gomock.NewController(t)
136139
defer mockCtrl.Finish()
140+
137141
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
138142

139143
mockExecute1 := mockclient.NewMockSdkClientReadAuthorizationModelsRequestInterface(mockCtrl)
@@ -216,6 +220,7 @@ func TestListModelsMultiPageMaxPage(t *testing.T) {
216220

217221
mockCtrl := gomock.NewController(t)
218222
defer mockCtrl.Finish()
223+
219224
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
220225

221226
mockExecute1 := mockclient.NewMockSdkClientReadAuthorizationModelsRequestInterface(mockCtrl)

cmd/model/write_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestWriteModelFail(t *testing.T) {
1919

2020
mockCtrl := gomock.NewController(t)
2121
defer mockCtrl.Finish()
22+
2223
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
2324

2425
modelJSONTxt := `{"schema_version":"1.1","type_definitions":[{"relations":{"viewer":{"this":{}}},"type":"github-repo"}],"conditions":{}}`
@@ -55,6 +56,7 @@ func TestWriteModel(t *testing.T) {
5556

5657
mockCtrl := gomock.NewController(t)
5758
defer mockCtrl.Finish()
59+
5860
mockFgaClient := mockclient.NewMockSdkClient(mockCtrl)
5961

6062
modelJSONTxt := `{"schema_version":"1.1","type_definitions":[{"relations":{"viewer":{"this":{}}},"type":"github-repo"}],"conditions":{}}`

cmd/query/check_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestCheckWithError(t *testing.T) {
1818

1919
mockCtrl := gomock.NewController(t)
2020
defer mockCtrl.Finish()
21+
2122
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
2223

2324
mockExecute := mock_client.NewMockSdkClientCheckRequestInterface(mockCtrl)
@@ -66,6 +67,7 @@ func TestCheckWithNoError(t *testing.T) {
6667

6768
mockCtrl := gomock.NewController(t)
6869
defer mockCtrl.Finish()
70+
6971
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
7072

7173
mockExecute := mock_client.NewMockSdkClientCheckRequestInterface(mockCtrl)
@@ -123,6 +125,7 @@ func TestCheckWithConsistency(t *testing.T) {
123125

124126
mockCtrl := gomock.NewController(t)
125127
defer mockCtrl.Finish()
128+
126129
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
127130

128131
mockExecute := mock_client.NewMockSdkClientCheckRequestInterface(mockCtrl)

cmd/query/expand_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestExpandWithError(t *testing.T) {
2020

2121
mockCtrl := gomock.NewController(t)
2222
defer mockCtrl.Finish()
23+
2324
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
2425

2526
mockExecute := mock_client.NewMockSdkClientExpandRequestInterface(mockCtrl)
@@ -53,6 +54,7 @@ func TestExpandWithNoError(t *testing.T) {
5354

5455
mockCtrl := gomock.NewController(t)
5556
defer mockCtrl.Finish()
57+
5658
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
5759

5860
mockExecute := mock_client.NewMockSdkClientExpandRequestInterface(mockCtrl)
@@ -95,6 +97,7 @@ func TestExpandWithConsistency(t *testing.T) {
9597

9698
mockCtrl := gomock.NewController(t)
9799
defer mockCtrl.Finish()
100+
98101
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
99102

100103
mockExecute := mock_client.NewMockSdkClientExpandRequestInterface(mockCtrl)

cmd/query/list-objects_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestListObjectsWithError(t *testing.T) {
1818

1919
mockCtrl := gomock.NewController(t)
2020
defer mockCtrl.Finish()
21+
2122
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
2223

2324
mockExecute := mock_client.NewMockSdkClientListObjectsRequestInterface(mockCtrl)
@@ -66,6 +67,7 @@ func TestListObjectsWithNoError(t *testing.T) {
6667

6768
mockCtrl := gomock.NewController(t)
6869
defer mockCtrl.Finish()
70+
6971
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
7072

7173
mockExecute := mock_client.NewMockSdkClientListObjectsRequestInterface(mockCtrl)
@@ -119,6 +121,7 @@ func TestListObjectsWithConsistency(t *testing.T) {
119121

120122
mockCtrl := gomock.NewController(t)
121123
defer mockCtrl.Finish()
124+
122125
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
123126

124127
mockExecute := mock_client.NewMockSdkClientListObjectsRequestInterface(mockCtrl)

cmd/query/list-relations_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func TestListRelationsLatestAuthModelError(t *testing.T) {
2626

2727
mockCtrl := gomock.NewController(t)
2828
defer mockCtrl.Finish()
29+
2930
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
3031

3132
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)
@@ -41,6 +42,7 @@ func TestListRelationsLatestAuthModelError(t *testing.T) {
4142
contextualTuples := []client.ClientContextualTupleKey{
4243
{User: "user:foo", Relation: "admin", Object: "doc:doc1"},
4344
}
45+
4446
_, err := listRelations(
4547
t.Context(),
4648
clientConfig,
@@ -52,7 +54,6 @@ func TestListRelationsLatestAuthModelError(t *testing.T) {
5254
queryContext,
5355
openfga.CONSISTENCYPREFERENCE_UNSPECIFIED.Ptr(),
5456
)
55-
5657
if err == nil {
5758
t.Error("Expect error but there is none")
5859
}
@@ -63,6 +64,7 @@ func TestListRelationsAuthModelSpecifiedError(t *testing.T) {
6364

6465
mockCtrl := gomock.NewController(t)
6566
defer mockCtrl.Finish()
67+
6668
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
6769

6870
mockExecute := mock_client.NewMockSdkClientReadAuthorizationModelRequestInterface(mockCtrl)
@@ -80,6 +82,7 @@ func TestListRelationsAuthModelSpecifiedError(t *testing.T) {
8082
contextualTuples := []client.ClientContextualTupleKey{
8183
{User: "user:foo", Relation: "admin", Object: "doc:doc1"},
8284
}
85+
8386
_, err := listRelations(
8487
t.Context(),
8588
clientConfig,
@@ -91,7 +94,6 @@ func TestListRelationsAuthModelSpecifiedError(t *testing.T) {
9194
queryContext,
9295
openfga.CONSISTENCYPREFERENCE_UNSPECIFIED.Ptr(),
9396
)
94-
9597
if err == nil {
9698
t.Error("Expect error but there is none")
9799
}
@@ -102,6 +104,7 @@ func TestListRelationsLatestAuthModelListError(t *testing.T) {
102104

103105
mockCtrl := gomock.NewController(t)
104106
defer mockCtrl.Finish()
107+
105108
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
106109

107110
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)
@@ -169,6 +172,7 @@ func TestListRelationsLatestAuthModelEmpty(t *testing.T) {
169172

170173
mockCtrl := gomock.NewController(t)
171174
defer mockCtrl.Finish()
175+
172176
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
173177

174178
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)
@@ -219,6 +223,7 @@ func TestListRelationsLatestAuthModelList(t *testing.T) {
219223

220224
mockCtrl := gomock.NewController(t)
221225
defer mockCtrl.Finish()
226+
222227
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
223228

224229
mockExecute := mock_client.NewMockSdkClientReadLatestAuthorizationModelRequestInterface(mockCtrl)
@@ -292,6 +297,7 @@ func TestListRelationsMultipleRelations(t *testing.T) {
292297

293298
mockCtrl := gomock.NewController(t)
294299
defer mockCtrl.Finish()
300+
295301
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
296302

297303
// after reading the latest auth model, expect to call list relations but failure
@@ -353,6 +359,7 @@ func TestListRelationsWithConsistency(t *testing.T) {
353359

354360
mockCtrl := gomock.NewController(t)
355361
defer mockCtrl.Finish()
362+
356363
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
357364

358365
mockListRelationsExecute := mock_client.NewMockSdkClientListRelationsRequestInterface(mockCtrl)

cmd/query/list-users_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func TestListUsersSimpleType(t *testing.T) {
1515

1616
mockCtrl := gomock.NewController(t)
1717
defer mockCtrl.Finish()
18+
1819
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
1920

2021
mockExecute := mock_client.NewMockSdkClientListUsersRequestInterface(mockCtrl)
@@ -83,6 +84,7 @@ func TestListUsersSimpleTypeAndRelation(t *testing.T) {
8384

8485
mockCtrl := gomock.NewController(t)
8586
defer mockCtrl.Finish()
87+
8688
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
8789

8890
mockExecute := mock_client.NewMockSdkClientListUsersRequestInterface(mockCtrl)
@@ -152,6 +154,7 @@ func TestListUsersWithConsistency(t *testing.T) {
152154

153155
mockCtrl := gomock.NewController(t)
154156
defer mockCtrl.Finish()
157+
155158
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
156159

157160
mockExecute := mock_client.NewMockSdkClientListUsersRequestInterface(mockCtrl)

cmd/store/create_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestCreateError(t *testing.T) {
1818

1919
mockCtrl := gomock.NewController(t)
2020
defer mockCtrl.Finish()
21+
2122
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
2223

2324
mockExecute := mock_client.NewMockSdkClientCreateStoreRequestInterface(mockCtrl)
@@ -46,6 +47,7 @@ func TestCreateSuccess(t *testing.T) {
4647

4748
mockCtrl := gomock.NewController(t)
4849
defer mockCtrl.Finish()
50+
4951
mockFgaClient := mock_client.NewMockSdkClient(mockCtrl)
5052

5153
mockExecute := mock_client.NewMockSdkClientCreateStoreRequestInterface(mockCtrl)

0 commit comments

Comments
 (0)