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

[chore] use the same version of golangci-lint #2948

Merged
merged 4 commits into from
Sep 25, 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
6 changes: 5 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.59.1 # we have a list of linters in our .golangci.yml config file
# Note: there are 2 different version of golangci-lint used inside the project.
# https://github.com/gopasspw/gopass/blob/master/.github/workflows/build.yml#L65
# https://github.com/gopasspw/gopass/blob/master/.github/workflows/golangci-lint.yml#L46
# https://github.com/gopasspw/gopass/blob/master/Makefile#L136
version: v1.61.0 # we have a list of linters in our .golangci.yml config file
only-new-issues: true
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
# - exportloopref # deprecated since Go 1.22
- forcetypeassert
- funlen
- ginkgolinter
Expand Down Expand Up @@ -90,6 +90,7 @@ issues:
- helpers/

output:
show-stats: true
sort-results: true
sort-order:
- linter
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ crosscompile:
codequality:
@echo ">> CODE QUALITY"

# Note: there are 2 different version of golangci-lint used inside the project.
# https://github.com/gopasspw/gopass/blob/master/.github/workflows/build.yml#L65
# https://github.com/gopasspw/gopass/blob/master/.github/workflows/golangci-lint.yml#L46
# https://github.com/gopasspw/gopass/blob/master/Makefile#L136
@echo -n " GOLANGCI-LINT "
@which golangci-lint > /dev/null; if [ $$? -ne 0 ]; then \
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
Expand Down
6 changes: 3 additions & 3 deletions internal/action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *Action) showHandleOutput(ctx context.Context, name string, sec gopass.S
out.Warning(ctx, "show.safecontent=true. Use -f to display password, if any")
}

return exit.Error(exit.NotFound, store.ErrEmptySecret, store.ErrEmptySecret.Error())
return exit.Error(exit.NotFound, store.ErrEmptySecret, "%v", store.ErrEmptySecret)
}

if IsPrintQR(ctx) && IsQRBody(ctx) {
Expand Down Expand Up @@ -244,7 +244,7 @@ func (s *Action) showGetContent(ctx context.Context, sec gopass.Secret) (string,
key := GetKey(ctx)
values, found := sec.Values(key)
if !found {
return "", "", exit.Error(exit.NotFound, store.ErrNoKey, store.ErrNoKey.Error())
return "", "", exit.Error(exit.NotFound, store.ErrNoKey, "%v", store.ErrNoKey)
}
val := strings.Join(values, "\n")

Expand All @@ -264,7 +264,7 @@ func (s *Action) showGetContent(ctx context.Context, sec gopass.Secret) (string,
}
if IsPasswordOnly(ctx) {
if pw == "" && fullBody != "" {
return "", "", exit.Error(exit.NotFound, store.ErrNoPassword, store.ErrNoPassword.Error())
return "", "", exit.Error(exit.NotFound, store.ErrNoPassword, "%v", store.ErrNoPassword)
}

return pw, pw, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/crypto/gpg/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (k Key) String() string {

out += "\n Key fingerprint = " + k.Fingerprint
for _, id := range k.Identities {
out += fmt.Sprintf("\n" + id.String())
out += fmt.Sprintf("\n%s", id)
}

return out
Expand Down
2 changes: 1 addition & 1 deletion internal/store/leaf/recipients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestSaveRecipients(t *testing.T) {
sort.Strings(foundRecs)

ids := rs.IDs()
for i := range len(ids) {
for i := range ids {
if i >= len(foundRecs) {
t.Errorf("Read too few recipients")

Expand Down
3 changes: 2 additions & 1 deletion pkg/clipboard/clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var (
// -ldflags=='-X github.com/gopasspw/gopass/pkg/clipboard.Helpers=termux-api'.
Helpers = "xsel or xclip"
// ErrNotSupported is returned when the clipboard is not accessible.
ErrNotSupported = fmt.Errorf("WARNING: No clipboard available. Install " + Helpers + ", provide $GOPASS_CLIPBOARD_COPY_CMD and $GOPASS_CLIPBOARD_CLEAR_CMD or use -f to print to console")
ErrNotSupported = fmt.Errorf("WARNING: No clipboard available. "+
"Install %s, provide $GOPASS_CLIPBOARD_COPY_CMD and $GOPASS_CLIPBOARD_CLEAR_CMD or use -f to print to console", Helpers)
)

// CopyTo copies the given data to the clipboard and enqueues automatic
Expand Down
2 changes: 0 additions & 2 deletions tests/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ foo/

// regression test for #1628.
func TestListRegressions1628(t *testing.T) {
t.Parallel()

ts := newTester(t)
defer ts.teardown()

Expand Down
15 changes: 8 additions & 7 deletions tests/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type tester struct {
resetFn func()
}

// newTester is not compatible with t.Parallel because it uses t.Setenv.
func newTester(t *testing.T) *tester {
t.Helper()

Expand Down Expand Up @@ -77,13 +78,13 @@ func newTester(t *testing.T) *tester {

// prepare ENVIRONMENT
ts.resetFn = gptest.UnsetVars("GNUPGHOME", "GOPASS_DEBUG", "NO_COLOR", "GOPASS_CONFIG", "GOPASS_NO_NOTIFY", "GOPASS_HOMEDIR")
require.NoError(t, os.Setenv("GNUPGHOME", ts.gpgDir()))
require.NoError(t, os.Setenv("GOPASS_DEBUG", ""))
require.NoError(t, os.Setenv("NO_COLOR", "true"))
require.NoError(t, os.Setenv("GOPASS_CONFIG_NOSYSTEM", "true"))
require.NoError(t, os.Setenv("GOPASS_CONFIG_NO_MIGRATE", "true"))
require.NoError(t, os.Setenv("GOPASS_NO_NOTIFY", "true"))
require.NoError(t, os.Setenv("GOPASS_HOMEDIR", td))
t.Setenv("GNUPGHOME", ts.gpgDir())
t.Setenv("GOPASS_DEBUG", "")
t.Setenv("NO_COLOR", "true")
t.Setenv("GOPASS_CONFIG_NOSYSTEM", "true")
t.Setenv("GOPASS_CONFIG_NO_MIGRATE", "true")
t.Setenv("GOPASS_NO_NOTIFY", "true")
t.Setenv("GOPASS_HOMEDIR", td)

// write config
require.NoError(t, os.MkdirAll(filepath.Dir(ts.gopassConfig()), 0o700))
Expand Down
Loading