Fix unparam and revive linting issues - unused params, comment styles, package docs

copilot-swe-agent[bot] and caarlos0 created

Co-authored-by: caarlos0 <245435+caarlos0@users.noreply.github.com>

Change summary

git/patch.go                   |  4 ++--
git/repo.go                    |  2 +-
pkg/access/access.go           |  1 +
pkg/cron/cron.go               |  2 +-
pkg/daemon/daemon.go           |  2 +-
pkg/daemon/daemon_test.go      | 11 +++++------
pkg/db/context.go              |  1 +
pkg/log/log.go                 |  1 +
pkg/proto/access_token.go      |  1 +
pkg/ssh/session_test.go        |  4 ++--
pkg/ssh/ssh.go                 |  2 +-
pkg/ui/common/component.go     |  2 +-
pkg/ui/keymap/keymap.go        |  1 +
pkg/ui/pages/selection/item.go |  2 +-
testscript/script_test.go      | 10 +++++-----
15 files changed, 25 insertions(+), 21 deletions(-)

Detailed changes

git/patch.go 🔗

@@ -136,7 +136,7 @@ func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange) {
 	return
 }
 
-// FileStats.
+// FileStats represents statistics for changed files in a diff.
 type FileStats []*DiffFile
 
 // String returns a string representation of file stats.
@@ -237,7 +237,7 @@ type Diff struct {
 	Files []*DiffFile
 }
 
-// FileStats returns the diff file stats.
+// Stats returns the diff file stats.
 func (d *Diff) Stats() FileStats {
 	return d.Files
 }

git/repo.go 🔗

