c6985ddf3dcef0ac81aea08aa6de49046a59a1dd

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: lint issues

Diff

  1diff --git a/git/tree.go b/git/tree.go
  2index d5fbe96f7a1582835b49c131f10b60a59bd44967..7bf5b4d26b64007568cc1f9ae39550b470161511 100644
  3--- a/git/tree.go
  4+++ b/git/tree.go
  5@@ -170,7 +170,7 @@ func (e *TreeEntry) Mode() fs.FileMode {
  6 	case git.EntryTree:
  7 		return fs.ModeDir | fs.ModePerm
  8 	default:
  9-		return fs.FileMode(m)
 10+		return fs.FileMode(m) //nolint:gosec
 11 	}
 12 }
 13 
 14diff --git a/pkg/backend/repo.go b/pkg/backend/repo.go
 15index a4a087fe5a78b3ab4ed0c3a1a38b0505cb432284..bacc8993848b638d4090b79e9f50a348446aa99a 100644
 16--- a/pkg/backend/repo.go
 17+++ b/pkg/backend/repo.go
 18@@ -742,7 +742,7 @@ func (r *repo) writeLastModified(t time.Time) error {
 19 		return err
 20 	}
 21 
 22-	return os.WriteFile(fp, []byte(t.Format(time.RFC3339)), os.ModePerm)
 23+	return os.WriteFile(fp, []byte(t.Format(time.RFC3339)), os.ModePerm) //nolint:gosec
 24 }
 25 
 26 func readOneline(path string) (string, error) {
 27diff --git a/pkg/backend/webhooks.go b/pkg/backend/webhooks.go
 28index 78126b2ee84e8f49c93cba422af3c7e588f62195..e8e1fe9224f5b2bde6e7cae237599b7912fbcee4 100644
 29--- a/pkg/backend/webhooks.go
 30+++ b/pkg/backend/webhooks.go
 31@@ -54,7 +54,7 @@ func (b *Backend) Webhook(ctx context.Context, repo proto.Repository, id int64)
 32 
 33 		wh = webhook.Hook{
 34 			Webhook:     h,
 35-			ContentType: webhook.ContentType(h.ContentType),
 36+			ContentType: webhook.ContentType(h.ContentType), //nolint:gosec
 37 			Events:      make([]webhook.Event, len(events)),
 38 		}
 39 		for i, e := range events {
 40@@ -105,7 +105,7 @@ func (b *Backend) ListWebhooks(ctx context.Context, repo proto.Repository) ([]we
 41 
 42 		hooks[i] = webhook.Hook{
 43 			Webhook:     h,
 44-			ContentType: webhook.ContentType(h.ContentType),
 45+			ContentType: webhook.ContentType(h.ContentType), //nolint:gosec
 46 			Events:      events,
 47 		}
 48 	}
 49diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go
 50index e4e6340d91ea604a347b284ddd238d2d097e2f52..a5156355e3362162ca8f958b232a4e5709c79751 100644
 51--- a/pkg/daemon/daemon.go
 52+++ b/pkg/daemon/daemon.go
 53@@ -109,7 +109,7 @@ func (d *GitDaemon) Serve(listener net.Listener) error {
 54 				} else {
 55 					tempDelay *= 2
 56 				}
 57-				if max := 1 * time.Second; tempDelay > max {
 58+				if max := 1 * time.Second; tempDelay > max { //nolint:revive
 59 					tempDelay = max
 60 				}
 61 				time.Sleep(tempDelay)
 62diff --git a/pkg/hooks/gen.go b/pkg/hooks/gen.go
 63index 9e445040a26207b838c6e2d7ad45a820e492f1ec..245e5eb69fe4844c19c721cd7573ff723b9b0aab 100644
 64--- a/pkg/hooks/gen.go
 65+++ b/pkg/hooks/gen.go
 66@@ -48,7 +48,7 @@ func GenerateHooks(_ context.Context, cfg *config.Config, repo string) error {
 67 		hp := filepath.Join(hooksPath, hook)
 68 
 69 		// Write the hooks primary script
 70-		if err := os.WriteFile(hp, []byte(hookTemplate), os.ModePerm); err != nil {
 71+		if err := os.WriteFile(hp, []byte(hookTemplate), os.ModePerm); err != nil { //nolint:gosec
 72 			return err
 73 		}
 74 
 75diff --git a/pkg/ssh/cmd/tree.go b/pkg/ssh/cmd/tree.go
 76index aec94e9165d6375058fa800a9474c6576579baf2..e5fc5fe5e05bf8164665654d28fbdf5cbf145b1f 100644
 77--- a/pkg/ssh/cmd/tree.go
 78+++ b/pkg/ssh/cmd/tree.go
 79@@ -92,7 +92,7 @@ func treeCommand() *cobra.Command {
 80 				if size == 0 {
 81 					ssize = "-"
 82 				} else {
 83-					ssize = humanize.Bytes(uint64(size))
 84+					ssize = humanize.Bytes(uint64(size)) //nolint:gosec
 85 				}
 86 				cmd.Printf("%s\t%s\t %s\n", ent.Mode(), ssize, common.UnquoteFilename(ent.Name()))
 87 			}
 88diff --git a/pkg/ssh/cmd/webhooks.go b/pkg/ssh/cmd/webhooks.go
 89index 0b894a58e63ec4b5fcb74616c03850f96d7f1720..e7409ebbaeafd43b2ad37c48695d2ab1729bccf7 100644
 90--- a/pkg/ssh/cmd/webhooks.go
 91+++ b/pkg/ssh/cmd/webhooks.go
 92@@ -361,34 +361,34 @@ func webhookDeliveriesGetCommand() *cobra.Command {
 93 			}
 94 
 95 			out := cmd.OutOrStdout()
 96-			fmt.Fprintf(out, "ID: %s\n", del.ID)
 97-			fmt.Fprintf(out, "Event: %s\n", del.Event)
 98-			fmt.Fprintf(out, "Request URL: %s\n", del.RequestURL)
 99-			fmt.Fprintf(out, "Request Method: %s\n", del.RequestMethod)
100-			fmt.Fprintf(out, "Request Error: %s\n", del.RequestError.String)
101-			fmt.Fprintf(out, "Request Headers:\n")
102+			fmt.Fprintf(out, "ID: %s\n", del.ID)                             //nolint:errcheck
103+			fmt.Fprintf(out, "Event: %s\n", del.Event)                       //nolint:errcheck
104+			fmt.Fprintf(out, "Request URL: %s\n", del.RequestURL)            //nolint:errcheck
105+			fmt.Fprintf(out, "Request Method: %s\n", del.RequestMethod)      //nolint:errcheck
106+			fmt.Fprintf(out, "Request Error: %s\n", del.RequestError.String) //nolint:errcheck
107+			fmt.Fprintf(out, "Request Headers:\n")                           //nolint:errcheck
108 			reqHeaders := strings.Split(del.RequestHeaders, "\n")
109 			for _, h := range reqHeaders {
110-				fmt.Fprintf(out, "  %s\n", h)
111+				fmt.Fprintf(out, "  %s\n", h) //nolint:errcheck
112 			}
113 
114-			fmt.Fprintf(out, "Request Body:\n")
115+			fmt.Fprintf(out, "Request Body:\n") //nolint:errcheck
116 			reqBody := strings.Split(del.RequestBody, "\n")
117 			for _, b := range reqBody {
118-				fmt.Fprintf(out, "  %s\n", b)
119+				fmt.Fprintf(out, "  %s\n", b) //nolint:errcheck
120 			}
121 
122-			fmt.Fprintf(out, "Response Status: %d\n", del.ResponseStatus)
123-			fmt.Fprintf(out, "Response Headers:\n")
124+			fmt.Fprintf(out, "Response Status: %d\n", del.ResponseStatus) //nolint:errcheck
125+			fmt.Fprintf(out, "Response Headers:\n")                       //nolint:errcheck
126 			resHeaders := strings.Split(del.ResponseHeaders, "\n")
127 			for _, h := range resHeaders {
128-				fmt.Fprintf(out, "  %s\n", h)
129+				fmt.Fprintf(out, "  %s\n", h) //nolint:errcheck
130 			}
131 
132-			fmt.Fprintf(out, "Response Body:\n")
133+			fmt.Fprintf(out, "Response Body:\n") //nolint:errcheck
134 			resBody := strings.Split(del.ResponseBody, "\n")
135 			for _, b := range resBody {
136-				fmt.Fprintf(out, "  %s\n", b)
137+				fmt.Fprintf(out, "  %s\n", b) //nolint:errcheck
138 			}
139 
140 			return nil
141diff --git a/pkg/ui/common/utils.go b/pkg/ui/common/utils.go
142index dac9ac2f07fb2cd49c2ad92ffe2b0ee03f7c491a..d5b9c91e0a78ed746fa09ddffe6b82909578ffae 100644
143--- a/pkg/ui/common/utils.go
144+++ b/pkg/ui/common/utils.go
145@@ -9,11 +9,11 @@ import (
146 )
147 
148 // TruncateString is a convenient wrapper around truncate.TruncateString.
149-func TruncateString(s string, max int) string {
150+func TruncateString(s string, max int) string { //nolint:revive
151 	if max < 0 {
152-		max = 0
153+		max = 0 //nolint:revive
154 	}
155-	return truncate.StringWithTail(s, uint(max), "…")
156+	return truncate.StringWithTail(s, uint(max), "…") //nolint:gosec
157 }
158 
159 // RepoURL returns the URL of the repository.
160diff --git a/pkg/ui/components/statusbar/statusbar.go b/pkg/ui/components/statusbar/statusbar.go
161index 2b9e18849df6682813756940e01d666608c3199c..20a5735e12da1729616ea9ead98ccfcadfda6a47 100644
162--- a/pkg/ui/components/statusbar/statusbar.go
163+++ b/pkg/ui/components/statusbar/statusbar.go
164@@ -75,7 +75,7 @@ func (s *Model) View() string {
165 	}
166 	branch := st.StatusBarBranch.Render(s.extra)
167 	maxWidth := s.common.Width - w(key) - w(info) - w(branch) - w(help)
168-	v := truncate.StringWithTail(s.value, uint(maxWidth-st.StatusBarValue.GetHorizontalFrameSize()), "…")
169+	v := truncate.StringWithTail(s.value, uint(maxWidth-st.StatusBarValue.GetHorizontalFrameSize()), "…") //nolint:gosec
170 	value := st.StatusBarValue.
171 		Width(maxWidth).
172 		Render(v)
173diff --git a/pkg/ui/pages/repo/filesitem.go b/pkg/ui/pages/repo/filesitem.go
174index a32fcea615308bb8696fc3739533be5107c91807..ca399fa1b74986f152d7005919048f2ab79762e0 100644
175--- a/pkg/ui/pages/repo/filesitem.go
176+++ b/pkg/ui/pages/repo/filesitem.go
177@@ -101,7 +101,7 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
178 	s := d.common.Styles.Tree
179 
180 	name := i.Title()
181-	size := humanize.Bytes(uint64(i.entry.Size()))
182+	size := humanize.Bytes(uint64(i.entry.Size())) //nolint:gosec
183 	size = strings.ReplaceAll(size, " ", "")
184 	sizeLen := lipgloss.Width(size)
185 	if i.entry.IsTree() {
186diff --git a/pkg/ui/pages/repo/logitem.go b/pkg/ui/pages/repo/logitem.go
187index ecdc4f1878c46ad9bc3869b81c69978571b5e3b6..0ff4da6814fd62c8be3fe4e9f4a741ace3cda6ca 100644
188--- a/pkg/ui/pages/repo/logitem.go
189+++ b/pkg/ui/pages/repo/logitem.go
190@@ -130,7 +130,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
191 	}
192 	who += styles.Desc.Render("on ") + styles.Keyword.Render(date)
193 	who = common.TruncateString(who, m.Width()-horizontalFrameSize)
194-	fmt.Fprint(w,
195+	fmt.Fprint(w, //nolint:errcheck
196 		d.common.Zone.Mark(
197 			i.ID(),
198 			styles.Base.Render(
199@@ -138,7 +138,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
200 					truncate.String(fmt.Sprintf("%s%s",
201 						title,
202 						hash,
203-					), uint(m.Width()-horizontalFrameSize)),
204+					), uint(m.Width()-horizontalFrameSize)), //nolint:gosec
205 					who,
206 				),
207 			),
208diff --git a/pkg/ui/pages/repo/refsitem.go b/pkg/ui/pages/repo/refsitem.go
209index 7d109de0c277251d6798b1a6aac8cfdfed082bc3..7bb10d6e94fb4013789f6c4f4c4dfd7935d8d09d 100644
210--- a/pkg/ui/pages/repo/refsitem.go
211+++ b/pkg/ui/pages/repo/refsitem.go
212@@ -191,13 +191,13 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
213 			PaddingLeft(1).
214 			Render(sha)
215 	}
216-	fmt.Fprint(w,
217+	fmt.Fprint(w, //nolint:errcheck
218 		d.common.Zone.Mark(
219 			i.ID(),
220 			st.Base.Render(
221 				lipgloss.JoinHorizontal(lipgloss.Top,
222 					truncate.String(selector+ref+desc+hash,
223-						uint(m.Width()-horizontalFrameSize)),
224+						uint(m.Width()-horizontalFrameSize)), //nolint:gosec
225 				),
226 			),
227 		),
228diff --git a/pkg/ui/pages/repo/stashitem.go b/pkg/ui/pages/repo/stashitem.go
229index cc2d3f3a0f107bad5642452a88e5ce53ab6e1b7b..e6b6a9a822f12310c28b12d7be33e4ce4f517e92 100644
230--- a/pkg/ui/pages/repo/stashitem.go
231+++ b/pkg/ui/pages/repo/stashitem.go
232@@ -93,7 +93,7 @@ func (d StashItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
233 
234 	selector = s.Selector.Render(selector)
235 	title := st.Render(item.Title())
236-	fmt.Fprint(w, d.common.Zone.Mark(
237+	fmt.Fprint(w, d.common.Zone.Mark( //nolint:errcheck
238 		item.ID(),
239 		common.TruncateString(fmt.Sprintf("%s%s",
240 			selector,
241diff --git a/pkg/ui/pages/selection/item.go b/pkg/ui/pages/selection/item.go
242index 4cd12a91dbbf0aa5b4cfa563c41dc2fe9e3a983c..1842d7243ac18ac997861a130d5ffc9efb34d51e 100644
243--- a/pkg/ui/pages/selection/item.go
244+++ b/pkg/ui/pages/selection/item.go
245@@ -212,7 +212,7 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
246 	}
247 	cmd = common.TruncateString(cmd, m.Width()-styles.Base.GetHorizontalFrameSize())
248 	s.WriteString(cmdStyler(cmd))
249-	fmt.Fprint(w,
250+	fmt.Fprint(w, //nolint:errcheck
251 		d.common.Zone.Mark(i.ID(),
252 			styles.Base.Render(s.String()),
253 		),
254diff --git a/pkg/web/logging.go b/pkg/web/logging.go
255index 956ad9e9c160e2e411b7a4510c431ba0c880484d..63b6d35e5b5fcf22308fffc7caefe729832d90d5 100644
256--- a/pkg/web/logging.go
257+++ b/pkg/web/logging.go
258@@ -81,7 +81,7 @@ func NewLoggingMiddleware(next http.Handler, logger *log.Logger) http.Handler {
259 		elapsed := time.Since(start)
260 		logger.Debug("response",
261 			"status", fmt.Sprintf("%d %s", writer.code, http.StatusText(writer.code)),
262-			"bytes", humanize.Bytes(uint64(writer.bytes)),
263+			"bytes", humanize.Bytes(uint64(writer.bytes)), //nolint:gosec
264 			"time", elapsed)
265 	})
266 }
267diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go
268index 8bd28e9c19663e3f7034a99213c3009f3486e391..15d93bb1db3a16485dad1558f516e4a652ae3bb6 100644
269--- a/pkg/webhook/webhook.go
270+++ b/pkg/webhook/webhook.go
271@@ -59,7 +59,7 @@ func SendWebhook(ctx context.Context, w models.Webhook, event Event, payload int
272 	dbx := db.FromContext(ctx)
273 	datastore := store.FromContext(ctx)
274 
275-	contentType := ContentType(w.ContentType)
276+	contentType := ContentType(w.ContentType) //nolint:gosec
277 	switch contentType {
278 	case ContentTypeJSON:
279 		if err := json.NewEncoder(&buf).Encode(payload); err != nil {