Fix code analyzer warnings

This commit is contained in:
Ryan McGuire 2024-12-30 13:20:27 -05:00
parent 5f9cc58ef7
commit 888ee5ea4a
5 changed files with 8 additions and 7 deletions

View File

@ -156,7 +156,7 @@ func fzfProjectFromProjects(opts *fzfProjectOpts, projects []*projects.Project)
return projects[i], nil return projects[i], nil
} }
func fzfPreviewWindow(i, w, h int) string { func fzfPreviewWindow(i, _, _ int) string {
p := projectCache.Projects[i] p := projectCache.Projects[i]
return projectCache.ProjectString(p) return projectCache.ProjectString(p)
} }

View File

@ -67,11 +67,10 @@ func (c *Cache) LockCache() {
c.checkLock() c.checkLock()
file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640) file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
defer file.Close()
if err != nil { if err != nil {
c.log.Fatal("Failed to lock cache", c.log.Args("error", err)) c.log.Fatal("Failed to lock cache", c.log.Args("error", err))
} }
file.Close()
} }
func (c *Cache) checkLock() { func (c *Cache) checkLock() {

View File

@ -3,8 +3,9 @@ package cache
import ( import (
"errors" "errors"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
) )
func (c *Cache) deleteAlias(alias *ProjectAlias) { func (c *Cache) deleteAlias(alias *ProjectAlias) {
@ -23,7 +24,7 @@ func (c *Cache) DeleteAlias(alias *ProjectAlias) {
func (c *Cache) addAlias(alias string, projectID int, remote string) error { func (c *Cache) addAlias(alias string, projectID int, remote string) error {
if c.GetAliasByName(alias) != nil { if c.GetAliasByName(alias) != nil {
return errors.New("Failed to add alias, already exists") return errors.New("failed to add alias, already exists")
} }
c.Aliases = append(c.Aliases, c.Aliases = append(c.Aliases,

View File

@ -32,7 +32,7 @@ func (c *Cache) GetProjectFromCwd() (*projects.Project, error) {
if err != nil { if err != nil {
return project, err return project, err
} else if !strings.HasPrefix(cwd, c.path) { } else if !strings.HasPrefix(cwd, c.path) {
return project, errors.New("Not in any project path") return project, errors.New("not in any project path")
} }
// Strip projects dir from path // Strip projects dir from path

View File

@ -5,6 +5,7 @@ import (
"time" "time"
git "github.com/go-git/go-git/v5" git "github.com/go-git/go-git/v5"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects" "gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
) )
@ -31,7 +32,7 @@ func (c *Cache) OpenProject(ctx context.Context, project *projects.Project) *git
// Check to make sure we can connect before we time out // Check to make sure we can connect before we time out
// shouldn't be necessary, but go-git does not properly // shouldn't be necessary, but go-git does not properly
// honor its context // honor its context
if err := project.CheckHost(projects.GitProtoSSH); err != nil { if err = project.CheckHost(projects.GitProtoSSH); err != nil {
c.log.Fatal("Git remote unreachable, giving up", c.log.Args("error", err)) c.log.Fatal("Git remote unreachable, giving up", c.log.Args("error", err))
} }