chore(ci): tighten go linting
This commit is contained in:
parent
b7346ada62
commit
c47732ca10
@ -2,21 +2,33 @@ version: "2"
|
|||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
|
- asasalint
|
||||||
|
- bidichk
|
||||||
- bodyclose
|
- bodyclose
|
||||||
|
- canonicalheader
|
||||||
- copyloopvar
|
- copyloopvar
|
||||||
|
- dupword
|
||||||
- durationcheck
|
- durationcheck
|
||||||
- errcheck
|
- errcheck
|
||||||
- errchkjson
|
- errchkjson
|
||||||
- errorlint
|
- errorlint
|
||||||
|
- exptostd
|
||||||
|
- gocheckcompilerdirectives
|
||||||
|
- gocritic
|
||||||
|
- gomoddirectives
|
||||||
- govet
|
- govet
|
||||||
- intrange
|
- intrange
|
||||||
- ineffassign
|
- ineffassign
|
||||||
|
- makezero
|
||||||
- misspell
|
- misspell
|
||||||
- modernize
|
- modernize
|
||||||
- nilerr
|
- nilerr
|
||||||
- nilnesserr
|
- nilnesserr
|
||||||
|
- noctx
|
||||||
- nolintlint
|
- nolintlint
|
||||||
|
- nosprintfhostport
|
||||||
- perfsprint
|
- perfsprint
|
||||||
|
- predeclared
|
||||||
- rowserrcheck
|
- rowserrcheck
|
||||||
- sloglint
|
- sloglint
|
||||||
- sqlclosecheck
|
- sqlclosecheck
|
||||||
@ -24,6 +36,7 @@ linters:
|
|||||||
- testifylint
|
- testifylint
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
|
- usetesting
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
- wastedassign
|
- wastedassign
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ func TestMainHelpAndVersion(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("os.Executable: %v", err)
|
t.Fatalf("os.Executable: %v", err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(exe, "-test.run=TestMainHelpAndVersion")
|
cmd := exec.CommandContext(t.Context(), exe, "-test.run=TestMainHelpAndVersion")
|
||||||
cmd.Env = append(os.Environ(), "DISCRAWL_MAIN_ERROR=1")
|
cmd.Env = append(os.Environ(), "DISCRAWL_MAIN_ERROR=1")
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
var exitErr *exec.ExitError
|
var exitErr *exec.ExitError
|
||||||
|
|||||||
@ -728,7 +728,7 @@ func publishSnapshot(t *testing.T, ctx context.Context, s *store.Store, opts sha
|
|||||||
func runGit(t *testing.T, dir string, args ...string) {
|
func runGit(t *testing.T, dir string, args ...string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
cmd := exec.Command("git", args...)
|
cmd := exec.CommandContext(t.Context(), "git", args...)
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
|
|||||||
@ -84,12 +84,13 @@ func (r *runtime) runDirectMessages(args []string) error {
|
|||||||
|
|
||||||
messageLimit := *limit
|
messageLimit := *limit
|
||||||
messageLast := *last
|
messageLast := *last
|
||||||
if *all {
|
switch {
|
||||||
|
case *all:
|
||||||
messageLimit = 0
|
messageLimit = 0
|
||||||
messageLast = 0
|
messageLast = 0
|
||||||
} else if flagPassed(fs, "limit") {
|
case flagPassed(fs, "limit"):
|
||||||
messageLast = 0
|
messageLast = 0
|
||||||
} else {
|
default:
|
||||||
messageLimit = 0
|
messageLimit = 0
|
||||||
}
|
}
|
||||||
rows, err := r.store.ListMessages(r.ctx, store.MessageListOptions{
|
rows, err := r.store.ListMessages(r.ctx, store.MessageListOptions{
|
||||||
|
|||||||
@ -18,7 +18,7 @@ func TestDockerGitSourceSmoke(t *testing.T) {
|
|||||||
t.Skip("docker is not installed")
|
t.Skip("docker is not installed")
|
||||||
}
|
}
|
||||||
root := repoRoot(t)
|
root := repoRoot(t)
|
||||||
cmd := exec.Command("bash", filepath.Join(root, "scripts", "docker-git-source-smoke.sh"))
|
cmd := exec.CommandContext(t.Context(), "bash", filepath.Join(root, "scripts", "docker-git-source-smoke.sh"))
|
||||||
cmd.Dir = root
|
cmd.Dir = root
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
@ -26,7 +26,7 @@ func TestDockerGitSourceSmoke(t *testing.T) {
|
|||||||
|
|
||||||
func repoRoot(t *testing.T) string {
|
func repoRoot(t *testing.T) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
cmd := exec.CommandContext(t.Context(), "git", "rev-parse", "--show-toplevel")
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return strings.TrimSpace(string(out))
|
return strings.TrimSpace(string(out))
|
||||||
|
|||||||
@ -462,9 +462,9 @@ func TestGitCommitDetectsNoChanges(t *testing.T) {
|
|||||||
_, err := Export(ctx, src, opts)
|
_, err := Export(ctx, src, opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", repo, "config", "user.name", "discrawl test").Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", repo, "config", "user.name", "discrawl test").Run())
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", repo, "config", "user.email", "discrawl@example.com").Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", repo, "config", "user.email", "discrawl@example.com").Run())
|
||||||
|
|
||||||
committed, err := Commit(ctx, opts, "test: snapshot")
|
committed, err := Commit(ctx, opts, "test: snapshot")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -483,16 +483,13 @@ func TestPullAndPushWithBareRemote(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
remote := filepath.Join(dir, "remote.git")
|
remote := filepath.Join(dir, "remote.git")
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", dir, "init", "--bare", remote).Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", dir, "init", "--bare", remote).Run())
|
||||||
|
|
||||||
publisher := filepath.Join(dir, "publisher")
|
publisher := filepath.Join(dir, "publisher")
|
||||||
opts := Options{RepoPath: publisher, Remote: remote, Branch: "main"}
|
opts := Options{RepoPath: publisher, Remote: remote, Branch: "main"}
|
||||||
_, err := Export(ctx, src, opts)
|
_, err := Export(ctx, src, opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
configureGitUser(t, publisher)
|
||||||
require.NoError(t, exec.Command("git", "-C", publisher, "config", "user.name", "discrawl test").Run())
|
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
|
||||||
require.NoError(t, exec.Command("git", "-C", publisher, "config", "user.email", "discrawl@example.com").Run())
|
|
||||||
committed, err := Commit(ctx, opts, "test: snapshot")
|
committed, err := Commit(ctx, opts, "test: snapshot")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, committed)
|
require.True(t, committed)
|
||||||
@ -512,7 +509,7 @@ func TestPushRebasesRemoteReadmeUpdates(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
remote := filepath.Join(dir, "remote.git")
|
remote := filepath.Join(dir, "remote.git")
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", dir, "init", "--bare", remote).Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", dir, "init", "--bare", remote).Run())
|
||||||
|
|
||||||
publisher := filepath.Join(dir, "publisher")
|
publisher := filepath.Join(dir, "publisher")
|
||||||
opts := Options{RepoPath: publisher, Remote: remote, Branch: "main"}
|
opts := Options{RepoPath: publisher, Remote: remote, Branch: "main"}
|
||||||
@ -908,9 +905,9 @@ func seedDirectMessageData(t *testing.T, ctx context.Context, s *store.Store) {
|
|||||||
func configureGitUser(t *testing.T, repo string) {
|
func configureGitUser(t *testing.T, repo string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", repo, "config", "user.name", "discrawl test").Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", repo, "config", "user.name", "discrawl test").Run())
|
||||||
// #nosec G204 -- fixed git argv in test setup.
|
// #nosec G204 -- fixed git argv in test setup.
|
||||||
require.NoError(t, exec.Command("git", "-C", repo, "config", "user.email", "discrawl@example.com").Run())
|
require.NoError(t, exec.CommandContext(t.Context(), "git", "-C", repo, "config", "user.email", "discrawl@example.com").Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustReadManifest(t *testing.T, repo string) Manifest {
|
func mustReadManifest(t *testing.T, repo string) Manifest {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user