Skip to content

Commit c5b9514

Browse files
authored
Merge pull request #148 from kzys/revisit-lint
Enable some linters on golangci-lint
2 parents bad0d95 + 2a0cdae commit c5b9514

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

.golangci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
linters-settings:
22
govet:
33
check-shadowing: true
4-
golint:
5-
min-confidence: 0
64
gocyclo:
75
min-complexity: 50
86
maligned:
@@ -42,11 +40,11 @@ linters:
4240
- paralleltest
4341
- cyclop # because we have gocyclo already
4442
# TODO: review the linters below. We disabled them to make the CI pass first.
45-
- gocritic
46-
- revive
47-
- containedctx
4843
- ireturn
4944
- varnamelen
5045
- forcetypeassert
5146
- thelper
52-
- wastedassign
47+
# Disable deprecated linters.
48+
# They will be removed from golangci-lint in future.
49+
- interfacer
50+
- golint

context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
none operationType = "none" // not specified in ctx
2020
)
2121

22-
var operationTypeEnum []operationType = []operationType{request, response, none}
22+
var operationTypeEnum = []operationType{request, response, none}
2323

2424
// WithOperationRequest returns a new context with operationType request
2525
// in context value

context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func TestContext_ExtractOperationType(t *testing.T) {
1212

1313
var testCases = []struct {
14-
Ctx context.Context
14+
Ctx context.Context //nolint: containedctx
1515
ExpectedOpType operationType
1616
}{
1717
{

jsonschema_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ func TestOptionalJSONSchemaSuite(t *testing.T) {
194194

195195
// Further testing with all formats recognized by strfmt
196196
func TestFormat_JSONSchemaExtended(t *testing.T) {
197-
jsonFormatSchemaFixturesPath := filepath.Join(formatFixturesPath)
198-
files, err := ioutil.ReadDir(jsonFormatSchemaFixturesPath)
197+
files, err := ioutil.ReadDir(formatFixturesPath)
199198
if err != nil {
200199
t.Fatal(err)
201200
}
@@ -213,7 +212,7 @@ func TestFormat_JSONSchemaExtended(t *testing.T) {
213212
return
214213
}
215214
t.Log("Running [extended formats] " + specName)
216-
b, _ := ioutil.ReadFile(filepath.Join(jsonFormatSchemaFixturesPath, fileName))
215+
b, _ := ioutil.ReadFile(filepath.Join(formatFixturesPath, fileName))
217216
doTestSchemaSuite(t, b)
218217
})
219218
}

schema_props.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
163163
}
164164

165165
if validated != 1 {
166-
additionalMsg := ""
166+
var additionalMsg string
167167
if validated == 0 {
168168
additionalMsg = "Found none valid"
169169
} else {

values.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func IsValueValidAgainstRange(val interface{}, typeName, format, prefix, path st
394394
kind := reflect.ValueOf(val).Type().Kind()
395395

396396
// What is the string representation of val
397-
stringRep := ""
397+
var stringRep string
398398
switch kind {
399399
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
400400
stringRep = swag.FormatUint64(valueHelp.asUint64(val))

0 commit comments

Comments
 (0)