Skip to content

Commit f671bf6

Browse files
committed
enable int conversion
1 parent 4faf34d commit f671bf6

File tree

38 files changed

+100
-85
lines changed

38 files changed

+100
-85
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ linters:
8383
- name: unreachable-code
8484
- name: var-declaration
8585
- name: var-naming
86-
perfsprint:
87-
integer-format: false
88-
int-conversion: false
8986
staticcheck:
9087
checks:
9188
- all

cmd/serv.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ func runServ(c *cli.Context) error {
372372
repo_module.EnvPusherEmail+"="+results.UserEmail,
373373
repo_module.EnvPusherID+"="+strconv.FormatInt(results.UserID, 10),
374374
repo_module.EnvRepoID+"="+strconv.FormatInt(results.RepoID, 10),
375-
repo_module.EnvPRID+"="+fmt.Sprintf("%d", 0),
376-
repo_module.EnvDeployKeyID+"="+fmt.Sprintf("%d", results.DeployKeyID),
377-
repo_module.EnvKeyID+"="+fmt.Sprintf("%d", results.KeyID),
375+
repo_module.EnvPRID+"="+strconv.Itoa(0),
376+
repo_module.EnvDeployKeyID+"="+strconv.FormatInt(results.DeployKeyID, 10),
377+
repo_module.EnvKeyID+"="+strconv.FormatInt(results.KeyID, 10),
378378
repo_module.EnvAppURL+"="+setting.AppURL,
379379
)
380380
// to avoid breaking, here only use the minimal environment variables for the "gitea serv" command.

models/issues/issue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"html/template"
1111
"regexp"
1212
"slices"
13+
"strconv"
1314

1415
"code.gitea.io/gitea/models/db"
1516
project_model "code.gitea.io/gitea/models/project"
@@ -815,7 +816,7 @@ func ChangeIssueTimeEstimate(ctx context.Context, issue *Issue, doer *user_model
815816
Doer: doer,
816817
Repo: issue.Repo,
817818
Issue: issue,
818-
Content: fmt.Sprintf("%d", timeEstimate),
819+
Content: strconv.FormatInt(timeEstimate, 10),
819820
}
820821
if _, err := CreateComment(ctx, opts); err != nil {
821822
return fmt.Errorf("createComment: %w", err)

models/migrations/v1_22/v287_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package v1_22 //nolint
55

66
import (
7-
"fmt"
7+
"strconv"
88
"testing"
99

1010
"code.gitea.io/gitea/models/migrations/base"
@@ -50,7 +50,7 @@ func Test_UpdateBadgeColName(t *testing.T) {
5050
for i, e := range oldBadges {
5151
got := got[i+1] // 1 is in the badge.yml
5252
assert.Equal(t, e.ID, got.ID)
53-
assert.Equal(t, fmt.Sprintf("%d", e.ID), got.Slug)
53+
assert.Equal(t, strconv.FormatInt(e.ID, 10), got.Slug)
5454
}
5555

5656
// TODO: check if badges have been updated

models/repo/avatar.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"image/png"
1010
"io"
1111
"net/url"
12+
"strconv"
1213

1314
"code.gitea.io/gitea/models/db"
1415
"code.gitea.io/gitea/modules/avatar"
@@ -37,7 +38,7 @@ func (repo *Repository) RelAvatarLink(ctx context.Context) string {
3738

3839
// generateRandomAvatar generates a random avatar for repository.
3940
func generateRandomAvatar(ctx context.Context, repo *Repository) error {
40-
idToString := fmt.Sprintf("%d", repo.ID)
41+
idToString := strconv.FormatInt(repo.ID, 10)
4142

4243
seed := idToString
4344
img, err := avatar.RandomImage([]byte(seed))

modules/git/grep.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO
6161
*/
6262
var results []*GrepResult
6363
cmd := NewCommand("grep", "--null", "--break", "--heading", "--line-number", "--full-name")
64-
cmd.AddOptionValues("--context", fmt.Sprint(opts.ContextLineNumber))
64+
cmd.AddOptionValues("--context", strconv.Itoa(opts.ContextLineNumber))
6565
switch opts.GrepMode {
6666
case GrepModeExact:
6767
cmd.AddArguments("--fixed-strings")

modules/httplib/serve_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
package httplib
55

66
import (
7-
"fmt"
87
"net/http"
98
"net/http/httptest"
109
"net/url"
1110
"os"
11+
"strconv"
1212
"strings"
1313
"testing"
1414

@@ -30,7 +30,7 @@ func TestServeContentByReader(t *testing.T) {
3030
ServeContentByReader(r, w, int64(len(data)), reader, &ServeHeaderOptions{})
3131
assert.Equal(t, expectedStatusCode, w.Code)
3232
if expectedStatusCode == http.StatusPartialContent || expectedStatusCode == http.StatusOK {
33-
assert.Equal(t, fmt.Sprint(len(expectedContent)), w.Header().Get("Content-Length"))
33+
assert.Equal(t, strconv.Itoa(len(expectedContent)), w.Header().Get("Content-Length"))
3434
assert.Equal(t, expectedContent, w.Body.String())
3535
}
3636
}
@@ -79,7 +79,7 @@ func TestServeContentByReadSeeker(t *testing.T) {
7979
ServeContentByReadSeeker(r, w, nil, seekReader, &ServeHeaderOptions{})
8080
assert.Equal(t, expectedStatusCode, w.Code)
8181
if expectedStatusCode == http.StatusPartialContent || expectedStatusCode == http.StatusOK {
82-
assert.Equal(t, fmt.Sprint(len(expectedContent)), w.Header().Get("Content-Length"))
82+
assert.Equal(t, strconv.Itoa(len(expectedContent)), w.Header().Get("Content-Length"))
8383
assert.Equal(t, expectedContent, w.Body.String())
8484
}
8585
}

modules/indexer/issues/elasticsearch/elasticsearch.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package elasticsearch
55

66
import (
77
"context"
8-
"fmt"
98
"strconv"
109
"strings"
1110

@@ -96,7 +95,7 @@ func (b *Indexer) Index(ctx context.Context, issues ...*internal.IndexerData) er
9695
issue := issues[0]
9796
_, err := b.inner.Client.Index().
9897
Index(b.inner.VersionedIndexName()).
99-
Id(fmt.Sprintf("%d", issue.ID)).
98+
Id(strconv.FormatInt(issue.ID, 10)).
10099
BodyJson(issue).
101100
Do(ctx)
102101
return err
@@ -107,7 +106,7 @@ func (b *Indexer) Index(ctx context.Context, issues ...*internal.IndexerData) er
107106
reqs = append(reqs,
108107
elastic.NewBulkIndexRequest().
109108
Index(b.inner.VersionedIndexName()).
110-
Id(fmt.Sprintf("%d", issue.ID)).
109+
Id(strconv.FormatInt(issue.ID, 10)).
111110
Doc(issue),
112111
)
113112
}
@@ -126,7 +125,7 @@ func (b *Indexer) Delete(ctx context.Context, ids ...int64) error {
126125
} else if len(ids) == 1 {
127126
_, err := b.inner.Client.Delete().
128127
Index(b.inner.VersionedIndexName()).
129-
Id(fmt.Sprintf("%d", ids[0])).
128+
Id(strconv.FormatInt(ids[0], 10)).
130129
Do(ctx)
131130
return err
132131
}
@@ -136,7 +135,7 @@ func (b *Indexer) Delete(ctx context.Context, ids ...int64) error {
136135
reqs = append(reqs,
137136
elastic.NewBulkDeleteRequest().
138137
Index(b.inner.VersionedIndexName()).
139-
Id(fmt.Sprintf("%d", id)),
138+
Id(strconv.FormatInt(id, 10)),
140139
)
141140
}
142141

modules/markup/common/footnote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type FootnoteLink struct {
5353
// Dump implements Node.Dump.
5454
func (n *FootnoteLink) Dump(source []byte, level int) {
5555
m := map[string]string{}
56-
m["Index"] = fmt.Sprintf("%v", n.Index)
56+
m["Index"] = strconv.Itoa(n.Index)
5757
m["Name"] = fmt.Sprintf("%v", n.Name)
5858
ast.DumpHelper(n, source, level, m, nil)
5959
}
@@ -85,7 +85,7 @@ type FootnoteBackLink struct {
8585
// Dump implements Node.Dump.
8686
func (n *FootnoteBackLink) Dump(source []byte, level int) {
8787
m := map[string]string{}
88-
m["Index"] = fmt.Sprintf("%v", n.Index)
88+
m["Index"] = strconv.Itoa(n.Index)
8989
m["Name"] = fmt.Sprintf("%v", n.Name)
9090
ast.DumpHelper(n, source, level, m, nil)
9191
}
@@ -151,7 +151,7 @@ type FootnoteList struct {
151151
// Dump implements Node.Dump.
152152
func (n *FootnoteList) Dump(source []byte, level int) {
153153
m := map[string]string{}
154-
m["Count"] = fmt.Sprintf("%v", n.Count)
154+
m["Count"] = strconv.Itoa(n.Count)
155155
ast.DumpHelper(n, source, level, m, nil)
156156
}
157157

modules/repository/env.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
package repository
55

66
import (
7-
"fmt"
87
"os"
8+
"strconv"
99
"strings"
1010

1111
repo_model "code.gitea.io/gitea/models/repo"
@@ -72,9 +72,9 @@ func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model
7272
EnvRepoUsername+"="+repo.OwnerName,
7373
EnvRepoIsWiki+"="+isWiki,
7474
EnvPusherName+"="+committer.Name,
75-
EnvPusherID+"="+fmt.Sprintf("%d", committer.ID),
76-
EnvRepoID+"="+fmt.Sprintf("%d", repo.ID),
77-
EnvPRID+"="+fmt.Sprintf("%d", prID),
75+
EnvPusherID+"="+strconv.FormatInt(committer.ID, 10),
76+
EnvRepoID+"="+strconv.FormatInt(repo.ID, 10),
77+
EnvPRID+"="+strconv.FormatInt(prID, 10),
7878
EnvAppURL+"="+setting.AppURL,
7979
"SSH_ORIGINAL_COMMAND=gitea-internal",
8080
)

0 commit comments

Comments
 (0)