fix: lint issues

Ayman Bagabas created

Change summary

git/tree.go                              |  2 
pkg/backend/repo.go                      |  2 
pkg/backend/webhooks.go                  |  4 +-
pkg/daemon/daemon.go                     |  2 
pkg/hooks/gen.go                         |  2 
pkg/ssh/cmd/tree.go                      |  2 
pkg/ssh/cmd/webhooks.go                  | 28 +++++++++++++-------------
pkg/ui/common/utils.go                   |  6 ++--
pkg/ui/components/statusbar/statusbar.go |  2 
pkg/ui/pages/repo/filesitem.go           |  2 
pkg/ui/pages/repo/logitem.go             |  4 +-
pkg/ui/pages/repo/refsitem.go            |  4 +-
pkg/ui/pages/repo/stashitem.go           |  2 
pkg/ui/pages/selection/item.go           |  2 
pkg/web/logging.go                       |  2 
pkg/webhook/webhook.go                   |  2 
16 files changed, 34 insertions(+), 34 deletions(-)

Detailed changes

git/tree.go 🔗

@@ -170,7 +170,7 @@ func (e *TreeEntry) Mode() fs.FileMode {
 	case git.EntryTree:
 		return fs.ModeDir | fs.ModePerm
 	default:
-		return fs.FileMode(m)
+		return fs.FileMode(m) //nolint:gosec
 	}
 }
 

pkg/backend/repo.go 🔗

@@ -742,7 +742,7 @@ func (r *repo) writeLastModified(t time.Time) error {
 		return err
 	}
 
