-
Notifications
You must be signed in to change notification settings - Fork 95
enable gocognit linter #1037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
enable gocognit linter #1037
Changes from 34 commits
e39fb38
a33374f
90dd596
3047f3f
f203aa4
b5dcd3c
efc29c9
c6ef237
9d5e827
3343652
2ba5042
3d56192
7386724
50d2eae
1edb132
5ce51c4
a2bf458
14394d5
c97da45
4765323
a3735b0
e06bc0e
12265dc
0ed37d8
3108b41
e7b2d6c
ec004e4
84d7f17
c7cb479
3053edb
0b86a1c
e81deb1
bd278ba
57a84ee
d81f128
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,6 @@ linters: | |
- forcetypeassert | ||
- funlen | ||
- gochecknoglobals | ||
- gocognit | ||
- godot | ||
- goerr113 | ||
- golint | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think no need to change test files for enabling gocongnit linter - this is no valuable for doing better source code |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,32 +179,11 @@ func Params(args ...interface{}) (params []table.ParameterOption, _ error) { | |
for i, arg := range args { | ||
switch x := arg.(type) { | ||
case driver.NamedValue: | ||
if x.Name == "" { | ||
switch xx := x.Value.(type) { | ||
case *table.QueryParameters: | ||
if len(args) > 1 { | ||
return nil, xerrors.WithStackTrace(errMultipleQueryParameters) | ||
} | ||
xx.Each(func(name string, v types.Value) { | ||
params = append(params, table.ValueParam(name, v)) | ||
}) | ||
case table.ParameterOption: | ||
params = append(params, xx) | ||
default: | ||
x.Name = fmt.Sprintf("$p%d", i) | ||
param, err := toYdbParam(x.Name, x.Value) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
params = append(params, param) | ||
} | ||
} else { | ||
param, err := toYdbParam(x.Name, x.Value) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
params = append(params, param) | ||
driverNamedParams, err := checkDriverNamedValue(i, params, x, args) | ||
if err != nil { | ||
return nil, err | ||
} | ||
params = driverNamedParams | ||
case sql.NamedArg: | ||
if x.Name == "" { | ||
return nil, xerrors.WithStackTrace(errUnnamedParam) | ||
|
@@ -237,3 +216,40 @@ func Params(args ...interface{}) (params []table.ParameterOption, _ error) { | |
|
||
return params, nil | ||
} | ||
|
||
// checkDriverNamedValue checks the driver.NamedValue and adds it to the params slice. | ||
func checkDriverNamedValue( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to test for newest func There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. appendParams or tryAppendParams? |
||
i int, | ||
params []table.ParameterOption, | ||
x driver.NamedValue, | ||
args []interface{}, | ||
) ([]table.ParameterOption, error) { | ||
if x.Name == "" { | ||
switch xx := x.Value.(type) { | ||
case *table.QueryParameters: | ||
if len(args) > 1 { | ||
return nil, xerrors.WithStackTrace(errMultipleQueryParameters) | ||
} | ||
xx.Each(func(name string, v types.Value) { | ||
params = append(params, table.ValueParam(name, v)) | ||
}) | ||
case table.ParameterOption: | ||
params = append(params, xx) | ||
default: | ||
x.Name = fmt.Sprintf("$p%d", i) | ||
param, err := toYdbParam(x.Name, x.Value) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
params = append(params, param) | ||
} | ||
} else { | ||
param, err := toYdbParam(x.Name, x.Value) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
params = append(params, param) | ||
} | ||
|
||
return params, nil | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this file need to stay as is with nolint comment because findGtraceGen also commented with nolint word |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this refactorings not valuable for users. Thats why no need to add lines to CHANGELOG