Skip to content

Commit f44402d

Browse files
authored
chore: Simplify redundantptr custom linter (#4148)
1 parent 059fb59 commit f44402d

3 files changed

Lines changed: 13 additions & 29 deletions

File tree

tools/redundantptr/testdata/src/github.com/google/go-github/v84/github/github.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

tools/redundantptr/testdata/src/has-warnings/main.go renamed to tools/redundantptr/testdata/src/has-warnings/github.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,30 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6-
package main
7-
8-
import (
9-
"github.com/google/go-github/v84/github"
10-
)
6+
package github
117

128
func main() {
139
file, content := getFileAndContent()
1410
opts := struct {
1511
Mode string
1612
}{Mode: "gfm"}
1713

18-
_ = github.Ptr(string(content))
14+
_ = Ptr(string(content))
1915

20-
_ = github.Ptr(file) // want `replace github.Ptr\(file\) with &file`
16+
_ = Ptr(file) // want `replace github.Ptr\(file\) with &file`
2117

2218
other := "b.txt"
23-
_ = github.Ptr(other) // want `replace github.Ptr\(other\) with &other`
24-
_ = github.Ptr(opts.Mode) // want `replace github.Ptr\(opts.Mode\) with &opts.Mode`
19+
_ = Ptr(other) // want `replace github.Ptr\(other\) with &other`
20+
_ = Ptr(opts.Mode) // want `replace github.Ptr\(opts.Mode\) with &opts.Mode`
2521

2622
for _, loopFile := range []string{"x", "y"} {
27-
_ = github.Ptr(loopFile) // want `replace github.Ptr\(loopFile\) with &loopFile`
23+
_ = Ptr(loopFile) // want `replace github.Ptr\(loopFile\) with &loopFile`
2824
}
2925

3026
name := "before"
31-
_ = github.Ptr(name) // want `replace github.Ptr\(name\) with &name`
27+
_ = Ptr(name) // want `replace github.Ptr\(name\) with &name`
3228
name = "after"
33-
_ = github.Ptr(name) // want `replace github.Ptr\(name\) with &name`
29+
_ = Ptr(name) // want `replace github.Ptr\(name\) with &name`
3430

3531
i := 1
3632
_ = Ptr(i) // want `replace github.Ptr\(i\) with &i`

tools/redundantptr/testdata/src/no-warnings/main.go renamed to tools/redundantptr/testdata/src/no-warnings/github.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6-
package main
7-
8-
import "github.com/google/go-github/v84/github"
6+
package github
97

108
func main() {
119
// Literal argument cannot be addressed.
12-
_ = github.Ptr("a.txt")
10+
_ = Ptr("a.txt")
1311

1412
const file = "a.txt"
15-
_ = github.Ptr(file)
13+
_ = Ptr(file)
1614

1715
for range []int{1, 2} {
18-
_ = github.Ptr("a")
16+
_ = Ptr("a")
1917
}
2018

21-
_ = github.Ptr(getOptions().Mode)
19+
_ = Ptr(getOptions().Mode)
2220
}
2321

2422
func getOptions() struct {

0 commit comments

Comments
 (0)