-	return os.WriteFile(fp, []byte(t.Format(time.RFC3339)), os.ModePerm)
+	return os.WriteFile(fp, []byte(t.Format(time.RFC3339)), os.ModePerm) //nolint:gosec
 }
 
 func readOneline(path string) (string, error) {

pkg/backend/webhooks.go 🔗

@@ -54,7 +54,7 @@ func (b *Backend) Webhook(ctx context.Context, repo proto.Repository, id int64)
 
 		wh = webhook.Hook{
 			Webhook:     h,
-			ContentType: webhook.ContentType(h.ContentType),
+			ContentType: webhook.ContentType(h.ContentType), //nolint:gosec
 			Events:      make([]webhook.Event, len(events)),
 		}
 		for i, e := range events {
@@ -105,7 +105,7 @@ func (b *Backend) ListWebhooks(ctx context.Context, repo proto.Repository) ([]we
 
 		hooks[i] = webhook.Hook{
 			Webhook:     h,
-			ContentType: webhook.ContentType(h.ContentType),
+			ContentType: webhook.ContentType(h.ContentType), //nolint:gosec
 			Events:      events,
 		}
 	}

pkg/daemon/daemon.go 🔗

@@ -109,7 +109,7 @@ func (d *GitDaemon) Serve(listener net.Listener) error {
 				} else {
 					tempDelay *= 2
 				}
-				if max := 1 * time.Second; tempDelay > max {
+				if max := 1 * time.Second; tempDelay > max { //nolint:revive
 					tempDelay = max
 				}
 				time.Sleep(tempDelay)

pkg/hooks/gen.go 🔗

@@ -48,7 +48,7 @@ func GenerateHooks(_ context.Context, cfg *config.Config, repo string) error {
 		hp := filepath.Join(hooksPath, hook)
 
 		// Write the hooks primary script
-		if err := os.WriteFile(hp, []byte(hookTemplate), os.ModePerm); err != nil {
+		if err := os.WriteFile(hp, []byte(hookTemplate), os.ModePerm); err != nil { //nolint:gosec
 			return err
 		}
 

pkg/ssh/cmd/tree.go 🔗

@@ -92,7 +92,7 @@ func treeCommand() *cobra.Command {
 				if size == 0 {
 					ssize = "-"
 				} else {
-					ssize = humanize.Bytes(uint64(size))
+					ssize = humanize.Bytes(uint64(size)) //nolint:gosec
 				}
 				cmd.Printf("%s\t%s\t %s\n", ent.Mode(), ssize, common.UnquoteFilename(ent.Name()))
 			}

pkg/ssh/cmd/webhooks.go 🔗

@@ -361,34 +361,34 @@ func webhookDeliveriesGetCommand() *cobra.Command {
 			}
 
 			out := cmd.OutOrStdout()
-			fmt.Fprintf(out, "ID: %s\n", del.ID)
-			fmt.Fprintf(out, "Event: %s\n", del.Event)
-			fmt.Fprintf(out, "Request URL: %s\n", del.RequestURL)
-			fmt.Fprintf(out, "Request Method: %s\n", del.RequestMethod)
-			fmt.Fprintf(out, "Request Error: %s\n", del.RequestError.String)
-			fmt.Fprintf(out, "Request Headers:\n")
+			fmt.Fprintf(out, "ID: %s\n", del.ID)                             //nolint:errcheck
+			fmt.Fprintf(out, "Event: %s\n", del.Event)                       //nolint:errcheck
+			fmt.Fprintf(out, "Request URL: %s\n", del.RequestURL)            //nolint:errcheck
+			fmt.Fprintf(out, "Request Method: %s\n", del.RequestMethod)      //nolint:errcheck
+			fmt.Fprintf(out, "Request Error: %s\n", del.RequestError.String) //nolint:errcheck
+			fmt.Fprintf(out, "Request Headers:\n")                           //nolint:errcheck
 			reqHeaders := strings.Split(del.RequestHeaders, "\n")
 			for _, h := range reqHeaders {
-				fmt.Fprintf(out, "  %s\n", h)
+				fmt.Fprintf(out, "  %s\n", h) //nolint:errcheck
 			}
 
-			fmt.Fprintf(out, "Request Body:\n")
+			fmt.Fprintf(out, "Request Body:\n") //nolint:errcheck
 			reqBody := strings.Split(del.RequestBody, "\n")
 			for _, b := range reqBody {
-				fmt.Fprintf(out, "  %s\n", b)
+				fmt.Fprintf(out, "  %s\n", b) //nolint:errcheck
 			}
 
-			fmt.Fprintf(out, "Response Status: %d\n", del.ResponseStatus)
-			fmt.Fprintf(out, "Response Headers:\n")
+			fmt.Fprintf(out, "Response Status: %d\n", del.ResponseStatus) //nolint:errcheck
+			fmt.Fprintf(out, "Response Headers:\n")                       //nolint:errcheck
 			resHeaders := strings.Split(del.ResponseHeaders, "\n")
 			for _, h := range resHeaders {
-				fmt.Fprintf(out, "  %s\n", h)
+				fmt.Fprintf(out, "  %s\n", h) //nolint:errcheck
 			}
 
-			fmt.Fprintf(out, "Response Body:\n")
+			fmt.Fprintf(out, "Response Body:\n") //nolint:errcheck
 			resBody := strings.Split(del.ResponseBody, "\n")
 			for _, b := range resBody {
-				fmt.Fprintf(out, "  %s\n", b)
+				fmt.Fprintf(out, "  %s\n", b) //nolint:errcheck
 			}
 
 			return nil

pkg/ui/common/utils.go 🔗

@@ -9,11 +9,11 @@ import (
 )
 
 // TruncateString is a convenient wrapper around truncate.TruncateString.
-func TruncateString(s string, max int) string {
+func TruncateString(s string, max int) string { //nolint:revive
 	if max < 0 {
-		max = 0
+		max = 0 //nolint:revive
 	}
-	return truncate.StringWithTail(s, uint(max), "…")
+	return truncate.StringWithTail(s, uint(max), "…") //nolint:gosec
 }
 
 // RepoURL returns the URL of the repository.

pkg/ui/components/statusbar/statusbar.go 🔗

@@ -75,7 +75,7 @@ func (s *Model) View() string {
 	}
 	branch := st.StatusBarBranch.Render(s.extra)
 	maxWidth := s.common.Width - w(key) - w(info) - w(branch) - w(help)
-	v := truncate.StringWithTail(s.value, uint(maxWidth-st.StatusBarValue.GetHorizontalFrameSize()), "…")
+	v := truncate.StringWithTail(s.value, uint(maxWidth-st.StatusBarValue.GetHorizontalFrameSize()), "…") //nolint:gosec
 	value := st.StatusBarValue.
 		Width(maxWidth).
 		Render(v)

pkg/ui/pages/repo/filesitem.go 🔗

@@ -101,7 +101,7 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
 	s := d.common.Styles.Tree
 
 	name := i.Title()
-	size := humanize.Bytes(uint64(i.entry.Size()))
+	size := humanize.Bytes(uint64(i.entry.Size())) //nolint:gosec
 	size = strings.ReplaceAll(size, " ", "")
 	sizeLen := lipgloss.Width(size)
 	if i.entry.IsTree() {

pkg/ui/pages/repo/logitem.go 🔗

@@ -130,7 +130,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
 	}
 	who += styles.Desc.Render("on ") + styles.Keyword.Render(date)
 	who = common.TruncateString(who, m.Width()-horizontalFrameSize)
-	fmt.Fprint(w,
+	fmt.Fprint(w, //nolint:errcheck
 		d.common.Zone.Mark(
 			i.ID(),
 			styles.Base.Render(
@@ -138,7 +138,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
 					truncate.String(fmt.Sprintf("%s%s",
 						title,
 						hash,
-					), uint(m.Width()-horizontalFrameSize)),
+					), uint(m.Width()-horizontalFrameSize)), //nolint:gosec
 					who,
 				),
 			),

pkg/ui/pages/repo/refsitem.go 🔗

@@ -191,13 +191,13 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
 			PaddingLeft(1).
 			Render(sha)
 	}
-	fmt.Fprint(w,
+	fmt.Fprint(w, //nolint:errcheck
 		d.common.Zone.Mark(
 			i.ID(),
 			st.Base.Render(
 				lipgloss.JoinHorizontal(lipgloss.Top,
 					truncate.String(selector+ref+desc+hash,
-						uint(m.Width()-horizontalFrameSize)),
+						uint(m.Width()-horizontalFrameSize)), //nolint:gosec
 				),
 			),
 		),

pkg/ui/pages/repo/stashitem.go 🔗

@@ -93,7 +93,7 @@ func (d StashItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
 
 	selector = s.Selector.Render(selector)
 	title := st.Render(item.Title())
-	fmt.Fprint(w, d.common.Zone.Mark(
+	fmt.Fprint(w, d.common.Zone.Mark( //nolint:errcheck
 		item.ID(),
 		common.TruncateString(fmt.Sprintf("%s%s",
 			selector,

pkg/ui/pages/selection/item.go 🔗

@@ -212,7 +212,7 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
 	}
 	cmd = common.TruncateString(cmd, m.Width()-styles.Base.GetHorizontalFrameSize())
 	s.WriteString(cmdStyler(cmd))
-	fmt.Fprint(w,
+	fmt.Fprint(w, //nolint:errcheck
 		d.common.Zone.Mark(i.ID(),
 			styles.Base.Render(s.String()),
 		),

pkg/web/logging.go 🔗

@@ -81,7 +81,7 @@ func NewLoggingMiddleware(next http.Handler, logger *log.Logger) http.Handler {
 		elapsed := time.Since(start)
 		logger.Debug("response",
 			"status", fmt.Sprintf("%d %s", writer.code, http.StatusText(writer.code)),
-			"bytes", humanize.Bytes(uint64(writer.bytes)),
+			"bytes", humanize.Bytes(uint64(writer.bytes)), //nolint:gosec
 			"time", elapsed)
 	})
 }

pkg/webhook/webhook.go 🔗

@@ -59,7 +59,7 @@ func SendWebhook(ctx context.Context, w models.Webhook, event Event, payload int
 	dbx := db.FromContext(ctx)
 	datastore := store.FromContext(ctx)
 
-	contentType := ContentType(w.ContentType)
+	contentType := ContentType(w.ContentType) //nolint:gosec
 	switch contentType {
 	case ContentTypeJSON:
 		if err := json.NewEncoder(&buf).Encode(payload); err != nil {