Skip to content

Commit 1085b8e

Browse files
committed
fix: lit errors
1 parent f332c3a commit 1085b8e

File tree

7 files changed

+89
-67
lines changed

7 files changed

+89
-67
lines changed

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ linters:
3030
disable-all: true
3131
enable:
3232
- unused
33-
- deadcode
3433
- stylecheck
3534
- gosimple
3635
- govet
3736
- errcheck
38-
- deadcode
39-
- structcheck
40-
- varcheck
4137
- ineffassign
4238
- typecheck
4339
- dupl

bik/bik_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ func TestValidate(t *testing.T) {
3535
IsValid: true,
3636
},
3737
}
38-
for i, test := range testCases {
39-
isValid, err := Validate(test.Code)
40-
assert.Equal(t, test.IsValid, isValid, test.Code)
38+
for i, tc := range testCases {
39+
tc := tc
40+
41+
isValid, err := Validate(tc.Code)
42+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
4143
if err != nil {
42-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
44+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4345
} else {
44-
assert.NoError(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
46+
assert.NoError(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4547
}
4648
}
4749
})
@@ -79,13 +81,15 @@ func TestValidate(t *testing.T) {
7981
IsValid: true,
8082
},
8183
}
82-
for i, test := range testCases {
83-
isValid, err := Validate(test.Code)
84-
assert.Equal(t, test.IsValid, isValid, test.Code, test.IsValid)
84+
for i, tc := range testCases {
85+
tc := tc
86+
87+
isValid, err := Validate(tc.Code)
88+
assert.Equal(t, tc.IsValid, isValid, tc.Code, tc.IsValid)
8589
if err != nil {
86-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
90+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8791
} else {
88-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
92+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8993
}
9094
}
9195
})

inn/inn_test.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ func TestValidate(t *testing.T) {
3636
IsValid: true,
3737
},
3838
}
39-
for i, test := range testCases {
40-
isValid, err := Validate(test.Code)
41-
assert.Equal(t, test.IsValid, isValid, test.Code)
39+
for i, tc := range testCases {
40+
tc := tc
41+
42+
isValid, err := Validate(tc.Code)
43+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
4244
if err != nil {
43-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
45+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4446
} else {
45-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
47+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4648
}
4749
}
4850
})
@@ -75,13 +77,15 @@ func TestValidate(t *testing.T) {
7577
IsValid: true,
7678
},
7779
}
78-
for i, test := range testCases {
79-
isValid, err := Validate(test.Code)
80-
assert.Equal(t, test.IsValid, isValid, test.Code)
80+
for i, tc := range testCases {
81+
tc := tc
82+
83+
isValid, err := Validate(tc.Code)
84+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
8185
if err != nil {
82-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
86+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8387
} else {
84-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
88+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8589
}
8690
}
8791
})
@@ -155,10 +159,11 @@ func TestGenerate(t *testing.T) {
155159
}
156160
var digits int64
157161

158-
for _, test := range tests {
159-
digits = ru_doc_code.RandomDigits(test.len)
162+
for _, tc := range tests {
163+
tc := tc
160164

161-
assert.True(t, digits >= test.min && digits <= test.max)
165+
digits = ru_doc_code.RandomDigits(tc.len)
166+
assert.True(t, digits >= tc.min && digits <= tc.max)
162167
}
163168
})
164169
}

kpp/kpp_test.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
ru_doc_code "github.com/sshaplygin/ru-doc-code"
1010
)
1111

