-
Notifications
You must be signed in to change notification settings - Fork 85
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
enable gocognit linter #1037
base: master
Are you sure you want to change the base?
enable gocognit linter #1037
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1037 +/- ##
==========================================
+ Coverage 68.48% 68.72% +0.24%
==========================================
Files 252 252
Lines 25155 25420 +265
==========================================
+ Hits 17228 17471 +243
- Misses 7069 7093 +24
+ Partials 858 856 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ith fixies in comments
…h off gocognit linter
…th off gocognit linter
…ests and upload with off gocognit linter
… and upload with off gocognit linter
…cks tests and upload with off gocognit linter
…cks tests and upload with off gocognit linter
I noted one comment //nolint:gocognit, because if I rewrite a function internal/cmd/gtrace.findGtraceGen in |
CHANGELOG.md
Outdated
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
internal/backoff/backoff_test.go
Outdated
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 no need to change test files for enabling gocongnit linter - this is no valuable for doing better source code
Can you add all test files to exclude-rules in .golangci.yaml config?
@@ -171,6 +166,18 @@ func (c call) Record(opts ...recordOption) string { | |||
return buffer.String() | |||
} | |||
|
|||
// findFileNameAndPkgPath finds the file, name and package path from the given file path, name and package path. | |||
func findFileNameAndPkgPath(file, name, pkgPath string) (string, string, string) { |
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.
need to unit test for newest func
internal/table/scanner/scanner.go
Outdated
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.
need to unit tests for newest func
@@ -96,3 +77,30 @@ func extractTablePathPrefixFromBinderName(binderName string) (string, error) { | |||
|
|||
return ss[0][1], nil | |||
} | |||
|
|||
// bindTablePathPrefixInConnectorOptions binds table path prefix query transformers to a list of ConnectorOptions. | |||
func bindTablePathPrefixInConnectorOptions(queryTransformers []string) ([]ConnectorOption, error) { |
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.
queryTransformersToConnectorOptions?
@@ -96,3 +77,30 @@ func extractTablePathPrefixFromBinderName(binderName string) (string, error) { | |||
|
|||
return ss[0][1], nil | |||
} | |||
|
|||
// bindTablePathPrefixInConnectorOptions binds table path prefix query transformers to a list of ConnectorOptions. | |||
func bindTablePathPrefixInConnectorOptions(queryTransformers []string) ([]ConnectorOption, error) { |
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.
need to unit test for newest func
log/driver.go
Outdated
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 file need to stay as is with nolint comment because your simple functions can be clashed in log package.
For example onInit
func may clashed between driver log and table log and other
log/sql.go
Outdated
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 file need to stay as is with nolint comment because your simple functions can be clashed in log package.
For example onInit func may clashed between driver log and table log and other
log/table.go
Outdated
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 file need to stay as is with nolint comment because your simple functions can be clashed in log package.
For example onInit func may clashed between driver log and table log and other
log/topic.go
Outdated
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 file need to stay as is with nolint comment because your simple functions can be clashed in log package.
For example onInit func may clashed between driver log and table log and other
metrics/driver.go
Outdated
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 file need to stay as is with nolint comment because your simple functions can be clashed in log package.
For example onInit func may clashed between driver log and table log and other
// with a panic recovery mechanism. If the `options.panicCallback` is specified, it | ||
// is invoked with the recovered value, and an error is returned with the recovered value wrapped | ||
// as the cause. This function returns the result of the `op` retry operation. | ||
func RecoveryCallbackWrapper(context context.Context, op retryOperation, options *retryOptions) (err error) { |
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.
public func not welcome
internal/cmd/gtrace/main.go
Outdated
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 file need to stay as is with nolint comment because findGtraceGen also commented with nolint word
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Need to test for newest func
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
appendParams or tryAppendParams?
@@ -266,6 +241,57 @@ func Format(x *big.Int, precision, scale uint32) string { | |||
return xstring.FromBytes(bts[pos:]) | |||
} | |||
|
|||
// dotStringAnalysis performs analysis on a string representation of a decimal number. | |||
func dotStringAnalysis( |
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.
toBigInt or stringToBigInt?
@@ -266,6 +241,57 @@ func Format(x *big.Int, precision, scale uint32) string { | |||
return xstring.FromBytes(bts[pos:]) | |||
} | |||
|
|||
// dotStringAnalysis performs analysis on a string representation of a decimal number. | |||
func dotStringAnalysis( |
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.
need to add unit test for newest func
} | ||
|
||
// multipliedByTen multiplies the given big.Int value by 10 raised to the power of scale. | ||
func multipliedByTen(v *big.Int, scale uint32, neg bool) { |
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.
need to add unit test for newest func
|
||
if timeout := c.config.DeleteTimeout(); timeout > 0 { | ||
var cancel context.CancelFunc | ||
createSessionCtx, cancel = xcontext.WithTimeout(closeSessionCtx, timeout) |
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.
createSessionCtx is not used
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.
May be a bug in base version of code
@@ -223,6 +209,25 @@ func (c *Client) createSession(ctx context.Context, opts ...createSessionOption) | |||
} | |||
} | |||
|
|||
// onCloseSession is a closure function that takes a session and performs the actions to close it. | |||
func onCloseSession(ctx, createSessionCtx context.Context, c *Client) func(s *session) { |
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.
createSessionCtx
and c
are not used
@@ -223,6 +209,25 @@ func (c *Client) createSession(ctx context.Context, opts ...createSessionOption) | |||
} | |||
} | |||
|
|||
// onCloseSession is a closure function that takes a session and performs the actions to close it. | |||
func onCloseSession(ctx, createSessionCtx context.Context, c *Client) func(s *session) { |
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 ctx
need to move from source args to result
And your high-ordered func may looks like:
func closerWithTimeout(timeout time.Duration) func(ctx context.Context, closer closer.Closer) {
return func(ctx context.Context, s *session) {
if closer == nil {
return
}
ctx = xcontext.WithoutDeadline(ctx)
var cancel context.CancelFunc
if timeout > 0 {
ctx, cancel = xcontext.WithTimeout(ctx, timeout)
} else {
ctx, cancel = xcontext.WithCancel(ctx)
}
defer cancel()
_ = closer.Close(ctx)
}
}
And this func can be tested with unit test
Summary of review:
|
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #938
What is the new behavior?
Other information
First I load the files with the linter turned off to check the ci tests.
I have the linter enabled locally and with the last commit I enabled the linter in the remote repository.