Skip to content

Commit 34ac2e7

Browse files
committed
update linter
1 parent a4a9704 commit 34ac2e7

File tree

4 files changed

+99
-3
lines changed

4 files changed

+99
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ require (
6969
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
7070
github.com/shirou/gopsutil/v3 v3.21.8
7171
github.com/sirupsen/logrus v1.8.1
72-
github.com/sivchari/tenv v1.3.7
72+
github.com/sivchari/tenv v1.4.7
7373
github.com/sonatard/noctx v0.0.1
7474
github.com/sourcegraph/go-diff v0.6.1
7575
github.com/spf13/cobra v1.2.1

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testdata/tenv.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// args: -Etenv
2+
// config_path: testdata/configs/tenv_all.yml
3+
package testdata
4+
5+
import (
6+
"os"
7+
"testing"
8+
)
9+
10+
var (
11+
e = os.Setenv("a", "b") // never seen
12+
)
13+
14+
func setup() {
15+
os.Setenv("a", "b") // never seen
16+
err := os.Setenv("a", "b") // never seen
17+
_ = err
18+
if err := os.Setenv("a", "b"); err != nil { // never seen
19+
_ = err
20+
}
21+
}
22+
23+
func TestF(t *testing.T) {
24+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
25+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
26+
_ = err
27+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
28+
_ = err
29+
}
30+
}
31+
32+
func BenchmarkF(b *testing.B) {
33+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
34+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
35+
_ = err
36+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
37+
_ = err
38+
}
39+
}
40+
41+
func testTB(tb testing.TB) {
42+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
43+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
44+
_ = err
45+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
46+
_ = err
47+
}
48+
}

test/testdata/tenv_all.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// args: -Etenv
2+
// config_path: testdata/configs/tenv_all.yml
3+
package testdata
4+
5+
import (
6+
"os"
7+
"testing"
8+
)
9+
10+
var (
11+
e = os.Setenv("a", "b") // never seen
12+
)
13+
14+
func setup() {
15+
os.Setenv("a", "b") // never seen
16+
err := os.Setenv("a", "b") // never seen
17+
_ = err
18+
if err := os.Setenv("a", "b"); err != nil { // never seen
19+
_ = err
20+
}
21+
}
22+
23+
func TestF(t *testing.T) {
24+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
25+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
26+
_ = err
27+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
28+
_ = err
29+
}
30+
}
31+
32+
func BenchmarkF(b *testing.B) {
33+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
34+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
35+
_ = err
36+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
37+
_ = err
38+
}
39+
}
40+
41+
func testTB(tb testing.TB) {
42+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
43+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
44+
_ = err
45+
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
46+
_ = err
47+
}
48+
}

0 commit comments

Comments
 (0)