Skip to content

Commit 56567b0

Browse files
committed
chore: exclude test files from gostyle errorstrings analyzer
Add exclude-test: true for errorstrings in .gostyle.yml and remove all //nostyle:errorstrings inline comments from test files.
1 parent fdfc8a1 commit 56567b0

7 files changed

Lines changed: 43 additions & 42 deletions

File tree

.gostyle.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ analyzers:
22
disable:
33
- mixedcaps # disable mixedcaps analyzer. because the underscores analyzer is more detailed.
44
- funcfmt
5-
# analyzers-settings:
5+
analyzers-settings:
6+
errorstrings:
7+
exclude-test: true
68
# dontpanic:
79
# exclude-test: true # exclude test files (default: false)
810
# handlerrors:

e2e/bare_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestE2E_BareRepository(t *testing.T) {
3434
t.Fatalf("expected success for bare repository list, but got error: %v\noutput: %s", err, out)
3535
}
3636
if !strings.Contains(out, "(bare)") {
37-
t.Errorf("output should contain '(bare)' label, got: %s", out) //nostyle:errorstrings
37+
t.Errorf("output should contain '(bare)' label, got: %s", out)
3838
}
3939
})
4040

@@ -110,7 +110,7 @@ func TestE2E_BareRepository(t *testing.T) {
110110
}
111111
// Should show both the bare entry and the worktree entry
112112
if !strings.Contains(out, "(bare)") {
113-
t.Errorf("output should contain '(bare)' label, got: %s", out) //nostyle:errorstrings
113+
t.Errorf("output should contain '(bare)' label, got: %s", out)
114114
}
115115
if !strings.Contains(out, "main") {
116116
t.Errorf("output should contain 'main' branch, got: %s", out)
@@ -160,7 +160,7 @@ func TestE2E_BareRepository(t *testing.T) {
160160
t.Fatalf("expected success for dotgit bare repository list, but got error: %v\noutput: %s", err, out)
161161
}
162162
if !strings.Contains(out, "(bare)") {
163-
t.Errorf("output should contain '(bare)' label, got: %s", out) //nostyle:errorstrings
163+
t.Errorf("output should contain '(bare)' label, got: %s", out)
164164
}
165165
})
166166

e2e/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,11 @@ echo "EXISTING_PWD=$EXISTING_PWD"
576576
}
577577

578578
if strings.Contains(newPwd, branchName) {
579-
t.Errorf("NEW_PWD should NOT contain worktree path when creating new worktree with wt.nocd=create, got: %s", newPwd) //nostyle:errorstrings
579+
t.Errorf("NEW_PWD should NOT contain worktree path when creating new worktree with wt.nocd=create, got: %s", newPwd)
580580
}
581581

582582
if !strings.Contains(existingPwd, branchName) {
583-
t.Errorf("EXISTING_PWD should contain worktree path when switching to existing worktree with wt.nocd=create, got: %s", existingPwd) //nostyle:errorstrings
583+
t.Errorf("EXISTING_PWD should contain worktree path when switching to existing worktree with wt.nocd=create, got: %s", existingPwd)
584584
}
585585
})
586586
}

internal/git/branch_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestBranchExists(t *testing.T) {
3232
t.Fatalf("unexpected error: %v", err)
3333
}
3434
if got != tt.want {
35-
t.Errorf("BranchExists(%q) = %v, want %v", tt.branch, got, tt.want) //nostyle:errorstrings
35+
t.Errorf("BranchExists(%q) = %v, want %v", tt.branch, got, tt.want)
3636
}
3737
})
3838
}
@@ -64,7 +64,7 @@ func TestLocalBranchExists(t *testing.T) {
6464
t.Fatalf("unexpected error: %v", err)
6565
}
6666
if got != tt.want {
67-
t.Errorf("LocalBranchExists(%q) = %v, want %v", tt.branch, got, tt.want) //nostyle:errorstrings
67+
t.Errorf("LocalBranchExists(%q) = %v, want %v", tt.branch, got, tt.want)
6868
}
6969
})
7070
}
@@ -219,7 +219,7 @@ func TestIsBranchMerged(t *testing.T) {
219219
t.Fatalf("unexpected error: %v", err)
220220
}
221221
if got != tt.want {
222-
t.Errorf("IsBranchMerged(%q) = %v, want %v", tt.branch, got, tt.want) //nostyle:errorstrings
222+
t.Errorf("IsBranchMerged(%q) = %v, want %v", tt.branch, got, tt.want)
223223
}
224224
})
225225
}
@@ -242,6 +242,6 @@ func TestDefaultBranch(t *testing.T) {
242242
}
243243

244244
if branch != "main" {
245-
t.Errorf("DefaultBranch() = %q, want %q", branch, "main") //nostyle:errorstrings
245+
t.Errorf("DefaultBranch() = %q, want %q", branch, "main")
246246
}
247247
}

internal/git/config_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ func TestGitConfig(t *testing.T) {
4545
t.Fatalf("GitConfig(%q) error = %v, wantErr %v", tt.key, err, tt.wantErr)
4646
}
4747
if len(got) != len(tt.want) {
48-
t.Errorf("GitConfig(%q) = %v, want %v", tt.key, got, tt.want) //nostyle:errorstrings
48+
t.Errorf("GitConfig(%q) = %v, want %v", tt.key, got, tt.want)
4949
return
5050
}
5151
for i := range got {
5252
if got[i] != tt.want[i] {
53-
t.Errorf("GitConfig(%q)[%d] = %q, want %q", tt.key, i, got[i], tt.want[i]) //nostyle:errorstrings
53+
t.Errorf("GitConfig(%q)[%d] = %q, want %q", tt.key, i, got[i], tt.want[i])
5454
}
5555
}
5656
})
@@ -77,16 +77,16 @@ func TestLoadConfig(t *testing.T) {
7777
}
7878

7979
if cfg.BaseDir != "../custom-worktrees" {
80-
t.Errorf("LoadConfig().BaseDir = %q, want %q", cfg.BaseDir, "../custom-worktrees") //nostyle:errorstrings
80+
t.Errorf("LoadConfig().BaseDir = %q, want %q", cfg.BaseDir, "../custom-worktrees")
8181
}
8282
if !cfg.CopyIgnored {
83-
t.Errorf("LoadConfig().CopyIgnored = %v, want true", cfg.CopyIgnored) //nostyle:errorstrings
83+
t.Errorf("LoadConfig().CopyIgnored = %v, want true", cfg.CopyIgnored)
8484
}
8585
if cfg.CopyUntracked {
86-
t.Errorf("LoadConfig().CopyUntracked = %v, want false", cfg.CopyUntracked) //nostyle:errorstrings
86+
t.Errorf("LoadConfig().CopyUntracked = %v, want false", cfg.CopyUntracked)
8787
}
8888
if !cfg.CopyModified {
89-
t.Errorf("LoadConfig().CopyModified = %v, want true", cfg.CopyModified) //nostyle:errorstrings
89+
t.Errorf("LoadConfig().CopyModified = %v, want true", cfg.CopyModified)
9090
}
9191

9292
// Test with explicit default pattern
@@ -101,19 +101,19 @@ func TestLoadConfig(t *testing.T) {
101101
}
102102

103103
if cfg.BaseDir != "../{gitroot}-wt" {
104-
t.Errorf("LoadConfig().BaseDir = %q, want %q", cfg.BaseDir, "../{gitroot}-wt") //nostyle:errorstrings
104+
t.Errorf("LoadConfig().BaseDir = %q, want %q", cfg.BaseDir, "../{gitroot}-wt")
105105
}
106106
if cfg.CopyIgnored {
107-
t.Errorf("LoadConfig().CopyIgnored default = %v, want false", cfg.CopyIgnored) //nostyle:errorstrings
107+
t.Errorf("LoadConfig().CopyIgnored default = %v, want false", cfg.CopyIgnored)
108108
}
109109
if cfg.CopyUntracked {
110-
t.Errorf("LoadConfig().CopyUntracked default = %v, want false", cfg.CopyUntracked) //nostyle:errorstrings
110+
t.Errorf("LoadConfig().CopyUntracked default = %v, want false", cfg.CopyUntracked)
111111
}
112112
if cfg.CopyModified {
113-
t.Errorf("LoadConfig().CopyModified default = %v, want false", cfg.CopyModified) //nostyle:errorstrings
113+
t.Errorf("LoadConfig().CopyModified default = %v, want false", cfg.CopyModified)
114114
}
115115
if cfg.NoCd {
116-
t.Errorf("LoadConfig().NoCd default = %v, want false", cfg.NoCd) //nostyle:errorstrings
116+
t.Errorf("LoadConfig().NoCd default = %v, want false", cfg.NoCd)
117117
}
118118

119119
// Test NoCd setting
@@ -125,7 +125,7 @@ func TestLoadConfig(t *testing.T) {
125125
}
126126

