Skip to content
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

feat:add more linter in configuration file #686

Merged
merged 9 commits into from
Dec 12, 2024

Conversation

No-SilverBullet
Copy link
Contributor

What this PR does:
add more linter in configuration file

Which issue(s) this PR fixes:

Fixes #
#479

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@@ -144,7 +144,9 @@ func (m *mysqlTrigger) getColumnMetas(ctx context.Context, dbName string, table
columnMeta.Autoincrement = strings.Contains(strings.ToLower(extra), "auto_increment")
columnMetas = append(columnMetas, columnMeta)
}

if err := rows.Err(); err != nil {
return nil, err
Copy link
Contributor Author

@No-SilverBullet No-SilverBullet Nov 10, 2024

Choose a reason for hiding this comment

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

image based on the description above, i think this is a potential bug, so added the error handle.

@@ -156,7 +156,7 @@ func isRegisterSuccess(response interface{}) bool {
func isReportSuccess(response interface{}) error {
if res, ok := response.(message.BranchReportResponse); ok {
if res.ResultCode == message.ResultCodeFailed {
return fmt.Errorf(res.Msg)
return errors.New(res.Msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为啥改动?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里为啥改动?

ci的go-linter加了一下errcheck,这里过不了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

参考这个,golang/lint#284

@@ -144,7 +144,9 @@ func (m *mysqlTrigger) getColumnMetas(ctx context.Context, dbName string, table
columnMeta.Autoincrement = strings.Contains(strings.ToLower(extra), "auto_increment")
columnMetas = append(columnMetas, columnMeta)
}

if err := rows.Err(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

如果要加,应该加载 103 行之前,使用 rows 之前进行判断

Copy link
Contributor Author

Choose a reason for hiding this comment

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

如果要加,应该加载 103 行之前,使用 rows 之前进行判断

就是在之后加,Next的描述为,Next prepares the next result row for reading with the [Rows.Scan] method. It returns true on success, or false if there is no next result row or an error happened while preparing it. [Rows.Err] should be consulted to distinguish between the two cases.读取过程中出现error也会导致循环退出,所以需要把可能存在的error读出来,参考这个https://stackoverflow.com/questions/67434205/how-does-the-rows-err-of-database-sql-work

@@ -204,6 +206,8 @@ func (m *mysqlTrigger) getIndexes(ctx context.Context, dbName string, tableName
result = append(result, index)

}

if err := rows.Err(); err != nil {
Copy link
Contributor

@luky116 luky116 Nov 13, 2024

Choose a reason for hiding this comment

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

这里放到 174 行之前是否更好

Copy link
Contributor Author

Choose a reason for hiding this comment

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

就是在之后加,Next的描述为,Next prepares the next result row for reading with the [Rows.Scan] method. It returns true on success, or false if there is no next result row or an error happened while preparing it. [Rows.Err] should be consulted to distinguish between the two cases.读取过程中出现error也会导致循环退出,所以需要把可能存在的error读出来,参考这个https://stackoverflow.com/questions/67434205/how-does-the-rows-err-of-database-sql-work

@luky116 luky116 removed the coding label Nov 23, 2024
Copy link

sonarqubecloud bot commented Dec 7, 2024

@luky116
Copy link
Contributor

luky116 commented Dec 12, 2024

LGTM

@luky116 luky116 merged commit 3188ecf into apache:master Dec 12, 2024
7 checks passed
@slievrly slievrly added this to the 2.0.0 milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants