Skip to content

[chore] Add keep-sorted linter #3130

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

Merged
merged 2 commits into from
Apr 19, 2025
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ codequality: licensecheck
fi
@golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 || exit 1

@echo -n " KEEP-SORTED "
@which keep-sorted > /dev/null; if [ $$? -ne 0 ]; then \
$(GO) install github.com/keep-sorted/keep-sorted@latest; \
fi
@keep-sorted --mode lint $(GOFILES_NOVENDOR) || exit 1

@printf '%s\n' '$(OK)'

licensecheck:
Expand All @@ -156,6 +162,7 @@ gen:
@$(GO) generate ./...

fmt:
@keep-sorted --mode fix $(GOFILES_NOVENDOR)
@gofumpt -w $(GOFILES_NOVENDOR)
@$(GO) mod tidy

Expand Down
8 changes: 6 additions & 2 deletions internal/config/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,38 @@ import (
// but originate from elsewhere. They should be well known and properly
// documented already.
var ignoredEnvs = set.Map([]string{
// keep-sorted start
"APPDATA",
"GIT_AUTHOR_EMAIL",
"GIT_AUTHOR_NAME",
"GNUPGHOME",
"GOPATH",
"GOPASS_CONFIG_NOSYSTEM", // name assembled, tests can't catch it
"GOPASS_DEBUG_FILES", // indirect usage
"GOPASS_DEBUG_FUNCS", // indirect usage
"GOPASS_GPG_OPTS", // indirect usage
"GOPASS_UMASK", // indirect usage
"PASSWORD_STORE_UMASK", // indirect usage
"GOPATH",
"GPG_TTY",
"HOME",
"LOCALAPPDATA",
"PASSWORD_STORE_UMASK", // indirect usage
"XDG_CACHE_HOME",
"XDG_CONFIG_HOME",
"XDG_DATA_HOME",
// keep-sorted end
})

// ignoredOptions is a list of config options that are used by gopass
// but may not be covered easily by a regexp.
var ignoredOptions = set.Map([]string{
// keep-sorted start
"core.post-hook",
"core.pre-hook",
"include.path",
"recipients.hash",
"user.email",
"user.name",
// keep-sorted end
})

func TestConfigOptsInDocs(t *testing.T) {
Expand Down
Loading