Skip to content

Commit

Permalink
fix: enable recvcheck linter (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobe4 authored Jan 2, 2025
1 parent 776e96e commit 2ea3095
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ linters:
- nestif
- paralleltest
- predeclared
- recvcheck
- revive
- whitespace
- wrapcheck
Expand Down
20 changes: 10 additions & 10 deletions internal/manager/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const (
PreventRefresh
)

func (r RefreshStrategy) String() string {
switch r {
func (r *RefreshStrategy) String() string {
switch *r {
case AutoRefresh:
return "auto"
case ForceRefresh:
Expand All @@ -37,8 +37,8 @@ func (r *RefreshStrategy) Allowed() string {
return "auto, force, prevent"
}

func (r RefreshStrategy) ShouldRefresh(expired bool) bool {
switch r {
func (r *RefreshStrategy) ShouldRefresh(expired bool) bool {
switch *r {

case ForceRefresh:
slog.Info("forcing a refresh")
Expand Down Expand Up @@ -71,7 +71,7 @@ func (r *RefreshStrategy) Set(value string) error {
return nil
}

func (r RefreshStrategy) Type() string {
func (r *RefreshStrategy) Type() string {
return "RefreshStrategy"
}

Expand All @@ -92,11 +92,11 @@ const (
ForceEnrich
)

func (r ForceStrategy) Has(s ForceStrategy) bool {
return r&s != 0
func (r *ForceStrategy) Has(s ForceStrategy) bool {
return *r&s != 0
}

func (r ForceStrategy) String() string {
func (r *ForceStrategy) String() string {
s := []string{}

if r.Has(ForceApply) {
Expand All @@ -114,7 +114,7 @@ func (r ForceStrategy) String() string {
return strings.Join(s, ", ")
}

func (r ForceStrategy) Allowed() string {
func (r *ForceStrategy) Allowed() string {
return "apply, noop, enrich"
}

Expand All @@ -137,6 +137,6 @@ func (r *ForceStrategy) Set(value string) error {
return nil
}

func (r ForceStrategy) Type() string {
func (r *ForceStrategy) Type() string {
return "ForceStrategy"
}
8 changes: 4 additions & 4 deletions internal/repl/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (CleanListMsg) apply(m model) (tea.Model, tea.Cmd) {
)
}

func (m *model) handleCommand(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m model) handleCommand(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
switch {
case key.Matches(msg, m.keymap.CommandAccept):
return m.acceptCommand()
Expand All @@ -65,7 +65,7 @@ func (m *model) handleCommand(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, cmd
}

func (m *model) handleResult(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m model) handleResult(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
switch {

case key.Matches(msg, m.list.KeyMap.ShowFullHelp):
Expand All @@ -82,7 +82,7 @@ func (m *model) handleResult(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, cmd
}

func (m *model) handleBrowsing(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m model) handleBrowsing(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
slog.Debug("browsing", "key", msg.String())

switch {
Expand Down Expand Up @@ -136,7 +136,7 @@ func (m model) setIndexes() tea.Cmd {
return tea.Batch(cmds...)
}

func (m *model) handleFiltering(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m model) handleFiltering(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
slog.Debug("filtering", "key", msg.String())

var cmd tea.Cmd
Expand Down
4 changes: 3 additions & 1 deletion internal/repl/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (k Keymap) FullHelp() [][]key.Binding {
}
}

func (m *model) initKeymap(keymap config.Keymap) {
func (m model) initKeymap(keymap config.Keymap) model {
m.keymap = Keymap{
Toggle: keymap.Binding("normal", "toggle selected"),
All: keymap.Binding("normal", "select all"),
Expand Down Expand Up @@ -62,6 +62,8 @@ func (m *model) initKeymap(keymap config.Keymap) {
PageDown: keymap.Binding("normal", "next page"),
PageUp: keymap.Binding("normal", "previous page"),
}

return m
}

type ViewportKeymap struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func Init(n notifications.Notifications, actions actions.ActionsMap, keymap conf
}

m.list.SetItems(items)
m.initView()
m.initKeymap(keymap)
m = m.initView()
m = m.initKeymap(keymap)

if _, err := tea.NewProgram(m).Run(); err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions internal/repl/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var noStyle = lipgloss.NewStyle()

func (m *model) initView() {
func (m model) initView() model {
m.list.SetShowStatusBar(false)
m.list.SetShowTitle(false)
m.list.SetShowFilter(false)
Expand Down Expand Up @@ -48,9 +48,11 @@ func (m *model) initView() {

m.command.SetSuggestions(suggestions)
m.command.ShowSuggestions = true

return m
}

func (m *model) handleResize(msg tea.WindowSizeMsg) (tea.Model, tea.Cmd) {
func (m model) handleResize(msg tea.WindowSizeMsg) (tea.Model, tea.Cmd) {
slog.Debug("resize", "width", msg.Width, "height", msg.Height)

m.list.SetHeight(min(msg.Height, m.maxHeight))
Expand Down

0 comments on commit 2ea3095

Please sign in to comment.