mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
Fix linter warnings (#3854)
- **PR Description** Fix some linter warnings that I keep getting locally because I'm running a newer version of golangci-lint than the pinned version we use on CI. Also, update the pinned version in CI to 1.60 so that we are in sync again. Finally, upgrade the golangci-lint-action version to the latest, although I'm not sure what difference this makes. The linting step runs faster now, maybe because of better caching -- I noticed that previously, loading and saving the cache took a very long time, which often made the lint step the slowest of all.
This commit is contained in:
commit
18935bf7f0
10 changed files with 19 additions and 36 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -170,9 +170,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: 1.22.x
|
go-version: 1.22.x
|
||||||
- name: Lint
|
- name: Lint
|
||||||
uses: golangci/golangci-lint-action@v3.7.0
|
uses: golangci/golangci-lint-action@v6.1.0
|
||||||
with:
|
with:
|
||||||
version: v1.58
|
version: v1.60
|
||||||
- name: errors
|
- name: errors
|
||||||
run: golangci-lint run
|
run: golangci-lint run
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
linters:
|
linters:
|
||||||
disable:
|
|
||||||
- structcheck # gives false positives
|
|
||||||
enable:
|
enable:
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- thelper
|
- thelper
|
||||||
- goimports
|
- goimports
|
||||||
- tparallel
|
- tparallel
|
||||||
- wastedassign
|
- wastedassign
|
||||||
- exportloopref
|
|
||||||
- unparam
|
- unparam
|
||||||
- prealloc
|
- prealloc
|
||||||
- unconvert
|
- unconvert
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (self *CachedGitConfig) Get(key string) string {
|
||||||
defer self.mutex.Unlock()
|
defer self.mutex.Unlock()
|
||||||
|
|
||||||
if value, ok := self.cache[key]; ok {
|
if value, ok := self.cache[key]; ok {
|
||||||
self.log.Debugf("using cache for key " + key)
|
self.log.Debug("using cache for key " + key)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (self *CachedGitConfig) GetGeneral(args string) string {
|
||||||
defer self.mutex.Unlock()
|
defer self.mutex.Unlock()
|
||||||
|
|
||||||
if value, ok := self.cache[args]; ok {
|
if value, ok := self.cache[args]; ok {
|
||||||
self.log.Debugf("using cache for args " + args)
|
self.log.Debug("using cache for args " + args)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func (self *CachedGitConfig) getGeneralAux(args string) string {
|
||||||
cmd := getGitConfigGeneralCmd(args)
|
cmd := getGitConfigGeneralCmd(args)
|
||||||
value, err := self.runGitConfigCmd(cmd)
|
value, err := self.runGitConfigCmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.log.Debugf("Error getting git config value for args: " + args + ". Error: " + err.Error())
|
self.log.Debugf("Error getting git config value for args: %s. Error: %v", args, err.Error())
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(value)
|
return strings.TrimSpace(value)
|
||||||
|
@ -79,7 +79,7 @@ func (self *CachedGitConfig) getAux(key string) string {
|
||||||
cmd := getGitConfigCmd(key)
|
cmd := getGitConfigCmd(key)
|
||||||
value, err := self.runGitConfigCmd(cmd)
|
value, err := self.runGitConfigCmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.log.Debugf("Error getting git config value for key: " + key + ". Error: " + err.Error())
|
self.log.Debugf("Error getting git config value for key: %s. Error: %v", key, err.Error())
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(value)
|
return strings.TrimSpace(value)
|
||||||
|
|
|
@ -810,7 +810,7 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
||||||
|
|
||||||
menuItems = append(menuItems, menuItemsForBranch(selectedBranch)...)
|
menuItems = append(menuItems, menuItemsForBranch(selectedBranch)...)
|
||||||
|
|
||||||
return self.c.Menu(types.CreateMenuOptions{Title: fmt.Sprintf(self.c.Tr.CreatePullRequestOptions), Items: menuItems})
|
return self.c.Menu(types.CreateMenuOptions{Title: fmt.Sprint(self.c.Tr.CreatePullRequestOptions), Items: menuItems})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchesController) createPullRequest(from string, to string) error {
|
func (self *BranchesController) createPullRequest(from string, to string) error {
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (self *ConfirmationHelper) getPopupPanelWidth() int {
|
||||||
|
|
||||||
func (self *ConfirmationHelper) prepareConfirmationPanel(
|
func (self *ConfirmationHelper) prepareConfirmationPanel(
|
||||||
opts types.ConfirmOpts,
|
opts types.ConfirmOpts,
|
||||||
) error {
|
) {
|
||||||
self.c.Views().Confirmation.Title = opts.Title
|
self.c.Views().Confirmation.Title = opts.Title
|
||||||
// for now we do not support wrapping in our editor
|
// for now we do not support wrapping in our editor
|
||||||
self.c.Views().Confirmation.Wrap = !opts.Editable
|
self.c.Views().Confirmation.Wrap = !opts.Editable
|
||||||
|
@ -176,8 +176,6 @@ func (self *ConfirmationHelper) prepareConfirmationPanel(
|
||||||
suggestionsView.Title = fmt.Sprintf(self.c.Tr.SuggestionsTitle, self.c.UserConfig().Keybinding.Universal.TogglePanel)
|
suggestionsView.Title = fmt.Sprintf(self.c.Tr.SuggestionsTitle, self.c.UserConfig().Keybinding.Universal.TogglePanel)
|
||||||
suggestionsView.Subtitle = ""
|
suggestionsView.Subtitle = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runeForMask(mask bool) rune {
|
func runeForMask(mask bool) rune {
|
||||||
|
@ -207,7 +205,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
||||||
// remove any previous keybindings
|
// remove any previous keybindings
|
||||||
self.clearConfirmationViewKeyBindings()
|
self.clearConfirmationViewKeyBindings()
|
||||||
|
|
||||||
err := self.prepareConfirmationPanel(
|
self.prepareConfirmationPanel(
|
||||||
types.ConfirmOpts{
|
types.ConfirmOpts{
|
||||||
Title: opts.Title,
|
Title: opts.Title,
|
||||||
Prompt: opts.Prompt,
|
Prompt: opts.Prompt,
|
||||||
|
@ -215,10 +213,6 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
||||||
Editable: opts.Editable,
|
Editable: opts.Editable,
|
||||||
Mask: opts.Mask,
|
Mask: opts.Mask,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
cancel()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
confirmationView := self.c.Views().Confirmation
|
confirmationView := self.c.Views().Confirmation
|
||||||
confirmationView.Editable = opts.Editable
|
confirmationView.Editable = opts.Editable
|
||||||
|
|
||||||
|
@ -232,10 +226,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
||||||
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(underlineLinks(opts.Prompt)))
|
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(underlineLinks(opts.Prompt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.setKeyBindings(cancel, opts); err != nil {
|
self.setKeyBindings(cancel, opts)
|
||||||
cancel()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
self.c.Contexts().Suggestions.State.AllowEditSuggestion = opts.AllowEditSuggestion
|
self.c.Contexts().Suggestions.State.AllowEditSuggestion = opts.AllowEditSuggestion
|
||||||
|
|
||||||
|
@ -266,7 +257,7 @@ func underlineLinks(text string) string {
|
||||||
return result + remaining
|
return result + remaining
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts types.CreatePopupPanelOpts) error {
|
func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts types.CreatePopupPanelOpts) {
|
||||||
var onConfirm func() error
|
var onConfirm func() error
|
||||||
if opts.HandleConfirmPrompt != nil {
|
if opts.HandleConfirmPrompt != nil {
|
||||||
onConfirm = self.wrappedPromptConfirmationFunction(cancel, opts.HandleConfirmPrompt, func() string { return self.c.Views().Confirmation.TextArea.GetContent() })
|
onConfirm = self.wrappedPromptConfirmationFunction(cancel, opts.HandleConfirmPrompt, func() string { return self.c.Views().Confirmation.TextArea.GetContent() })
|
||||||
|
@ -296,8 +287,6 @@ func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts
|
||||||
self.c.Contexts().Suggestions.State.OnConfirm = onSuggestionConfirm
|
self.c.Contexts().Suggestions.State.OnConfirm = onSuggestionConfirm
|
||||||
self.c.Contexts().Suggestions.State.OnClose = onClose
|
self.c.Contexts().Suggestions.State.OnClose = onClose
|
||||||
self.c.Contexts().Suggestions.State.OnDeleteSuggestion = onDeleteSuggestion
|
self.c.Contexts().Suggestions.State.OnDeleteSuggestion = onDeleteSuggestion
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ConfirmationHelper) clearConfirmationViewKeyBindings() {
|
func (self *ConfirmationHelper) clearConfirmationViewKeyBindings() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -60,7 +59,7 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
|
||||||
|
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
self.c.Log.Infof(fmt.Sprintf("Refresh took %s", time.Since(t)))
|
self.c.Log.Infof("Refresh took %s", time.Since(t))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if options.Scope == nil {
|
if options.Scope == nil {
|
||||||
|
@ -114,7 +113,7 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
f()
|
f()
|
||||||
self.c.Log.Infof(fmt.Sprintf("refreshed %s in %s", name, time.Since(t)))
|
self.c.Log.Infof("refreshed %s in %s", name, time.Since(t))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -970,7 +970,7 @@ func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { //nolint:unpara
|
||||||
|
|
||||||
// scan to buffer to prevent run unintentional operations when TUI resumes.
|
// scan to buffer to prevent run unintentional operations when TUI resumes.
|
||||||
var buffer string
|
var buffer string
|
||||||
fmt.Scanln(&buffer) // wait for enter press
|
_, _ = fmt.Scanln(&buffer) // wait for enter press
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -131,11 +131,9 @@ func (self *HandlerCreator) inputPrompt(prompt *config.CustomCommandPrompt, wrap
|
||||||
func (self *HandlerCreator) generateFindSuggestionsFunc(prompt *config.CustomCommandPrompt) (func(string) []*types.Suggestion, error) {
|
func (self *HandlerCreator) generateFindSuggestionsFunc(prompt *config.CustomCommandPrompt) (func(string) []*types.Suggestion, error) {
|
||||||
if prompt.Suggestions.Preset != "" && prompt.Suggestions.Command != "" {
|
if prompt.Suggestions.Preset != "" && prompt.Suggestions.Command != "" {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
fmt.Sprintf(
|
"Custom command prompt cannot have both a preset and a command for suggestions. Preset: '%s', Command: '%s'",
|
||||||
"Custom command prompt cannot have both a preset and a command for suggestions. Preset: '%s', Command: '%s'",
|
prompt.Suggestions.Preset,
|
||||||
prompt.Suggestions.Preset,
|
prompt.Suggestions.Command,
|
||||||
prompt.Suggestions.Command,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
} else if prompt.Suggestions.Preset != "" {
|
} else if prompt.Suggestions.Preset != "" {
|
||||||
return self.getPresetSuggestionsFn(prompt.Suggestions.Preset)
|
return self.getPresetSuggestionsFn(prompt.Suggestions.Preset)
|
||||||
|
|
|
@ -49,7 +49,7 @@ func RunCLI(testNames []string, slow bool, sandbox bool, waitForDebugger bool, r
|
||||||
|
|
||||||
func runAndPrintFatalError(test *components.IntegrationTest, f func() error) {
|
func runAndPrintFatalError(test *components.IntegrationTest, f func() error) {
|
||||||
if err := f(); err != nil {
|
if err := f(); err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,7 @@ func suspendAndRunTest(test *components.IntegrationTest, sandbox bool, waitForDe
|
||||||
runTuiTest(test, sandbox, waitForDebugger, raceDetector, inputDelay)
|
runTuiTest(test, sandbox, waitForDebugger, raceDetector, inputDelay)
|
||||||
|
|
||||||
fmt.Fprintf(os.Stdout, "\n%s", style.FgGreen.Sprint("press enter to return"))
|
fmt.Fprintf(os.Stdout, "\n%s", style.FgGreen.Sprint("press enter to return"))
|
||||||
fmt.Scanln() // wait for enter press
|
_, _ = fmt.Scanln() // wait for enter press
|
||||||
|
|
||||||
if err := gocui.Screen.Resume(); err != nil {
|
if err := gocui.Screen.Resume(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue