Skip to content

Commit 358a6c5

Browse files
committed
chore(lint): fix and suppress all soft lint issues; update directives
1 parent 7525b8c commit 358a6c5

File tree

11 files changed

+46
-42
lines changed

11 files changed

+46
-42
lines changed

filepicker/filepicker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (m Model) View() string {
379379

380380
disabled := !m.canSelect(name) && !f.IsDir()
381381

382-
if m.selected == i {
382+
if m.selected == i { //nolint:nestif
383383
selected := ""
384384
if m.ShowPermissions {
385385
selected += " " + info.Mode().String()

list/defaultitem.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type DefaultItemStyles struct {
3535
func NewDefaultItemStyles() (s DefaultItemStyles) {
3636
s.NormalTitle = lipgloss.NewStyle().
3737
Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}).
38-
Padding(0, 0, 0, 2)
38+
Padding(0, 0, 0, 2) //nolint:mnd
3939

4040
s.NormalDesc = s.NormalTitle.
4141
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"})
@@ -51,7 +51,7 @@ func NewDefaultItemStyles() (s DefaultItemStyles) {
5151

5252
s.DimmedTitle = lipgloss.NewStyle().
5353
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
54-
Padding(0, 0, 0, 2)
54+
Padding(0, 0, 0, 2) //nolint:mnd
5555

5656
s.DimmedDesc = s.DimmedTitle.
5757
Foreground(lipgloss.AdaptiveColor{Light: "#C2B8C2", Dark: "#4D4D4D"})
@@ -93,11 +93,13 @@ type DefaultDelegate struct {
9393

9494
// NewDefaultDelegate creates a new delegate with default styles.
9595
func NewDefaultDelegate() DefaultDelegate {
96+
const defaultHeight = 2
97+
const defaultSpacing = 1
9698
return DefaultDelegate{
9799
ShowDescription: true,
98100
Styles: NewDefaultItemStyles(),
99-
height: 2,
100-
spacing: 1,
101+
height: defaultHeight,
102+
spacing: defaultSpacing,
101103
}
102104
}
103105

list/list.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (m *Model) SetShowTitle(v bool) {
273273

274274
// SetFilterText explicitly sets the filter text without relying on user input.
275275
// It also sets the filterState to a sane default of FilterApplied, but this
276-
// can be changed with SetFilterState
276+
// can be changed with SetFilterState.
277277
func (m *Model) SetFilterText(filter string) {
278278
m.filterState = Filtering
279279
m.FilterInput.SetValue(filter)
@@ -289,7 +289,7 @@ func (m *Model) SetFilterText(filter string) {
289289
m.updateKeybindings()
290290
}
291291

292-
// Helper method for setting the filtering state manually
292+
// Helper method for setting the filtering state manually.
293293
func (m *Model) SetFilterState(state FilterState) {
294294
m.Paginator.Page = 0
295295
m.cursor = 0
@@ -722,7 +722,7 @@ func (m Model) itemsAsFilterItems() filteredItems {
722722

723723
// Set keybindings according to the filter state.
724724
func (m *Model) updateKeybindings() {
725-
switch m.filterState {
725+
switch m.filterState { //nolint:exhaustive
726726
case Filtering:
727727
m.KeyMap.CursorUp.SetEnabled(false)
728728
m.KeyMap.CursorDown.SetEnabled(false)
@@ -1153,7 +1153,7 @@ func (m Model) statusView() string {
11531153

11541154
itemsDisplay := fmt.Sprintf("%d %s", visibleItems, itemName)
11551155

1156-
if m.filterState == Filtering {
1156+
if m.filterState == Filtering { //nolint:nestif
11571157
// Filter results
11581158
if visibleItems == 0 {
11591159
status = m.Styles.StatusEmpty.Render("Nothing matched")
@@ -1169,7 +1169,7 @@ func (m Model) statusView() string {
11691169

11701170
if filtered {
11711171
f := strings.TrimSpace(m.FilterInput.Value())
1172-
f = ansi.Truncate(f, 10, "…")
1172+
f = ansi.Truncate(f, 10, "…") //nolint:mnd
11731173
status += fmt.Sprintf("“%s” ", f)
11741174
}
11751175

@@ -1186,7 +1186,7 @@ func (m Model) statusView() string {
11861186
}
11871187

11881188
func (m Model) paginationView() string {
1189-
if m.Paginator.TotalPages < 2 { //nolint:gomnd
1189+
if m.Paginator.TotalPages < 2 { //nolint:mnd
11901190
return ""
11911191
}
11921192

list/style.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func DefaultStyles() (s Styles) {
4545
verySubduedColor := lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"}
4646
subduedColor := lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
4747

48-
s.TitleBar = lipgloss.NewStyle().Padding(0, 0, 1, 2)
48+
s.TitleBar = lipgloss.NewStyle().Padding(0, 0, 1, 2) //nolint:mnd
4949

5050
s.Title = lipgloss.NewStyle().
5151
Background(lipgloss.Color("62")).
@@ -65,7 +65,7 @@ func DefaultStyles() (s Styles) {
6565

6666
s.StatusBar = lipgloss.NewStyle().
6767
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
68-
Padding(0, 0, 1, 2)
68+
Padding(0, 0, 1, 2) //nolint:mnd
6969

7070
s.StatusEmpty = lipgloss.NewStyle().Foreground(subduedColor)
7171

@@ -79,9 +79,9 @@ func DefaultStyles() (s Styles) {
7979

8080
s.ArabicPagination = lipgloss.NewStyle().Foreground(subduedColor)
8181

82-
s.PaginationStyle = lipgloss.NewStyle().PaddingLeft(2) //nolint:gomnd
82+
s.PaginationStyle = lipgloss.NewStyle().PaddingLeft(2) //nolint:mnd
8383

84-
s.HelpStyle = lipgloss.NewStyle().Padding(1, 0, 0, 2)
84+
s.HelpStyle = lipgloss.NewStyle().Padding(1, 0, 0, 2) //nolint:mnd
8585

8686
s.ActivePaginationDot = lipgloss.NewStyle().
8787
Foreground(lipgloss.AdaptiveColor{Light: "#847A85", Dark: "#979797"}).

paginator/paginator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
189189

190190
// View renders the pagination to a string.
191191
func (m Model) View() string {
192-
switch m.Type {
192+
switch m.Type { //nolint:exhaustive
193193
case Dots:
194194
return m.dotsView()
195195
default:

progress/progress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func (m Model) percentageView(percent float64) string {
335335
return ""
336336
}
337337
percent = math.Max(0, math.Min(1, percent))
338-
percentage := fmt.Sprintf(m.PercentFormat, percent*100) //nolint:gomnd
338+
percentage := fmt.Sprintf(m.PercentFormat, percent*100) //nolint:mnd
339339
percentage = m.PercentageStyle.Inline(true).Render(percentage)
340340
return percentage
341341
}

spinner/spinner.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@ type Spinner struct {
2626
var (
2727
Line = Spinner{
2828
Frames: []string{"|", "/", "-", "\\"},
29-
FPS: time.Second / 10, //nolint:gomnd
29+
FPS: time.Second / 10, //nolint:mnd
3030
}
3131
Dot = Spinner{
3232
Frames: []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
33-
FPS: time.Second / 10, //nolint:gomnd
33+
FPS: time.Second / 10, //nolint:mnd
3434
}
3535
MiniDot = Spinner{
3636
Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
37-
FPS: time.Second / 12, //nolint:gomnd
37+
FPS: time.Second / 12, //nolint:mnd
3838
}
3939
Jump = Spinner{
4040
Frames: []string{"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"},
41-
FPS: time.Second / 10, //nolint:gomnd
41+
FPS: time.Second / 10, //nolint:mnd
4242
}
4343
Pulse = Spinner{
4444
Frames: []string{"█", "▓", "▒", "░"},
45-
FPS: time.Second / 8, //nolint:gomnd
45+
FPS: time.Second / 8, //nolint:mnd
4646
}
4747
Points = Spinner{
4848
Frames: []string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●"},
49-
FPS: time.Second / 7, //nolint:gomnd
49+
FPS: time.Second / 7, //nolint:mnd
5050
}
5151
Globe = Spinner{
5252
Frames: []string{"🌍", "🌎", "🌏"},
53-
FPS: time.Second / 4, //nolint:gomnd
53+
FPS: time.Second / 4, //nolint:mnd
5454
}
5555
Moon = Spinner{
5656
Frames: []string{"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"},
57-
FPS: time.Second / 8, //nolint:gomnd
57+
FPS: time.Second / 8, //nolint:mnd
5858
}
5959
Monkey = Spinner{
6060
Frames: []string{"🙈", "🙉", "🙊"},
61-
FPS: time.Second / 3, //nolint:gomnd
61+
FPS: time.Second / 3, //nolint:mnd
6262
}
6363
Meter = Spinner{
6464
Frames: []string{
@@ -70,15 +70,15 @@ var (
7070
"▰▱▱",
7171
"▱▱▱",
7272
},
73-
FPS: time.Second / 7, //nolint:gomnd
73+
FPS: time.Second / 7, //nolint:mnd
7474
}
7575
Hamburger = Spinner{
7676
Frames: []string{"☱", "☲", "☴", "☲"},
77-
FPS: time.Second / 3, //nolint:gomnd
77+
FPS: time.Second / 3, //nolint:mnd
7878
}
7979
Ellipsis = Spinner{
8080
Frames: []string{"", ".", "..", "..."},
81-
FPS: time.Second / 3, //nolint:gomnd
81+
FPS: time.Second / 3, //nolint:mnd
8282
}
8383
)
8484

table/table.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ type Option func(*Model)
133133
func New(opts ...Option) Model {
134134
m := Model{
135135
cursor: 0,
136-
viewport: viewport.New(0, 20),
136+
viewport: viewport.New(0, 20), //nolint:mnd
137137

138138
KeyMap: DefaultKeyMap(),
139139
Help: help.New(),
@@ -216,9 +216,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
216216
case key.Matches(msg, m.KeyMap.PageDown):
217217
m.MoveDown(m.viewport.Height)
218218
case key.Matches(msg, m.KeyMap.HalfPageUp):
219-
m.MoveUp(m.viewport.Height / 2)
219+
m.MoveUp(m.viewport.Height / 2) //nolint:mnd
220220
case key.Matches(msg, m.KeyMap.HalfPageDown):
221-
m.MoveDown(m.viewport.Height / 2)
221+
m.MoveDown(m.viewport.Height / 2) //nolint:mnd
222222
case key.Matches(msg, m.KeyMap.GotoTop):
223223
m.GotoTop()
224224
case key.Matches(msg, m.KeyMap.GotoBottom):

textarea/textarea.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ func (m *Model) CursorDown() {
492492
// Move the cursor to the start of the next line so that we can get
493493
// the line information. We need to add 2 columns to account for the
494494
// trailing space wrapping.
495-
m.col = min(li.StartColumn+li.Width+2, len(m.value[m.row])-1)
495+
const trailingSpace = 2
496+
m.col = min(li.StartColumn+li.Width+trailingSpace, len(m.value[m.row])-1)
496497
}
497498

498499
nli := m.LineInfo()
@@ -526,7 +527,8 @@ func (m *Model) CursorUp() {
526527
// This can be done by moving the cursor to the start of the line and
527528
// then subtracting 2 to account for the trailing space we keep on
528529
// soft-wrapped lines.
529-
m.col = li.StartColumn - 2
530+
const trailingSpace = 2
531+
m.col = li.StartColumn - trailingSpace
530532
}
531533

532534
nli := m.LineInfo()
@@ -1119,7 +1121,7 @@ func (m Model) View() string {
11191121
displayLine++
11201122

11211123
var ln string
1122-
if m.ShowLineNumbers {
1124+
if m.ShowLineNumbers { //nolint:nestif
11231125
if wl == 0 {
11241126
if m.row == l {
11251127
ln = style.Render(m.style.computedCursorLineNumber().Render(m.formatLineNumber(l + 1)))
@@ -1198,7 +1200,7 @@ func (m Model) View() string {
11981200
}
11991201

12001202
// formatLineNumber formats the line number for display dynamically based on
1201-
// the maximum number of lines
1203+
// the maximum number of lines.
12021204
func (m Model) formatLineNumber(x any) string {
12031205
// XXX: ultimately we should use a max buffer height, which has yet to be
12041206
// implemented.
@@ -1407,7 +1409,7 @@ func wrap(runes []rune, width int) [][]rune {
14071409
word = append(word, r)
14081410
}
14091411

1410-
if spaces > 0 {
1412+
if spaces > 0 { //nolint:nestif
14111413
if uniseg.StringWidth(string(lines[row]))+uniseg.StringWidth(string(word))+spaces > width {
14121414
row++
14131415
lines = append(lines, []rune{})

textinput/textinput.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
565565

566566
// Let's remember where the position of the cursor currently is so that if
567567
// the cursor position changes, we can reset the blink.
568-
oldPos := m.pos //nolint
568+
oldPos := m.pos
569569

570570
switch msg := msg.(type) {
571571
case tea.KeyMsg:
@@ -658,7 +658,7 @@ func (m Model) View() string {
658658
pos := max(0, m.pos-m.offset)
659659
v := styleText(m.echoTransform(string(value[:pos])))
660660

661-
if pos < len(value) {
661+
if pos < len(value) { //nolint:nestif
662662
char := m.echoTransform(string(value[pos]))
663663
m.Cursor.SetChar(char)
664664
v += m.Cursor.View() // cursor and text under it

0 commit comments

Comments
 (0)