Skip to content

Commit

Permalink
fix: lint issues (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 authored Sep 6, 2024
1 parent 8ab6253 commit b9611e1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
9 changes: 1 addition & 8 deletions .golangci-soft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ issues:

linters:
enable:
# - dupl
- exhaustive
# - exhaustivestruct
- goconst
- godot
- godox
- gomnd
- mnd
- gomoddirectives
- goprintffuncname
# - ifshort
# - lll
- misspell
- nakedret
- nestif
Expand All @@ -35,12 +31,9 @@ linters:
# disable default linters, they are already enabled in .golangci.yml
disable:
- wrapcheck
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- varcheck
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ issues:
linters:
enable:
- bodyclose
- exportloopref
- goimports
- gosec
- nilerr
Expand Down
8 changes: 4 additions & 4 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ func (o Options) Run() error {
}

func widest(options []string) int {
var max int
var maxw int
for _, o := range options {
w := lipgloss.Width(o)
if w > max {
max = w
if w > maxw {
maxw = w
}
}
return max
return maxw
}

func ansiprint(s string) {
Expand Down
16 changes: 8 additions & 8 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type model struct {
func (m model) Init() tea.Cmd {
return timeout.Init(m.timeout, nil)
}

func (m model) View() string {
if m.quitting {
return ""
Expand Down Expand Up @@ -254,7 +255,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

func (m *model) CursorUp() {
if m.reverse {
if m.reverse { //nolint:nestif
m.cursor = (m.cursor + 1) % len(m.matches)
if len(m.matches)-m.cursor <= m.viewport.YOffset {
m.viewport.LineUp(1)
Expand All @@ -274,7 +275,7 @@ func (m *model) CursorUp() {
}

func (m *model) CursorDown() {
if m.reverse {
if m.reverse { //nolint:nestif
m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches)
if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset {
m.viewport.LineDown(1)
Expand Down Expand Up @@ -334,13 +335,12 @@ func exactMatches(search string, choices []string) []fuzzy.Match {
return matches
}

//nolint:unparam
func clamp(min, max, val int) int {
if val < min {
return min
func clamp(low, high, val int) int {
if val < low {
return low
}
if val > max {
return max
if val > high {
return high
}
return val
}

0 comments on commit b9611e1

Please sign in to comment.