From e30951ad725139e20f861fc88fe61a913afbb34c Mon Sep 17 00:00:00 2001 From: Mathias Date: Wed, 1 Jul 2026 22:53:15 +0200 Subject: [PATCH] fix(create_project): use fmt.Fprintf in test fake (lint QF1012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to e3cdd23 — staticcheck QF1012 flagged w.Write([]byte(fmt.Sprintf(...))) in the rewritten test's fake server. Behaviour unchanged; lint gate green. --- internal/tools/create_project_from_template_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/tools/create_project_from_template_test.go b/internal/tools/create_project_from_template_test.go index d6df141..a91f744 100644 --- a/internal/tools/create_project_from_template_test.go +++ b/internal/tools/create_project_from_template_test.go @@ -61,13 +61,13 @@ func (f *fakeTemplateServer) handler(t *testing.T, tmpl, dest string) http.Handl return } f.repoGetsPost++ - _, _ = w.Write([]byte(fmt.Sprintf(`{"name":%q,"full_name":"mathias/%s","default_branch":"main","clone_url":"c","html_url":"h","template":false}`, dest, dest))) + _, _ = fmt.Fprintf(w, `{"name":%q,"full_name":"mathias/%s","default_branch":"main","clone_url":"c","html_url":"h","template":false}`, dest, dest) case r.Method == http.MethodPost && p == "/api/v1/repos/mathias/"+tmpl+"/generate": f.generated = true w.WriteHeader(http.StatusCreated) - _, _ = w.Write([]byte(fmt.Sprintf(`{"name":%q,"full_name":"mathias/%s","default_branch":%q,"clone_url":"http://gitea.example.com/mathias/%s.git","html_url":"http://gitea.example.com/mathias/%s","template":false}`, - dest, dest, f.genBranch, dest, dest))) + _, _ = fmt.Fprintf(w, `{"name":%q,"full_name":"mathias/%s","default_branch":%q,"clone_url":"http://gitea.example.com/mathias/%s.git","html_url":"http://gitea.example.com/mathias/%s","template":false}`, + dest, dest, f.genBranch, dest, dest) case r.Method == http.MethodGet && strings.HasPrefix(p, "/api/v1/repos/mathias/"+dest+"/git/trees/"): var entries []string @@ -76,7 +76,7 @@ func (f *fakeTemplateServer) handler(t *testing.T, tmpl, dest string) http.Handl } // include a tree (directory) entry to exercise the blob filter entries = append(entries, `{"path":"cmd","type":"tree","sha":"treesha"}`) - _, _ = w.Write([]byte(fmt.Sprintf(`{"sha":"root","tree":[%s],"truncated":false}`, strings.Join(entries, ",")))) + _, _ = fmt.Fprintf(w, `{"sha":"root","tree":[%s],"truncated":false}`, strings.Join(entries, ",")) case r.Method == http.MethodGet && strings.HasPrefix(p, "/api/v1/repos/mathias/"+dest+"/contents/"): path := strings.TrimPrefix(p, "/api/v1/repos/mathias/"+dest+"/contents/") @@ -86,8 +86,8 @@ func (f *fakeTemplateServer) handler(t *testing.T, tmpl, dest string) http.Handl _, _ = w.Write([]byte(`{"message":"not found"}`)) return } - _, _ = w.Write([]byte(fmt.Sprintf(`{"path":%q,"sha":"sha-%s","size":1,"content":%q,"encoding":"base64"}`, - path, strings.ReplaceAll(path, "/", "-"), encb64(body)))) + _, _ = fmt.Fprintf(w, `{"path":%q,"sha":"sha-%s","size":1,"content":%q,"encoding":"base64"}`, + path, strings.ReplaceAll(path, "/", "-"), encb64(body)) // POST = create (new/renamed file, no sha), PUT = update (existing, with sha). case (r.Method == http.MethodPost || r.Method == http.MethodPut) && strings.HasPrefix(p, "/api/v1/repos/mathias/"+dest+"/contents/"):