Fix all exhaustive switch case issues and some godot/nolintlint issues

copilot-swe-agent[bot] and caarlos0 created

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

Change summary

cmd/soft/browse/browse.go           |  4 ++++
git/patch.go                        |  2 +-
pkg/config/config.go                |  2 +-
pkg/lfs/basic_transfer.go           | 10 +++++-----
pkg/lfs/client.go                   |  8 ++++----
pkg/ssh/ui.go                       |  4 ++++
pkg/ui/pages/repo/files.go          | 14 ++++++++++++++
pkg/ui/pages/repo/log.go            | 12 +++++++++++-
pkg/ui/pages/repo/stash.go          |  6 ++++++
pkg/ui/pages/selection/selection.go |  6 ++++++
pkg/web/git.go                      |  2 +-
pkg/webhook/repository.go           |  2 ++
12 files changed, 59 insertions(+), 13 deletions(-)

Detailed changes

cmd/soft/browse/browse.go 🔗

@@ -109,6 +109,8 @@ func (m model) ShortHelp() []key.Binding {
 			m.common.KeyMap.Quit,
 			m.common.KeyMap.Help,
 		}
+	case startState:
+		return m.model.ShortHelp()
 	default:
 		return m.model.ShortHelp()
 	}
@@ -127,6 +129,8 @@ func (m model) FullHelp() [][]key.Binding {
 				m.common.KeyMap.Help,
 			},
 		}
+	case startState:
+		return m.model.FullHelp()
 	default:
 		return m.model.FullHelp()
 	}

git/patch.go 🔗

@@ -136,7 +136,7 @@ func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange) {
 	return
 }
 
-// FileStats
+// FileStats.
 type FileStats []*DiffFile
 
 // String returns a string representation of file stats.

pkg/config/config.go 🔗

@@ -307,7 +307,7 @@ func DefaultDataPath() string {
 }
 
 // ConfigPath returns the path to the config file.