@@ -8,7 +8,7 @@ import (
 )
 
 var (
-	// DiffMaxFile is the maximum number of files to show in a diff.
+	// DiffMaxFiles is the maximum number of files to show in a diff.
 	DiffMaxFiles = 1000
 	// DiffMaxFileLines is the maximum number of lines to show in a file diff.
 	DiffMaxFileLines = 1000

pkg/access/access.go 🔗

@@ -1,3 +1,4 @@
+// Package access defines access control levels and permissions for repositories and users.
 package access
 
 import (

pkg/cron/cron.go 🔗

@@ -37,7 +37,7 @@ func NewScheduler(ctx context.Context) *Scheduler {
 	}
 }
 
-// Shutdonw gracefully shuts down the Scheduler.
+// Shutdown gracefully shuts down the Scheduler.
 func (s *Scheduler) Shutdown() {
 	ctx, cancel := context.WithTimeout(s.Cron.Stop(), 30*time.Second)
 	defer func() { cancel() }()

pkg/daemon/daemon.go 🔗

@@ -58,7 +58,7 @@ type GitDaemon struct {
 	liMu      sync.Mutex
 }
 
-// NewDaemon returns a new Git daemon.
+// NewGitDaemon returns a new Git daemon.
 func NewGitDaemon(ctx context.Context) (*GitDaemon, error) {
 	cfg := config.FromContext(ctx)
 	addr := cfg.Git.ListenAddr

pkg/daemon/daemon_test.go 🔗

@@ -6,7 +6,6 @@ import (
 	"log"
 	"net"
 	"os"
-	"strings"
 	"testing"
 	"time"
 
@@ -86,7 +85,7 @@ func TestIdleTimeout(t *testing.T) {
 		time.Sleep(10 * time.Millisecond)
 	}
 	time.Sleep(2 * time.Second)
-	_, err = readPktline(c)
+	err = readPktline(c)
 	if err == nil {
 		t.Errorf("expected error, got nil")
 	}
@@ -100,16 +99,16 @@ func TestInvalidRepo(t *testing.T) {
 	if err := pktline.NewEncoder(c).EncodeString("git-upload-pack /test.git\x00"); err != nil {
 		t.Fatalf("expected nil, got error: %v", err)
 	}
-	_, err = readPktline(c)
+	err = readPktline(c)
 	if err != nil && err.Error() != git.ErrInvalidRepo.Error() {
 		t.Errorf("expected %q error, got %q", git.ErrInvalidRepo, err)
 	}
 }
 
-func readPktline(c net.Conn) (string, error) {
+func readPktline(c net.Conn) error {
 	pktout := pktline.NewScanner(c)
 	if !pktout.Scan() {
-		return "", pktout.Err()
+		return pktout.Err()
 	}
-	return strings.TrimSpace(string(pktout.Bytes())), nil
+	return nil
 }

pkg/db/context.go 🔗

@@ -1,3 +1,4 @@
+// Package db provides database interface and connection management for Soft Serve.
 package db
 
 import "context"

pkg/log/log.go 🔗

@@ -1,3 +1,4 @@
+// Package log provides logging functionality and context-aware logging utilities.
 package log
 
 import (

pkg/proto/access_token.go 🔗

@@ -1,3 +1,4 @@
+// Package proto defines protocol buffer-like interfaces and data structures for the Soft Serve API.
 package proto
 
 import "time"

pkg/ssh/session_test.go 🔗

@@ -28,7 +28,7 @@ func TestSession(t *testing.T) {
 	is := is.New(t)
 	t.Run("authorized repo access", func(t *testing.T) {
 		t.Log("setting up")
-		s, close := setup(t)
+		s, cleanup := setup(t)
 		s.Stderr = os.Stderr
 		t.Log("requesting pty")
 		err := s.RequestPty("xterm", 80, 40, nil)
@@ -43,7 +43,7 @@ func TestSession(t *testing.T) {
 		var ee *gossh.ExitMissingError
 		is.True(errors.As(err, &ee))
 		t.Log("session exited")
-		is.NoErr(close())
+		is.NoErr(cleanup())
 	})
 }
 

pkg/ssh/ssh.go 🔗

@@ -162,7 +162,7 @@ func initializePermissions(ctx ssh.Context) {
 	}
 }
 
-// PublicKeyAuthHandler handles public key authentication.
+// PublicKeyHandler handles public key authentication.
 func (s *SSHServer) PublicKeyHandler(ctx ssh.Context, pk ssh.PublicKey) (allowed bool) {
 	if pk == nil {
 		return false

pkg/ui/common/component.go 🔗

@@ -13,7 +13,7 @@ type Component interface {
 	SetSize(width, height int)
 }
 
-// TabComponenet represents a model that is mounted to a tab.
+// TabComponent represents a model that is mounted to a tab.
 // TODO: find a better name.
 type TabComponent interface {
 	Component

pkg/ui/keymap/keymap.go 🔗

@@ -1,3 +1,4 @@
+// Package keymap defines key bindings and keyboard shortcuts for the TUI.
 package keymap
 
 import "github.com/charmbracelet/bubbles/v2/key"

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

@@ -52,7 +52,7 @@ type Item struct {
 	cmd        string
 }
 
-// New creates a new Item.
+// NewItem creates a new Item.
 func NewItem(c common.Common, repo proto.Repository) (Item, error) {
 	var lastUpdate *time.Time
 	lu := repo.UpdatedAt()

testscript/script_test.go 🔗

@@ -351,11 +351,11 @@ func check(ts *testscript.TestScript, err error, neg bool) {
 	}
 }
 
-func cmdReadfile(ts *testscript.TestScript, neg bool, args []string) {
+func cmdReadfile(ts *testscript.TestScript, neg bool, args []string) { //nolint:unparam
 	ts.Stdout().Write([]byte(ts.ReadFile(args[0])))
 }
 
-func cmdEnvfile(ts *testscript.TestScript, neg bool, args []string) {
+func cmdEnvfile(ts *testscript.TestScript, neg bool, args []string) { //nolint:unparam
 	if len(args) < 1 {
 		ts.Fatalf("usage: envfile key=file...")
 	}
@@ -481,7 +481,7 @@ func cmdCurl(ts *testscript.TestScript, neg bool, args []string) {
 	check(ts, cmd.Execute(), neg)
 }
 
-func cmdEnsureServerRunning(ts *testscript.TestScript, neg bool, args []string) {
+func cmdEnsureServerRunning(ts *testscript.TestScript, neg bool, args []string) { //nolint:unparam
 	if len(args) < 1 {
 		ts.Fatalf("Must supply a TCP port of one of the services to connect to. " +
 			"These are set as env vars as they are randomized. " +
@@ -507,7 +507,7 @@ func cmdEnsureServerRunning(ts *testscript.TestScript, neg bool, args []string)
 	}
 }
 
-func cmdEnsureServerNotRunning(ts *testscript.TestScript, neg bool, args []string) {
+func cmdEnsureServerNotRunning(ts *testscript.TestScript, neg bool, args []string) { //nolint:unparam
 	if len(args) < 1 {
 		ts.Fatalf("Must supply a TCP port of one of the services to connect to. " +
 			"These are set as env vars as they are randomized. " +
@@ -533,7 +533,7 @@ func cmdEnsureServerNotRunning(ts *testscript.TestScript, neg bool, args []strin
 	}
 }
 
-func cmdStopserver(ts *testscript.TestScript, neg bool, args []string) {
+func cmdStopserver(ts *testscript.TestScript, neg bool, args []string) { //nolint:unparam
 	// stop the server
 	resp, err := http.DefaultClient.Head(fmt.Sprintf("%s/__stop", ts.Getenv("SOFT_SERVE_HTTP_PUBLIC_URL")))
 	check(ts, err, neg)