12+
//nolint:dupl
1213
func TestValidate(t *testing.T) {
1314
t.Parallel()
1415

@@ -35,13 +36,15 @@ func TestValidate(t *testing.T) {
3536
IsValid: true,
3637
},
3738
}
38-
for i, test := range testCases {
39-
isValid, err := Validate(test.Code)
40-
assert.Equal(t, isValid, test.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
39+
for i, tc := range testCases {
40+
tc := tc
41+
42+
isValid, err := Validate(tc.Code)
43+
assert.Equal(t, isValid, tc.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4144
if err != nil {
42-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
45+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4346
} else {
44-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
47+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4548
}
4649
}
4750
})
@@ -69,13 +72,15 @@ func TestValidate(t *testing.T) {
6972
IsValid: true,
7073
},
7174
}
72-
for i, test := range testCases {
73-
isValid, err := Validate(test.Code)
74-
assert.Equal(t, isValid, test.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
75+
for i, tc := range testCases {
76+
tc := tc
77+
78+
isValid, err := Validate(tc.Code)
79+
assert.Equal(t, isValid, tc.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
7580
if err != nil {
76-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
81+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
7782
} else {
78-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
83+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
7984
}
8085
}
8186
})
@@ -93,13 +98,15 @@ func TestValidate(t *testing.T) {
9398
IsValid: true,
9499
},
95100
}
96-
for i, test := range testCases {
97-
isValid, err := Validate(test.Code)
98-
assert.Equal(t, isValid, test.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
101+
for i, tc := range testCases {
102+
tc := tc
103+
104+
isValid, err := Validate(tc.Code)
105+
assert.Equal(t, isValid, tc.IsValid, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
99106
if err != nil {
100-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
107+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
101108
} else {
102-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
109+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
103110
}
104111
}
105112
})

ogrn/ogrn_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ func TestValidate(t *testing.T) {
3636
IsValid: false,
3737
},
3838
}
39-
for i, test := range testCases {
40-
isValid, err := Validate(test.Code)
41-
assert.Equal(t, test.IsValid, isValid, test.Code)
39+
for i, tc := range testCases {
40+
tc := tc
41+
42+
isValid, err := Validate(tc.Code)
43+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
4244
if err != nil {
43-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
45+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4446
} else {
45-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
47+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4648
}
4749
}
4850
})

ogrnip/ogrnip_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ func TestValidate(t *testing.T) {
3535
IsValid: false,
3636
},
3737
}
38-
for i, test := range testCases {
39-
isValid, err := Validate(test.Code)
40-
assert.Equal(t, test.IsValid, isValid, test.Code)
38+
for i, tc := range testCases {
39+
tc := tc
40+
41+
isValid, err := Validate(tc.Code)
42+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
4143
if err != nil {
42-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
44+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4345
} else {
44-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
46+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4547
}
4648
}
4749
})
@@ -74,13 +76,15 @@ func TestValidate(t *testing.T) {
7476
IsValid: true,
7577
},
7678
}
77-
for i, test := range testCases {
78-
isValid, err := Validate(test.Code)
79-
assert.Equal(t, test.IsValid, isValid, test.Code, test.IsValid)
79+
for i, tc := range testCases {
80+
tc := tc
81+
82+
isValid, err := Validate(tc.Code)
83+
assert.Equal(t, tc.IsValid, isValid, tc.Code, tc.IsValid)
8084
if err != nil {
81-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
85+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8286
} else {
83-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
87+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8488
}
8589
}
8690
})

snils/snils_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ func TestValidate(t *testing.T) {
3535
IsValid: false,
3636
},
3737
}
38-
for i, test := range testCases {
39-
isValid, err := Validate(test.Code)
40-
assert.Equal(t, test.IsValid, isValid, test.Code)
38+
for i, tc := range testCases {
39+
tc := tc
40+
41+
isValid, err := Validate(tc.Code)
42+
assert.Equal(t, tc.IsValid, isValid, tc.Code)
4143
if err != nil {
42-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
44+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4345
} else {
44-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
46+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
4547
}
4648
}
4749
})
@@ -79,13 +81,15 @@ func TestValidate(t *testing.T) {
7981
IsValid: true,
8082
},
8183
}
82-
for i, test := range testCases {
83-
isValid, err := Validate(test.Code)
84-
assert.Equal(t, test.IsValid, isValid, test.Code, test.IsValid)
84+
for i, tc := range testCases {
85+
tc := tc
86+
87+
isValid, err := Validate(tc.Code)
88+
assert.Equal(t, tc.IsValid, isValid, tc.Code, tc.IsValid)
8589
if err != nil {
86-
assert.ErrorAs(t, err, &test.Error, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
90+
assert.ErrorAs(t, err, &tc.Error, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8791
} else {
88-
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, test.Code))
92+
assert.Empty(t, err, fmt.Sprintf("invalid test case %d: input: %s", i, tc.Code))
8993
}
9094
}
9195
})

0 commit comments

Comments
 (0)