Skip to content

Commit

Permalink
fix: golangci-lint issues (#378)
Browse files Browse the repository at this point in the history
* build: fix golangci-lint config

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: golangci-lint issues

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: lint

Signed-off-by: Carlos Alexandro Becker <[email protected]>

---------

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Aug 21, 2024
1 parent 8c0eb1f commit 84f3912
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
10 changes: 1 addition & 9 deletions .golangci-soft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ issues:

linters:
enable:
# - dupl
- exhaustive
# - exhaustivestruct
- goconst
- godot
- godox
- gomnd
- mnd
- gomoddirectives
- goprintffuncname
# - ifshort
# - lll
- misspell
- nakedret
- nestif
Expand All @@ -35,13 +30,10 @@ linters:

# disable default linters, they are already enabled in .golangci.yml
disable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
8 changes: 4 additions & 4 deletions field_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ func (t *Text) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, t.keymap.Editor):
ext := strings.TrimPrefix(t.editorExtension, ".")
tmpFile, _ := os.CreateTemp(os.TempDir(), "*."+ext)
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint
_ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), 0600)
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint:gosec
_ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), 0o644) //nolint:mnd,gosec
cmds = append(cmds, tea.ExecProcess(cmd, func(error) tea.Msg {
content, _ := os.ReadFile(tmpFile.Name())
_ = os.Remove(tmpFile.Name())
Expand Down Expand Up @@ -364,8 +364,8 @@ func (t *Text) activeTextAreaStyles() *textarea.Style {

// View renders the text field.
func (t *Text) View() string {
var styles = t.activeStyles()
var textareaStyles = t.activeTextAreaStyles()
styles := t.activeStyles()
textareaStyles := t.activeTextAreaStyles()

// NB: since the method is on a pointer receiver these are being mutated.
// Because this runs on every render this shouldn't matter in practice,
Expand Down
3 changes: 2 additions & 1 deletion form.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package huh
import (
"context"
"errors"
"fmt"
"io"
"os"
"sync"
Expand Down Expand Up @@ -651,7 +652,7 @@ func (f *Form) run(ctx context.Context) error {
if errors.Is(err, tea.ErrProgramKilled) {
return ErrTimeout
}
return err
return fmt.Errorf("huh: %w", err)
}

// runAccessible runs the form in accessible mode.
Expand Down
3 changes: 1 addition & 2 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func NewGroup(fields ...Field) *Group {
}

height := group.fullHeight()
//nolint:gomnd
v := viewport.New(80, height)
v := viewport.New(80, height) //nolint:mnd
group.viewport = v
group.height = height

Expand Down
4 changes: 2 additions & 2 deletions layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (l *layoutColumns) View(f *Form) string {
return ""
}

var columns []string
columns := make([]string, 0, len(groups))
for _, group := range groups {
columns = append(columns, group.Content())
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func (l *layoutGrid) View(f *Form) string {
return ""
}

var rows []string
rows := make([]string, 0, len(grid))
for _, row := range grid {
var columns []string
for _, group := range row {
Expand Down

0 comments on commit 84f3912

Please sign in to comment.