127127
if !cfg.NoCd {
128-
t.Errorf("LoadConfig().NoCd = %v, want true", cfg.NoCd) //nostyle:errorstrings
128+
t.Errorf("LoadConfig().NoCd = %v, want true", cfg.NoCd)
129129
}
130130
}
131131

@@ -176,7 +176,7 @@ func TestExpandPath(t *testing.T) {
176176
t.Fatalf("unexpected error: %v", err)
177177
}
178178
if got != tt.want {
179-
t.Errorf("ExpandPath(%q) = %q, want %q", tt.path, got, tt.want) //nostyle:errorstrings
179+
t.Errorf("ExpandPath(%q) = %q, want %q", tt.path, got, tt.want)
180180
}
181181
})
182182
}
@@ -199,7 +199,7 @@ func TestWorktreePathFor(t *testing.T) {
199199
// Expected: parent_dir/repo-wt/feature-branch
200200
expectedDir := filepath.Clean(filepath.Join(repo.Root, "../repo-wt/feature-branch"))
201201
if path != expectedDir {
202-
t.Errorf("WorktreePathFor(\"feature-branch\") = %q, want %q", path, expectedDir) //nostyle:errorstrings
202+
t.Errorf("WorktreePathFor(\"feature-branch\") = %q, want %q", path, expectedDir)
203203
}
204204

205205
// Test with custom basedir
@@ -210,7 +210,7 @@ func TestWorktreePathFor(t *testing.T) {
210210

211211
expectedDir = filepath.Clean(filepath.Join(repo.Root, "../repo-worktrees/feature-branch"))
212212
if path != expectedDir {
213-
t.Errorf("WorktreePathFor(\"feature-branch\") with custom basedir = %q, want %q", path, expectedDir) //nostyle:errorstrings
213+
t.Errorf("WorktreePathFor(\"feature-branch\") with custom basedir = %q, want %q", path, expectedDir)
214214
}
215215
}
216216

@@ -256,7 +256,7 @@ func TestExpandBaseDir(t *testing.T) {
256256
t.Fatalf("unexpected error: %v", err)
257257
}
258258
if got != tt.want {
259-
t.Errorf("ExpandBaseDir(%q) = %q, want %q", tt.baseDir, got, tt.want) //nostyle:errorstrings
259+
t.Errorf("ExpandBaseDir(%q) = %q, want %q", tt.baseDir, got, tt.want)
260260
}
261261
})
262262
}
@@ -316,6 +316,6 @@ func TestSetConfig(t *testing.T) {
316316
t.Fatalf("GitConfig() error = %v", err)
317317
}
318318
if len(values) != 1 || values[0] != "../test-wt" {
319-
t.Errorf("GitConfig() = %v, want [../test-wt]", values) //nostyle:errorstrings
319+
t.Errorf("GitConfig() = %v, want [../test-wt]", values)
320320
}
321321
}

internal/git/repo_context_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ func TestIsBareRepository_WorktreeFromBare(t *testing.T) {
242242
}
243243
}
244244

245-
246245
func TestWithRepoContext_CacheHit(t *testing.T) {
247246
repo := testutil.NewTestRepo(t)
248247
repo.CreateFile("README.md", "# Test")
@@ -306,7 +305,7 @@ func TestShowPrefix(t *testing.T) {
306305
t.Fatalf("unexpected error: %v", err)
307306
}
308307
if prefix != "" {
309-
t.Errorf("ShowPrefix() at root = %q, want empty string", prefix) //nostyle:errorstrings
308+
t.Errorf("ShowPrefix() at root = %q, want empty string", prefix)
310309
}
311310
})
312311

@@ -324,7 +323,7 @@ func TestShowPrefix(t *testing.T) {
324323
t.Fatalf("unexpected error: %v", err)
325324
}
326325
if prefix != "some/path" {
327-
t.Errorf("ShowPrefix() in subdir = %q, want %q", prefix, "some/path") //nostyle:errorstrings
326+
t.Errorf("ShowPrefix() in subdir = %q, want %q", prefix, "some/path")
328327
}
329328
})
330329
}
@@ -347,7 +346,7 @@ func TestMainRepoRoot(t *testing.T) {
347346
}
348347

349348
if root != repo.Root {
350-
t.Errorf("MainRepoRoot() = %q, want %q", root, repo.Root) //nostyle:errorstrings
349+
t.Errorf("MainRepoRoot() = %q, want %q", root, repo.Root)
351350
}
352351

353352
// Test from subdirectory
@@ -362,7 +361,7 @@ func TestMainRepoRoot(t *testing.T) {
362361
}
363362

