Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: golangci-lint issues #378

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading