Skip to content

Commit b3f925a

Browse files
committed
enable string formatting
1 parent 1415544 commit b3f925a

File tree

135 files changed

+382
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+382
-424
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ linters:
8686
perfsprint:
8787
integer-format: false
8888
int-conversion: false
89-
string-format: false
90-
sprintf1: false
91-
strconcat: false
9289
bool-format: false
9390
hex-format: false
9491
staticcheck:

cmd/dump.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package cmd
66

77
import (
8-
"fmt"
98
"os"
109
"path"
1110
"path/filepath"
@@ -93,7 +92,7 @@ var CmdDump = &cli.Command{
9392
},
9493
&cli.StringFlag{
9594
Name: "type",
96-
Usage: fmt.Sprintf(`Dump output format, default to "zip", supported types: %s`, strings.Join(dump.SupportedOutputTypes, ", ")),
95+
Usage: "Dump output format, default to \"zip\", supported types: " + strings.Join(dump.SupportedOutputTypes, ", "),
9796
},
9897
},
9998
}

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func getLFSAuthToken(ctx context.Context, lfsVerb string, results *private.ServC
173173
if err != nil {
174174
return "", fail(ctx, "Failed to sign JWT Token", "Failed to sign JWT token: %v", err)
175175
}
176-
return fmt.Sprintf("Bearer %s", tokenString), nil
176+
return "Bearer " + tokenString, nil
177177
}
178178

179179
func runServ(c *cli.Context) error {

models/asymkey/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func IsErrGPGKeyParsing(err error) bool {
132132
}
133133

134134
func (err ErrGPGKeyParsing) Error() string {
135-
return fmt.Sprintf("failed to parse gpg key %s", err.ParseError.Error())
135+
return "failed to parse gpg key " + err.ParseError.Error()
136136
}
137137

138138
// ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error.

models/auth/access_token_scope_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func TestAccessTokenScope_Normalize(t *testing.T) {
2828

2929
for _, scope := range GetAccessTokenCategories() {
3030
tests = append(tests,
31-
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%s", scope)), AccessTokenScope(fmt.Sprintf("read:%s", scope)), nil},
32-
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("write:%s", scope)), AccessTokenScope(fmt.Sprintf("write:%s", scope)), nil},
33-
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("write:%[1]s,read:%[1]s", scope)), AccessTokenScope(fmt.Sprintf("write:%s", scope)), nil},
34-
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%[1]s,write:%[1]s", scope)), AccessTokenScope(fmt.Sprintf("write:%s", scope)), nil},
35-
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%[1]s,write:%[1]s,write:%[1]s", scope)), AccessTokenScope(fmt.Sprintf("write:%s", scope)), nil},
31+
scopeTestNormalize{AccessTokenScope("read:" + scope), AccessTokenScope("read:" + scope), nil},
32+
scopeTestNormalize{AccessTokenScope("write:" + scope), AccessTokenScope("write:" + scope), nil},
33+
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("write:%[1]s,read:%[1]s", scope)), AccessTokenScope("write:" + scope), nil},
34+
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%[1]s,write:%[1]s", scope)), AccessTokenScope("write:" + scope), nil},
35+
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%[1]s,write:%[1]s,write:%[1]s", scope)), AccessTokenScope("write:" + scope), nil},
3636
)
3737
}
3838