-func (c *Config) ConfigPath() string { //nolint:revive
+func (c *Config) ConfigPath() string {
 	// If we have a custom config location set, then use that.
 	if path := os.Getenv("SOFT_SERVE_CONFIG_LOCATION"); exist(path) {
 		return path

pkg/lfs/basic_transfer.go 🔗

@@ -12,17 +12,17 @@ import (
 	"github.com/charmbracelet/log/v2"
 )
 
-// BasicTransferAdapter implements the "basic" adapter
+// BasicTransferAdapter implements the "basic" adapter.
 type BasicTransferAdapter struct {
 	client *http.Client
 }
 
-// Name returns the name of the adapter
+// Name returns the name of the adapter.
 func (a *BasicTransferAdapter) Name() string {
 	return "basic"
 }
 
-// Download reads the download location and downloads the data
+// Download reads the download location and downloads the data.
 func (a *BasicTransferAdapter) Download(ctx context.Context, _ Pointer, l *Link) (io.ReadCloser, error) {
 	resp, err := a.performRequest(ctx, "GET", l, nil, nil)
 	if err != nil {
@@ -31,7 +31,7 @@ func (a *BasicTransferAdapter) Download(ctx context.Context, _ Pointer, l *Link)
 	return resp.Body, nil
 }
 
-// Upload sends the content to the LFS server
+// Upload sends the content to the LFS server.
 func (a *BasicTransferAdapter) Upload(ctx context.Context, p Pointer, r io.Reader, l *Link) error {
 	res, err := a.performRequest(ctx, "PUT", l, r, func(req *http.Request) {
 		if len(req.Header.Get("Content-Type")) == 0 {
@@ -50,7 +50,7 @@ func (a *BasicTransferAdapter) Upload(ctx context.Context, p Pointer, r io.Reade
 	return res.Body.Close()
 }
 
-// Verify calls the verify handler on the LFS server
+// Verify calls the verify handler on the LFS server.
 func (a *BasicTransferAdapter) Verify(ctx context.Context, p Pointer, l *Link) error {
 	logger := log.FromContext(ctx).WithPrefix("lfs")
 	b, err := json.Marshal(p)

pkg/lfs/client.go 🔗

@@ -6,16 +6,16 @@ import (
 )
 
 const (
-	// SchemeHTTP represents the HTTP protocol scheme
+	// SchemeHTTP represents the HTTP protocol scheme.
 	SchemeHTTP = "http"
-	// SchemeHTTPS represents the HTTPS protocol scheme
+	// SchemeHTTPS represents the HTTPS protocol scheme.
 	SchemeHTTPS = "https"
 )
 
-// DownloadCallback gets called for every requested LFS object to process its content
+// DownloadCallback gets called for every requested LFS object to process its content.
 type DownloadCallback func(p Pointer, content io.ReadCloser, objectError error) error
 
-// UploadCallback gets called for every requested LFS object to provide its content
+// UploadCallback gets called for every requested LFS object to provide its content.
 type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error)
 
 // Client is a Git LFS client to communicate with a LFS source API.

pkg/ssh/ui.go 🔗

@@ -91,6 +91,8 @@ func (ui *UI) ShortHelp() []key.Binding {
 		b = append(b, ui.common.KeyMap.Back)
 	case readyState:
 		b = append(b, ui.pages[ui.activePage].ShortHelp()...)
+	case loadingState:
+		// No key bindings while loading
 	}
 	if !ui.IsFiltering() {
 		b = append(b, ui.common.KeyMap.Quit)
@@ -107,6 +109,8 @@ func (ui *UI) FullHelp() [][]key.Binding {
 		b = append(b, []key.Binding{ui.common.KeyMap.Back})
 	case readyState:
 		b = append(b, ui.pages[ui.activePage].FullHelp()...)
+	case loadingState:
+		// No key bindings while loading
 	}
 	h := []key.Binding{
 		ui.common.KeyMap.Help,

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

@@ -268,6 +268,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		switch f.activeView {
 		case filesViewFiles, filesViewContent:
 			cmds = append(cmds, f.deselectItemCmd())
+		case filesViewLoading:
+			// Do nothing while loading
 		}
 	case tea.KeyPressMsg:
 		switch f.activeView {
@@ -303,6 +305,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 				f.code.UseGlamour = !f.code.UseGlamour
 				cmds = append(cmds, f.code.SetContent(f.currentContent.content, f.currentContent.ext))
 			}
+		case filesViewLoading:
+			// No key handling while loading
 		}
 	case tea.WindowSizeMsg:
 		f.SetSize(msg.Width, msg.Height)
@@ -319,6 +323,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					cmds = append(cmds, cmd)
 				}
 			}
+		case filesViewLoading:
+			// Do nothing while loading
 		}
 	case EmptyRepoMsg:
 		f.ref = nil
@@ -350,6 +356,12 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if cmd != nil {
 			cmds = append(cmds, cmd)
 		}
+	case filesViewLoading:
+		m, cmd := f.spinner.Update(msg)
+		f.spinner = m
+		if cmd != nil {
+			cmds = append(cmds, cmd)
+		}
 	}
 	return f, tea.Batch(cmds...)
 }
@@ -389,6 +401,8 @@ func (f *Files) StatusBarInfo() string {
 		return fmt.Sprintf("# %d/%d", f.selector.Index()+1, len(f.selector.VisibleItems()))
 	case filesViewContent:
 		return common.ScrollPercent(f.code.ScrollPosition())
+	case filesViewLoading:
+		return "Loading..."
 	default:
 		return ""
 	}

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

@@ -88,8 +88,10 @@ func (l *Log) Path() string {
 	switch l.activeView {
 	case logViewCommits:
 		return ""
-	default:
+	case logViewLoading, logViewDiff:
 		return "diff" // XXX: this is a place holder and doesn't mean anything
+	default:
+		return "diff"
 	}
 }
 
@@ -126,6 +128,8 @@ func (l *Log) ShortHelp() []key.Binding {
 			l.common.KeyMap.GotoTop,
 			l.common.KeyMap.GotoBottom,
 		}
+	case logViewLoading:
+		return []key.Binding{}
 	default:
 		return []key.Binding{}
 	}
@@ -178,6 +182,8 @@ func (l *Log) FullHelp() [][]key.Binding {
 				l.common.KeyMap.GotoBottom,
 			},
 		}...)
+	case logViewLoading:
+		// No key bindings while loading
 	}
 	return b
 }