364363
if root != repo.Root {
365-
t.Errorf("MainRepoRoot() from subdir = %q, want %q", root, repo.Root) //nostyle:errorstrings
364+
t.Errorf("MainRepoRoot() from subdir = %q, want %q", root, repo.Root)
366365
}
367366
}
368367

@@ -381,7 +380,7 @@ func TestRepoName(t *testing.T) {
381380

382381
// The repo is created in a temp directory named "repo"
383382
if name != "repo" {
384-
t.Errorf("RepoName() = %q, want %q", name, "repo") //nostyle:errorstrings
383+
t.Errorf("RepoName() = %q, want %q", name, "repo")
385384
}
386385
}
387386

@@ -539,7 +538,7 @@ func TestMainRepoRoot_BareRepo(t *testing.T) {
539538

540539
// Bare repo: MainRepoRoot should return the bare repo directory itself
541540
if root != bareRepo.Root {
542-
t.Errorf("MainRepoRoot() = %q, want %q", root, bareRepo.Root) //nostyle:errorstrings
541+
t.Errorf("MainRepoRoot() = %q, want %q", root, bareRepo.Root)
543542
}
544543
}
545544

@@ -573,7 +572,7 @@ func TestMainRepoRoot_WorktreeFromBare(t *testing.T) {
573572

574573
// From a bare-derived worktree, MainRepoRoot should return the bare repo directory
575574
if root != bareRepo.Root {
576-
t.Errorf("MainRepoRoot() = %q, want %q", root, bareRepo.Root) //nostyle:errorstrings
575+
t.Errorf("MainRepoRoot() = %q, want %q", root, bareRepo.Root)
577576
}
578577
}
579578

@@ -600,7 +599,7 @@ func TestRepoName_BareRepo(t *testing.T) {
600599

601600
// BareTestRepo creates "repo.git", so RepoName should return "repo.git"
602601
if name != "repo.git" {
603-
t.Errorf("RepoName() = %q, want %q", name, "repo.git") //nostyle:errorstrings
602+
t.Errorf("RepoName() = %q, want %q", name, "repo.git")
604603
}
605604
}
606605

internal/git/worktree_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestCurrentWorktree(t *testing.T) {
8484
}
8585

8686
if path != repo.Root {
87-
t.Errorf("CurrentWorktree() = %q, want %q", path, repo.Root) //nostyle:errorstrings
87+
t.Errorf("CurrentWorktree() = %q, want %q", path, repo.Root)
8888
}
8989
}
9090

@@ -102,7 +102,7 @@ func TestCurrentLocation_NormalRepo(t *testing.T) {
102102
}
103103

104104
if path != repo.Root {
105-
t.Errorf("CurrentLocation() = %q, want %q", path, repo.Root) //nostyle:errorstrings
105+
t.Errorf("CurrentLocation() = %q, want %q", path, repo.Root)
106106
}
107107
}
108108

@@ -133,7 +133,7 @@ func TestCurrentLocation_NormalWorktree(t *testing.T) {
133133
}
134134

135135
if path != wtPath {
136-
t.Errorf("CurrentLocation() = %q, want %q", path, wtPath) //nostyle:errorstrings
136+
t.Errorf("CurrentLocation() = %q, want %q", path, wtPath)
137137
}
138138
}
139139

@@ -159,7 +159,7 @@ func TestCurrentLocation_BareRoot(t *testing.T) {
159159
}
160160

161161
if path != bareRepo.Root {
162-
t.Errorf("CurrentLocation() = %q, want %q", path, bareRepo.Root) //nostyle:errorstrings
162+
t.Errorf("CurrentLocation() = %q, want %q", path, bareRepo.Root)
163163
}
164164
}
165165

@@ -185,7 +185,7 @@ func TestCurrentLocation_CoreBareTrueRoot(t *testing.T) {
185185
}
186186

187187
if path != bareRepo.Root {
188-
t.Errorf("CurrentLocation() = %q, want %q", path, bareRepo.Root) //nostyle:errorstrings
188+
t.Errorf("CurrentLocation() = %q, want %q", path, bareRepo.Root)
189189
}
190190
}
191191

@@ -215,7 +215,7 @@ func TestCurrentLocation_BareWorktree(t *testing.T) {
215215
}
216216

217217
if path != wtPath {
218-
t.Errorf("CurrentLocation() = %q, want %q", path, wtPath) //nostyle:errorstrings
218+
t.Errorf("CurrentLocation() = %q, want %q", path, wtPath)
219219
}
220220
}
221221

0 commit comments

Comments
 (0)