summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-08 15:46:35 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-09 14:09:53 +1100
commit18f48a43d5401af97dae18aab07238146b7d587b (patch)
tree5f220bac5ac7210ee5f30c80cba6d396a8f0b18f /pkg/gui
parent5d6d8942862428afb72bc45b562af10ceac6e0a3 (diff)
add some more linters
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commits_panel.go12
-rw-r--r--pkg/gui/credentials_panel.go8
-rw-r--r--pkg/gui/custom_commands.go3
-rw-r--r--pkg/gui/custom_commands_test.go1
-rw-r--r--pkg/gui/files_panel_test.go2
-rw-r--r--pkg/gui/gui.go2
-rw-r--r--pkg/gui/patch_building_panel.go4
-rw-r--r--pkg/gui/presentation/commit_files.go4
-rw-r--r--pkg/gui/presentation/graph/cell.go1
-rw-r--r--pkg/gui/rebase_options_panel.go2
-rw-r--r--pkg/gui/undoing.go4
-rw-r--r--pkg/gui/view_helpers.go4
12 files changed, 28 insertions, 19 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 3817e9e47..fcc49d839 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -79,7 +79,7 @@ func (gui *Gui) refreshReflogCommitsConsideringStartup() {
// whenever we change commits, we should update branches because the upstream/downstream
// counts can change. Whenever we change branches we should probably also change commits
// e.g. in the case of switching branches.
-func (gui *Gui) refreshCommits() error {
+func (gui *Gui) refreshCommits() {
wg := sync.WaitGroup{}
wg.Add(2)
@@ -110,8 +110,6 @@ func (gui *Gui) refreshCommits() error {
})
wg.Wait()
-
- return nil
}
func (gui *Gui) refreshCommitsWithLimit() error {
@@ -605,7 +603,7 @@ func (gui *Gui) createTagMenu(commitSha string) error {
return gui.createMenu(gui.Tr.TagMenuTitle, items, createMenuOptions{showCancel: true})
}
-func (gui *Gui) afterTagCreate(tagName string) error {
+func (gui *Gui) afterTagCreate() error {
gui.State.Panels.Tags.SelectedLineIdx = 0 // Set to the top
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
}
@@ -621,7 +619,7 @@ func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error {
if err := gui.Git.Tag.CreateAnnotated(tagName, commitSha, msg); err != nil {
return gui.surfaceError(err)
}
- return gui.afterTagCreate(tagName)
+ return gui.afterTagCreate()
},
})
},
@@ -636,7 +634,7 @@ func (gui *Gui) handleCreateLightweightTag(commitSha string) error {
if err := gui.Git.Tag.CreateLightweight(tagName, commitSha); err != nil {
return gui.surfaceError(err)
}
- return gui.afterTagCreate(tagName)
+ return gui.afterTagCreate()
},
})
}
@@ -666,7 +664,7 @@ func (gui *Gui) handleCreateCommitResetMenu() error {
return gui.createResetMenu(commit.Sha)
}
-func (gui *Gui) handleOpenSearchForCommitsPanel(_viewName string) error {
+func (gui *Gui) handleOpenSearchForCommitsPanel(string) error {
// we usually lazyload these commits but now that we're searching we need to load them now
if gui.State.Panels.Commits.LimitCommits {
gui.State.Panels.Commits.LimitCommits = false
diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go
index 69c08359f..b4c313e07 100644
--- a/pkg/gui/credentials_panel.go
+++ b/pkg/gui/credentials_panel.go
@@ -11,18 +11,18 @@ import (
type credentials chan string
// promptUserForCredential wait for a username, password or passphrase input from the credentials popup
-func (gui *Gui) promptUserForCredential(passOrUname oscommands.CredentialName) string {
+func (gui *Gui) promptUserForCredential(passOrUname oscommands.CredentialType) string {
gui.credentials = make(chan string)
gui.g.Update(func(g *gocui.Gui) error {
credentialsView := gui.Views.Credentials
switch passOrUname {
- case "username":
+ case oscommands.Username:
credentialsView.Title = gui.Tr.CredentialsUsername
credentialsView.Mask = 0
- case "password":
+ case oscommands.Password:
credentialsView.Title = gui.Tr.CredentialsPassword
credentialsView.Mask = '*'
- case "passphrase":
+ case oscommands.Passphrase:
credentialsView.Title = gui.Tr.CredentialsPassphrase
credentialsView.Mask = '*'
}
diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go
index 7d8cdd281..c55b58a02 100644
--- a/pkg/gui/custom_commands.go
+++ b/pkg/gui/custom_commands.go
@@ -144,7 +144,7 @@ func (gui *Gui) GenerateMenuCandidates(commandOutput, filter, valueFormat, label
}
candidates := []commandMenuEntry{}
- for _, str := range strings.Split(string(commandOutput), "\n") {
+ for _, str := range strings.Split(commandOutput, "\n") {
if str == "" {
continue
}
@@ -216,6 +216,7 @@ func (gui *Gui) menuPromptFromCommand(prompt config.CustomCommandPrompt, promptR
menuItems := make([]*menuItem, len(candidates))
for i := range candidates {
+ i := i
menuItems[i] = &menuItem{
displayStrings: []string{candidates[i].label},
onPress: func() error {
diff --git a/pkg/gui/custom_commands_test.go b/pkg/gui/custom_commands_test.go
index d51617c09..d31bcf291 100644
--- a/pkg/gui/custom_commands_test.go
+++ b/pkg/gui/custom_commands_test.go
@@ -56,6 +56,7 @@ func TestGuiGenerateMenuCandidates(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.test(NewDummyGui().GenerateMenuCandidates(s.cmdOut, s.filter, s.valueFormat, s.labelFormat))
})
diff --git a/pkg/gui/files_panel_test.go b/pkg/gui/files_panel_test.go
index fcf8fe66b..8946898e5 100644
--- a/pkg/gui/files_panel_test.go
+++ b/pkg/gui/files_panel_test.go
@@ -24,7 +24,7 @@ func TestGetSuggestedRemote(t *testing.T) {
}
func mkRemoteList(names ...string) []*models.Remote {
- var result []*models.Remote
+ result := make([]*models.Remote, 0, len(names))
for _, name := range names {
result = append(result, &models.Remote{Name: name})
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 41ccf2283..ded51cd7d 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -648,7 +648,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
return cmdErr == nil, gui.surfaceError(cmdErr)
}
-func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error {
+func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { //nolint:unparam
gui.logCommand(cmdObj.ToString(), true)
subprocess := cmdObj.GetCmd()
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go
index 5f99b42b5..ee1610fb4 100644
--- a/pkg/gui/patch_building_panel.go
+++ b/pkg/gui/patch_building_panel.go
@@ -17,7 +17,7 @@ func (gui *Gui) getFromAndReverseArgsForDiff(to string) (string, bool) {
return from, reverse
}
-func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *LblPanelState) error {
+func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
if !gui.Git.Patch.PatchManager.Active() {
return gui.handleEscapePatchBuildingPanel()
}
@@ -59,7 +59,7 @@ func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error {
gui.Mutexes.LineByLinePanelMutex.Lock()
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
- return gui.refreshPatchBuildingPanel(selectedLineIdx, gui.State.Panels.LineByLine)
+ return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
func (gui *Gui) handleToggleSelectionForPatch() error {
diff --git a/pkg/gui/presentation/commit_files.go b/pkg/gui/presentation/commit_files.go
index 3b68b9eeb..6a351be48 100644
--- a/pkg/gui/presentation/commit_files.go
+++ b/pkg/gui/presentation/commit_files.go
@@ -9,7 +9,7 @@ import (
)
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
- colour := theme.DefaultTextColor
+ var colour style.TextStyle
if diffName == name {
colour = theme.DiffTerminalColor
} else {
@@ -18,6 +18,8 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi
colour = style.FgGreen
case patch.PART:
colour = style.FgYellow
+ case patch.UNSELECTED:
+ colour = theme.DefaultTextColor
}
}
diff --git a/pkg/gui/presentation/graph/cell.go b/pkg/gui/presentation/graph/cell.go
index 9ba7d92fb..e970c6dd2 100644
--- a/pkg/gui/presentation/graph/cell.go
+++ b/pkg/gui/presentation/graph/cell.go
@@ -121,6 +121,7 @@ func (cell *Cell) setLeft(style style.TextStyle) *Cell {
return cell
}
+//nolint:unparam
func (cell *Cell) setRight(style style.TextStyle, override bool) *Cell {
cell.right = true
if cell.rightStyle == nil || override {
diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go
index e3e8ab621..a9e7d9317 100644
--- a/pkg/gui/rebase_options_panel.go
+++ b/pkg/gui/rebase_options_panel.go
@@ -59,6 +59,8 @@ func (gui *Gui) genericMergeCommand(command string) error {
commandType = "merge"
case enums.REBASE_MODE_REBASING:
commandType = "rebase"
+ default:
+ // shouldn't be possible to land here
}
// we should end up with a command like 'git merge --continue'
diff --git a/pkg/gui/undoing.go b/pkg/gui/undoing.go
index 09e1a0328..72a4ef302 100644
--- a/pkg/gui/undoing.go
+++ b/pkg/gui/undoing.go
@@ -110,6 +110,8 @@ func (gui *Gui) reflogUndo() error {
EnvVars: undoEnvVars,
WaitingStatus: undoingStatus,
})
+ case CURRENT_REBASE:
+ // do nothing
}
gui.Log.Error("didn't match on the user action when trying to undo")
@@ -146,6 +148,8 @@ func (gui *Gui) reflogRedo() error {
EnvVars: redoEnvVars,
WaitingStatus: redoingStatus,
})
+ case CURRENT_REBASE:
+ // do nothing
}
gui.Log.Error("didn't match on the user action when trying to redo")
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 3401ce81b..00b28b45c 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -114,9 +114,9 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
wg.Add(1)
func() {
if options.mode == ASYNC {
- go utils.Safe(func() { _ = gui.refreshCommits() })
+ go utils.Safe(func() { gui.refreshCommits() })
} else {
- _ = gui.refreshCommits()
+ gui.refreshCommits()
}
wg.Done()
}()