Skip to content

Commit 6413312

Browse files
authored
Update golangci-lint to version 1.31.0 (#13102)
This PR updates golangci-lint to the latest version 1.31.0. The upgrade introduced a new check for which I've fixed or disabled most cases. Signed-off-by: kolaente <[email protected]>
1 parent e35f7e8 commit 6413312

File tree

23 files changed

+47
-41
lines changed

23 files changed

+47
-41
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,9 @@ issues:
101101
- path: cmd/dump.go
102102
linters:
103103
- dupl
104+
- text: "commentFormatting: put a space between `//` and comment text"
105+
linters:
106+
- gocritic
107+
- text: "exitAfterDefer:"
108+
linters:
109+
- gocritic

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ pr\#%: clean-all
697697
golangci-lint:
698698
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
699699
export BINARY="golangci-lint"; \
700-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.30.0; \
700+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.31.0; \
701701
fi
702702
golangci-lint run --timeout 5m
703703

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,5 @@ func formatBuiltWith() string {
189189
return " built with " + version
190190
}
191191

192-
return " built with " + version + " : " + strings.Replace(Tags, " ", ", ", -1)
192+
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
193193
}

models/migrations/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
680680
cols += "`" + strings.ToLower(col) + "`"
681681
}
682682
sql := fmt.Sprintf("SELECT Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('%[1]s') AND PARENT_COLUMN_ID IN (SELECT column_id FROM sys.columns WHERE lower(NAME) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))",
683-
tableName, strings.Replace(cols, "`", "'", -1))
683+
tableName, strings.ReplaceAll(cols, "`", "'"))
684684
constraints := make([]string, 0)
685685
if err := sess.SQL(sql).Find(&constraints); err != nil {
686686
return fmt.Errorf("Find constraints: %v", err)

modules/git/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (h *Hook) Update() error {
9696
return err
9797
}
9898

99-
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
99+
err := ioutil.WriteFile(h.path, []byte(strings.ReplaceAll(h.Content, "\r", "")), os.ModePerm)
100100
if err != nil {
101101
return err
102102
}

modules/log/stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func functionName(programCounter uintptr) []byte {
6969
name = name[period+1:]
7070
}
7171
// And we should just replace the interpunct with a dot
72-
name = bytes.Replace(name, []byte("·"), []byte("."), -1)
72+
name = bytes.ReplaceAll(name, []byte("·"), []byte("."))
7373
return name
7474
}
7575

modules/markup/html.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,9 @@ func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) {
683683
absoluteLink := isLinkStr(link)
684684
if !absoluteLink {
685685
if image {
686-
link = strings.Replace(link, " ", "+", -1)
686+
link = strings.ReplaceAll(link, " ", "+")
687687
} else {
688-
link = strings.Replace(link, " ", "-", -1)
688+
link = strings.ReplaceAll(link, " ", "-")
689689
}
690690
if !strings.Contains(link, "/") {
691691
link = url.PathEscape(link)
@@ -902,7 +902,7 @@ func emojiShortCodeProcessor(ctx *postProcessCtx, node *html.Node) {
902902
}
903903

904904
alias := node.Data[m[0]:m[1]]
905-
alias = strings.Replace(alias, ":", "", -1)
905+
alias = strings.ReplaceAll(alias, ":", "")
906906
converted := emoji.FromAlias(alias)
907907
if converted == nil {
908908
// check if this is a custom reaction

modules/markup/html_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestRender_Commits(t *testing.T) {
3535
var sha = "65f1bf27bc3bf70f64657658635e66094edbcb4d"
3636
var commit = util.URLJoin(AppSubURL, "commit", sha)
3737
var subtree = util.URLJoin(commit, "src")
38-
var tree = strings.Replace(subtree, "/commit/", "/tree/", -1)
38+
var tree = strings.ReplaceAll(subtree, "/commit/", "/tree/")
3939

4040
test(sha, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
4141
test(sha[:7], `<p><a href="`+commit[:len(commit)-(40-7)]+`" rel="nofollow"><code>65f1bf2</code></a></p>`)
@@ -235,7 +235,7 @@ func TestRender_emoji(t *testing.T) {
235235
setting.StaticURLPrefix = AppURL
236236

237237
test := func(input, expected string) {
238-
expected = strings.Replace(expected, "&", "&amp;", -1)
238+
expected = strings.ReplaceAll(expected, "&", "&amp;")
239239
buffer := RenderString("a.md", input, setting.AppSubURL, nil)
240240
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
241241
}

modules/repository/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func gatherMissingRepoRecords(ctx context.Context) ([]*models.Repository, error)
120120
return nil
121121
},
122122
); err != nil {
123-
if strings.HasPrefix("Aborted gathering missing repo", err.Error()) {
123+
if strings.HasPrefix(err.Error(), "Aborted gathering missing repo") {
124124
return nil, err
125125
}
126126
if err2 := models.CreateRepositoryNotice("gatherMissingRepoRecords: %v", err); err2 != nil {

modules/setting/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func newRepository() {
253253
if err != nil {
254254
log.Fatal("Failed to get home directory: %v", err)
255255
}
256-
homeDir = strings.Replace(homeDir, "\\", "/", -1)
256+
homeDir = strings.ReplaceAll(homeDir, "\\", "/")
257257

258258
// Determine and create root git repository path.
259259
sec := Cfg.Section("repository")

0 commit comments

Comments
 (0)