@@ -264,6 +270,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					}
 				}
 			}
+		case logViewLoading:
+			// No key handling while loading
 		}
 	case GoBackMsg:
 		l.goBack()
@@ -342,6 +350,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if cmd != nil {
 			cmds = append(cmds, cmd)
 		}
+	case logViewLoading, logViewCommits:
+		// No additional viewport updates needed
 	}
 	return l, tea.Batch(cmds...)
 }

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

@@ -129,6 +129,8 @@ func (s *Stash) StatusBarInfo() string {
 		return fmt.Sprintf("p. %d/%d", s.list.Page()+1, totalPages)
 	case stashStatePatch:
 		return common.ScrollPercent(s.code.ScrollPosition())
+	case stashStateLoading:
+		return "Loading..."
 	default:
 		return ""
 	}
@@ -184,6 +186,8 @@ func (s *Stash) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					cmds = append(cmds, copyCmd(patch.Patch(), "Stash patch copied to clipboard"))
 				}
 			}
+		case stashStateLoading:
+			// No key handling while loading
 		}
 	case StashListMsg:
 		s.state = stashStateList
@@ -230,6 +234,8 @@ func (s *Stash) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if cmd != nil {
 			cmds = append(cmds, cmd)
 		}
+	case stashStateLoading:
+		// No updates while loading
 	}
 	return s, tea.Batch(cmds...)
 }

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

@@ -176,6 +176,8 @@ func (s *Selection) FullHelp() [][]key.Binding {
 			k.CancelWhileFiltering,
 			k.AcceptWhileFiltering,
 		})
+	case lastPane:
+		// lastPane is not a real pane, used for bounds checking
 	}
 	return b
 }
@@ -279,6 +281,8 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if cmd != nil {
 			cmds = append(cmds, cmd)
 		}
+	case lastPane:
+		// lastPane is not a real pane, no updates needed
 	}
 	return s, tea.Batch(cmds...)
 }
@@ -306,6 +310,8 @@ func (s *Selection) View() string {
 			s.readme.View(),
 			readmeStatus,
 		))
+	case lastPane:
+		// lastPane is not a real pane, no view
 	}
 	if s.activePane != selectorPane || s.FilterState() != list.Filtering {
 		tabs := s.common.Styles.Tabs.Render(s.tabs.View())

pkg/web/git.go 🔗

@@ -461,7 +461,7 @@ type flushResponseWriter struct {
 }
 
 func (f *flushResponseWriter) ReadFrom(r io.Reader) (int64, error) {
-	flusher := http.NewResponseController(f.ResponseWriter) //nolint: bodyclose
+	flusher := http.NewResponseController(f.ResponseWriter)
 
 	var n int64
 	p := make([]byte, 1024)

pkg/webhook/repository.go 🔗

@@ -37,6 +37,8 @@ func NewRepositoryEvent(ctx context.Context, user proto.User, repo proto.Reposit
 	switch action {
 	case RepositoryEventActionVisibilityChange:
 		event = EventRepositoryVisibilityChange
+	case RepositoryEventActionDelete, RepositoryEventActionRename, RepositoryEventActionDefaultBranchChange:
+		event = EventRepository
 	default:
 		event = EventRepository
 	}