Skip to content

Conversation

@grishagavrin
Copy link
Contributor

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:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

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.

@codecov-commenter
Copy link

codecov-commenter commented Feb 8, 2024

Codecov Report

Attention: 230 lines in your changes are missing coverage. Please review.

Comparison is base (c6e45cd) 68.48% compared to head (57a84ee) 68.72%.

Files Patch % Lines
internal/table/scanner/scanner.go 41.56% 87 Missing and 10 partials ⚠️
internal/decimal/decimal.go 0.00% 35 Missing ⚠️
log/table.go 83.65% 29 Missing and 5 partials ⚠️
sugar/path.go 43.24% 17 Missing and 4 partials ⚠️
log/sql.go 76.47% 8 Missing and 4 partials ⚠️
internal/xsql/dsn.go 66.66% 6 Missing and 2 partials ⚠️
retry/retry.go 27.27% 7 Missing and 1 partial ⚠️
internal/bind/params.go 80.00% 4 Missing and 2 partials ⚠️
internal/table/client.go 78.57% 2 Missing and 1 partial ⚠️
log/topic.go 97.18% 0 Missing and 2 partials ⚠️
... and 2 more
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     
Flag Coverage Δ
55.48% <60.96%> (+0.29%) ⬆️
go-1.20.x 68.57% <70.84%> (+0.30%) ⬆️
go-1.21.x 68.67% <70.84%> (+0.21%) ⬆️
integration 55.48% <60.96%> (+0.29%) ⬆️
macOS 38.34% <15.71%> (-0.32%) ⬇️
ubuntu 38.38% <15.71%> (-0.30%) ⬇️
unit 38.44% <15.71%> (-0.30%) ⬇️
windows 38.38% <15.71%> (-0.34%) ⬇️
ydb-22.5 55.00% <60.96%> (+0.17%) ⬆️
ydb-23.1 54.98% <59.31%> (+0.04%) ⬆️
ydb-23.2 55.16% <60.96%> (+0.34%) ⬆️
ydb-23.3 55.22% <59.31%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@grishagavrin
Copy link
Contributor Author

grishagavrin commented Feb 10, 2024

I noted one comment //nolint:gocognit, because if I rewrite a function internal/cmd/gtrace.findGtraceGen in
for _, c := range v.List { if strings.Contains(strings.TrimPrefix(c.Text, "//"), "gtrace:gen") { if item == nil { item = &GenItem{} } } } the autotest breaks either tests / unit (1.21.x, windows)

@asmyasnikov asmyasnikov self-assigned this Feb 19, 2024
Copy link
Member

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

Copy link
Member

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?

}

// 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) {
Copy link
Member

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

Copy link
Member

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

}

// bindTablePathPrefixInConnectorOptions binds table path prefix query transformers to a list of ConnectorOptions.
func bindTablePathPrefixInConnectorOptions(queryTransformers []string) ([]ConnectorOption, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queryTransformersToConnectorOptions?

}

// bindTablePathPrefixInConnectorOptions binds table path prefix query transformers to a list of ConnectorOptions.
func bindTablePathPrefixInConnectorOptions(queryTransformers []string) ([]ConnectorOption, error) {
Copy link
Member

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

Copy link
Member

@asmyasnikov asmyasnikov Mar 7, 2024

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

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public func not welcome

Copy link
Member

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

}

// checkDriverNamedValue checks the driver.NamedValue and adds it to the params slice.
func checkDriverNamedValue(
Copy link
Member

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

}

// checkDriverNamedValue checks the driver.NamedValue and adds it to the params slice.
func checkDriverNamedValue(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appendParams or tryAppendParams?

}

// dotStringAnalysis performs analysis on a string representation of a decimal number.
func dotStringAnalysis(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toBigInt or stringToBigInt?

}

// dotStringAnalysis performs analysis on a string representation of a decimal number.
func dotStringAnalysis(
Copy link
Member

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) {
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createSessionCtx is not used

Copy link
Member

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

}

// 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) {
Copy link
Member

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

}

// 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) {
Copy link
Member

@asmyasnikov asmyasnikov Mar 7, 2024

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

@asmyasnikov
Copy link
Member

Summary of review:

  1. Need to rebase to master
  2. Need to add exclude-rules into .golangci.yaml config for:
    • all tests
    • packages log and metrics
  3. Need to add unit tests for newest funcs
  4. Minor issues see in full review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants