Skip to content

Commit

Permalink
Merge pull request #148 from kzys/revisit-lint
Browse files Browse the repository at this point in the history
Enable some linters on golangci-lint
  • Loading branch information
youyuanwu committed Feb 16, 2022
2 parents bad0d95 + 2a0cdae commit c5b9514
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
10 changes: 4 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 50
maligned:
Expand Down Expand Up @@ -42,11 +40,11 @@ linters:
- paralleltest
- cyclop # because we have gocyclo already
# TODO: review the linters below. We disabled them to make the CI pass first.
- gocritic
- revive
- containedctx
- ireturn
- varnamelen
- forcetypeassert
- thelper
- wastedassign
# Disable deprecated linters.
# They will be removed from golangci-lint in future.
- interfacer
- golint
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
none operationType = "none" // not specified in ctx
)

var operationTypeEnum []operationType = []operationType{request, response, none}
var operationTypeEnum = []operationType{request, response, none}

// WithOperationRequest returns a new context with operationType request
// in context value
Expand Down
2 changes: 1 addition & 1 deletion context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func TestContext_ExtractOperationType(t *testing.T) {

var testCases = []struct {
Ctx context.Context
Ctx context.Context //nolint: containedctx
ExpectedOpType operationType
}{
{
Expand Down
5 changes: 2 additions & 3 deletions jsonschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ func TestOptionalJSONSchemaSuite(t *testing.T) {

// Further testing with all formats recognized by strfmt
func TestFormat_JSONSchemaExtended(t *testing.T) {
jsonFormatSchemaFixturesPath := filepath.Join(formatFixturesPath)
files, err := ioutil.ReadDir(jsonFormatSchemaFixturesPath)
files, err := ioutil.ReadDir(formatFixturesPath)
if err != nil {
t.Fatal(err)
}
Expand All @@ -213,7 +212,7 @@ func TestFormat_JSONSchemaExtended(t *testing.T) {
return
}
t.Log("Running [extended formats] " + specName)
b, _ := ioutil.ReadFile(filepath.Join(jsonFormatSchemaFixturesPath, fileName))
b, _ := ioutil.ReadFile(filepath.Join(formatFixturesPath, fileName))
doTestSchemaSuite(t, b)
})
}
Expand Down
2 changes: 1 addition & 1 deletion schema_props.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
}

if validated != 1 {
additionalMsg := ""
var additionalMsg string
if validated == 0 {
additionalMsg = "Found none valid"
} else {
Expand Down
2 changes: 1 addition & 1 deletion values.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func IsValueValidAgainstRange(val interface{}, typeName, format, prefix, path st
kind := reflect.ValueOf(val).Type().Kind()

// What is the string representation of val
stringRep := ""
var stringRep string
switch kind {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
stringRep = swag.FormatUint64(valueHelp.asUint64(val))
Expand Down

0 comments on commit c5b9514

Please sign in to comment.