@@ -63,20 +63,20 @@ func TestAccessTokenScope_HasScope(t *testing.T) {
6363
for _, scope := range GetAccessTokenCategories() {
6464
tests = append(tests,
6565
scopeTestHasScope{
66-
AccessTokenScope(fmt.Sprintf("read:%s", scope)),
67-
AccessTokenScope(fmt.Sprintf("read:%s", scope)), true, nil,
66+
AccessTokenScope("read:" + scope),
67+
AccessTokenScope("read:" + scope), true, nil,
6868
},
6969
scopeTestHasScope{
70-
AccessTokenScope(fmt.Sprintf("write:%s", scope)),
71-
AccessTokenScope(fmt.Sprintf("write:%s", scope)), true, nil,
70+
AccessTokenScope("write:" + scope),
71+
AccessTokenScope("write:" + scope), true, nil,
7272
},
7373
scopeTestHasScope{
74-
AccessTokenScope(fmt.Sprintf("write:%s", scope)),
75-
AccessTokenScope(fmt.Sprintf("read:%s", scope)), true, nil,
74+
AccessTokenScope("write:" + scope),
75+
AccessTokenScope("read:" + scope), true, nil,
7676
},
7777
scopeTestHasScope{
78-
AccessTokenScope(fmt.Sprintf("read:%s", scope)),
79-
AccessTokenScope(fmt.Sprintf("write:%s", scope)), false, nil,
78+
AccessTokenScope("read:" + scope),
79+
AccessTokenScope("write:" + scope), false, nil,
8080
},
8181
)
8282
}

models/db/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func IsTableNotEmpty(beanOrTableName any) (bool, error) {
127127

128128
// DeleteAllRecords will delete all the records of this table
129129
func DeleteAllRecords(tableName string) error {
130-
_, err := xormEngine.Exec(fmt.Sprintf("DELETE FROM %s", tableName))
130+
_, err := xormEngine.Exec("DELETE FROM " + tableName)
131131
return err
132132
}
133133

models/db/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (err ErrNotExist) Error() string {
6565
if err.ID != 0 {
6666
return fmt.Sprintf("%s does not exist [id: %d]", name, err.ID)
6767
}
68-
return fmt.Sprintf("%s does not exist", name)
68+
return name + " does not exist"
6969
}
7070

7171
// Unwrap unwraps this as a ErrNotExist err

models/git/commit_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (status *CommitStatus) HideActionsURL(ctx context.Context) {
222222
}
223223
}
224224

225-
prefix := fmt.Sprintf("%s/actions", status.Repo.Link())
225+
prefix := status.Repo.Link() + "/actions"
226226
if strings.HasPrefix(status.TargetURL, prefix) {
227227
status.TargetURL = ""
228228
}

models/issues/pull.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,20 +926,20 @@ func ParseCodeOwnersLine(ctx context.Context, tokens []string) (*CodeOwnerRule,
926926
if strings.Contains(user, "/") {
927927
s := strings.Split(user, "/")
928928
if len(s) != 2 {
929-
warnings = append(warnings, fmt.Sprintf("incorrect codeowner group: %s", user))
929+
warnings = append(warnings, "incorrect codeowner group: "+user)
930930
continue
931931
}
932932
orgName := s[0]
933933
teamName := s[1]
934934

935935
org, err := org_model.GetOrgByName(ctx, orgName)
936936
if err != nil {
937-
warnings = append(warnings, fmt.Sprintf("incorrect codeowner organization: %s", user))
937+
warnings = append(warnings, "incorrect codeowner organization: "+user)
938938
continue
939939
}
940940
teams, err := org.LoadTeams(ctx)
941941
if err != nil {
942-
warnings = append(warnings, fmt.Sprintf("incorrect codeowner team: %s", user))
942+
warnings = append(warnings, "incorrect codeowner team: "+user)
943943
continue
944944
}
945945

@@ -951,7 +951,7 @@ func ParseCodeOwnersLine(ctx context.Context, tokens []string) (*CodeOwnerRule,
951951
} else {
952952
u, err := user_model.GetUserByName(ctx, user)
953953
if err != nil {
954-
warnings = append(warnings, fmt.Sprintf("incorrect codeowner user: %s", user))
954+
warnings = append(warnings, "incorrect codeowner user: "+user)
955955
continue
956956
}
957957
rule.Users = append(rule.Users, u)

models/migrations/base/db.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func RecreateTable(sess *xorm.Session, bean any) error {
5252
// TODO: This will not work if there are foreign keys
5353

5454
tableName := sess.Engine().TableName(bean)
55-
tempTableName := fmt.Sprintf("tmp_recreate__%s", tableName)
55+
tempTableName := "tmp_recreate__" + tableName
5656

5757
// We need to move the old table away and create a new one with the correct columns
5858
// We will need to do this in stages to prevent data loss
@@ -552,11 +552,11 @@ func deleteDB() error {
552552
}
553553
defer db.Close()
554554

555-
if _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", setting.Database.Name)); err != nil {
555+
if _, err = db.Exec("DROP DATABASE IF EXISTS " + setting.Database.Name); err != nil {
556556
return err
557557
}
558558

559-
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", setting.Database.Name)); err != nil {
559+
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS " + setting.Database.Name); err != nil {
560560
return err
561561
}
562562
return nil
@@ -568,11 +568,11 @@ func deleteDB() error {
568568
}
569569
defer db.Close()
570570

571-
if _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", setting.Database.Name)); err != nil {
571+
if _, err = db.Exec("DROP DATABASE IF EXISTS " + setting.Database.Name); err != nil {
572572
return err
573573
}
574574

575-
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s", setting.Database.Name)); err != nil {
575+
if _, err = db.Exec("CREATE DATABASE " + setting.Database.Name); err != nil {
576576
return err
577577
}
578578
db.Close()
@@ -594,7 +594,7 @@ func deleteDB() error {
594594

595595
if !schrows.Next() {
596596
// Create and setup a DB schema
597-
_, err = db.Exec(fmt.Sprintf("CREATE SCHEMA %s", setting.Database.Schema))
597+
_, err = db.Exec("CREATE SCHEMA " + setting.Database.Schema)
598598
if err != nil {
599599
return err
600600
}

0 commit comments

Comments
 (0)