-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Update golangci-lint to v2.6.0 #35801
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: main
Are you sure you want to change the base?
Conversation
|
I think I will revert these string builder changes and disable the offending rule, it seems useless. |
|
The It says "This avoids quadratic memory allocation and improves performance." so maybe it is worth it. I will fix those var names. |
|
I manually cleaned up the stringsbuilder cases, should be ready. |
| } | ||
| text += fmt.Sprintf("[%s](%s) %s", commit.ID[:7], commit.URL, | ||
| strings.TrimRight(commit.Message, "\r\n")) + authorName | ||
| textSb.WriteString(fmt.Sprintf("[%s](%s) %s", commit.ID[:7], commit.URL, |
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.
fmt.Fprintf should be better.
| message = fmt.Sprintf("%.47s...", message) | ||
| } | ||
| text += fmt.Sprintf("[%s](%s) %s - %s", commit.ID[:7], commit.URL, message, commit.Author.Name) | ||
| textSb.WriteString(fmt.Sprintf("[%s](%s) %s - %s", commit.ID[:7], commit.URL, message, commit.Author.Name)) |
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.
As above
|
|
||
| text := fmt.Sprintf("[%s:%s] %s\r\n", p.Repo.FullName, branchName, commitDesc) | ||
| var textSb strings.Builder | ||
| textSb.WriteString(fmt.Sprintf("[%s:%s] %s\r\n", p.Repo.FullName, branchName, commitDesc)) |
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.
As above
| } | ||
| text += fmt.Sprintf("[%s](%s) %s", commit.ID[:7], commit.URL, | ||
| strings.TrimRight(commit.Message, "\r\n")) + authorName | ||
| textSb.WriteString(fmt.Sprintf("[%s](%s) %s", commit.ID[:7], commit.URL, |
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.
As above
| text := fmt.Sprintf("[%s] %s pushed %s to %s:<br>", repoLink, p.Pusher.UserName, commitDesc, branchLink) | ||
|
|
||
| var textSb strings.Builder | ||
| textSb.WriteString(fmt.Sprintf("[%s] %s pushed %s to %s:<br>", repoLink, p.Pusher.UserName, commitDesc, branchLink)) |
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.
As above
| // for each commit, generate a new line text | ||
| for i, commit := range p.Commits { | ||
| text += fmt.Sprintf("%s: %s - %s", htmlLinkFormatter(commit.URL, commit.ID[:7]), commit.Message, commit.Author.Name) | ||
| textSb.WriteString(fmt.Sprintf("%s: %s - %s", htmlLinkFormatter(commit.URL, commit.ID[:7]), commit.Message, commit.Author.Name)) |
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.
As above
| for i, commit := range p.Commits { | ||
| text += fmt.Sprintf("[%s](%s) %s - %s", commit.ID[:7], commit.URL, | ||
| strings.TrimRight(commit.Message, "\r\n"), commit.Author.Name) | ||
| textSb.WriteString(fmt.Sprintf("[%s](%s) %s - %s", commit.ID[:7], commit.URL, |
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.
As above
| var attachmentTextSb strings.Builder | ||
| for i, commit := range p.Commits { | ||
| attachmentText += fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.URL, commit.ID[:7]), SlackShortTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name)) | ||
| attachmentTextSb.WriteString(fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.URL, commit.ID[:7]), SlackShortTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name))) |
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.
As above
| var htmlCommitsSb strings.Builder | ||
| for _, commit := range p.Commits { | ||
| htmlCommits += fmt.Sprintf("\n[%s] %s", htmlLinkFormatter(commit.URL, commit.ID[:7]), html.EscapeString(strings.TrimRight(commit.Message, "\r\n"))) | ||
| htmlCommitsSb.WriteString(fmt.Sprintf("\n[%s] %s", htmlLinkFormatter(commit.URL, commit.ID[:7]), html.EscapeString(strings.TrimRight(commit.Message, "\r\n")))) |
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.
As above
| message := strings.ReplaceAll(commit.Message, "\n\n", "\r\n") | ||
| text += fmt.Sprintf(" > [%s](%s) \r\n ><font color=\"info\">%s</font> \n ><font color=\"warning\">%s</font>", commit.ID[:7], commit.URL, | ||
| message, authorName) | ||
| textSb.WriteString(fmt.Sprintf(" > [%s](%s) \r\n ><font color=\"info\">%s</font> \n ><font color=\"warning\">%s</font>", commit.ID[:7], commit.URL, |
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.
As above
| func (p *Permission) LogString() string { | ||
| format := "<Permission AccessMode=%s, %d Units, %d UnitsMode(s): [" | ||
| var formatSb strings.Builder | ||
| formatSb.WriteString("<Permission AccessMode=%s, %d Units, %d UnitsMode(s): [") |
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.
Just use fmt.Fprintf so that no args is needed.
|
I really dislike unnecessary lint rules. And I have strong objection for this Sprintf change, it doesn't improve readability. |
https://github.com/golangci/golangci-lint/releases/tag/v2.6.0
modernizelinter is enabled, this is the same asgopls modernizeperfsprintlinter is disabled because it conflicts withmodernize(maybe there is a middle ground)deprecatedCommentis disabled as it conflicts withgo-swagger