Skip to content

Commit 36ddc0e

Browse files
build(deps): bump github.com/uudashr/iface from 1.3.2 to 1.4.0 (#5820)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent 79fb722 commit 36ddc0e

13 files changed

+116
-21
lines changed

.golangci.next.reference.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,7 @@ linters:
17951795
- identical # Identifies interfaces in the same package that have identical method sets.
17961796
- unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined.
17971797
- opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation.
1798+
- unexported # Identifies interfaces that are not exported but are used in exported functions or methods.
17981799
settings:
17991800
unused:
18001801
# List of packages path to exclude from the check.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ require (
119119
github.com/ultraware/funlen v0.2.0
120120
github.com/ultraware/whitespace v0.2.0
121121
github.com/uudashr/gocognit v1.2.0
122-
github.com/uudashr/iface v1.3.2
122+
github.com/uudashr/iface v1.4.0
123123
github.com/valyala/quicktemplate v1.8.0
124124
github.com/xen0n/gosmopolitan v1.3.0
125125
github.com/yagipy/maintidx v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@
661661
"enum": [
662662
"identical",
663663
"unused",
664-
"opaque"
664+
"opaque",
665+
"unexported"
665666
]
666667
},
667668
"tagliatelle-cases": {

pkg/golinters/iface/iface.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/uudashr/iface/identical"
77
"github.com/uudashr/iface/opaque"
8+
"github.com/uudashr/iface/unexported"
89
"github.com/uudashr/iface/unused"
910
"golang.org/x/tools/go/analysis"
1011

@@ -28,9 +29,10 @@ func New(settings *config.IfaceSettings) *goanalysis.Linter {
2829

2930
func analyzersFromSettings(settings *config.IfaceSettings) []*analysis.Analyzer {
3031
allAnalyzers := map[string]*analysis.Analyzer{
31-
"identical": identical.Analyzer,
32-
"unused": unused.Analyzer,
33-
"opaque": opaque.Analyzer,
32+
"identical": identical.Analyzer,
33+
"unused": unused.Analyzer,
34+
"opaque": opaque.Analyzer,
35+
"unexported": unexported.Analyzer,
3436
}
3537

3638
if settings == nil || len(settings.Enable) == 0 {

pkg/golinters/iface/testdata/iface_all.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import "fmt"
66

77
// identical
88

9-
type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy"
9+
type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy"
1010
Ping() error
1111
}
1212

13-
type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy"
13+
type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy"
1414
Ping() error
1515
}
1616

@@ -28,7 +28,7 @@ func (s server) Serve() error {
2828
return nil
2929
}
3030

31-
func NewServer(addr string) Server { // want "opaque: NewServer function return Server interface at the 1st result, abstract a single concrete implementation of \\*server"
31+
func NewServer(addr string) Server { // want "opaque: 'NewServer' function return 'Server' interface at the 1st result, abstract a single concrete implementation of '\\*server'"
3232
return &server{addr: addr}
3333
}
3434

@@ -39,7 +39,7 @@ type User struct {
3939
Name string
4040
}
4141

42-
type UserRepository interface { // want "unused: interface UserRepository is declared but not used within the package"
42+
type UserRepository interface { // want "unused: interface 'UserRepository' is declared but not used within the package"
4343
UserOf(id string) (*User, error)
4444
}
4545

pkg/golinters/iface/testdata/iface_cgo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func _() {
2424

2525
// identical
2626

27-
type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy"
27+
type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy"
2828
Ping() error
2929
}
3030

31-
type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy"
31+
type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy"
3232
Ping() error
3333
}
3434

pkg/golinters/iface/testdata/iface_default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import "fmt"
55

66
// identical
77

8-
type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy"
8+
type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy"
99
Ping() error
1010
}
1111

12-
type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy"
12+
type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy"
1313
Ping() error
1414
}
1515

pkg/golinters/iface/testdata/iface_identical.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import "fmt"
66

77
// identical
88

9-
type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy"
9+
type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy"
1010
Ping() error
1111
}
1212

13-
type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy"
13+
type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy"
1414
Ping() error
1515
}
1616

pkg/golinters/iface/testdata/iface_opaque.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (s server) Serve() error {
2828
return nil
2929
}
3030

31-
func NewServer(addr string) Server { // want "opaque: NewServer function return Server interface at the 1st result, abstract a single concrete implementation of \\*server"
31+
func NewServer(addr string) Server { // want "opaque: 'NewServer' function return 'Server' interface at the 1st result, abstract a single concrete implementation of '\\*server'"
3232
return &server{addr: addr}
3333
}
3434

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//golangcitest:args -Eiface
2+
//golangcitest:config_path testdata/iface_unexported.yml
3+
package testdata
4+
5+
import "fmt"
6+
7+
// identical
8+
9+
type Pinger interface {
10+
Ping() error
11+
}
12+
13+
type Healthcheck interface {
14+
Ping() error
15+
}
16+
17+
// opaque
18+
19+
type Server interface {
20+
Serve() error
21+
}
22+
23+
type server struct {
24+
addr string
25+
}
26+
27+
func (s server) Serve() error {
28+
return nil
29+
}
30+
31+
func NewServer(addr string) Server {
32+
return &server{addr: addr}
33+
}
34+
35+
// unused
36+
37+
type User struct {
38+
ID string
39+
Name string
40+
}
41+
42+
type UserRepository interface {
43+
UserOf(id string) (*User, error)
44+
}
45+
46+
type UserRepositorySQL struct {
47+
}
48+
49+
func (r *UserRepositorySQL) UserOf(id string) (*User, error) {
50+
return nil, nil
51+
}
52+
53+
type Granter interface {
54+
Grant(permission string) error
55+
}
56+
57+
func AllowAll(g Granter) error {
58+
return g.Grant("all")
59+
}
60+
61+
type Allower interface {
62+
Allow(permission string) error
63+
}
64+
65+
func Allow(x any) {
66+
_ = x.(Allower)
67+
fmt.Println("allow")
68+
}
69+
70+
// unexported
71+
72+
type unexportedReader interface {
73+
Read([]byte) (int, error)
74+
}
75+
76+
func ReadAll(r unexportedReader) ([]byte, error) { // want "unexported interface 'unexportedReader' used as parameter in exported function 'ReadAll'"
77+
buf := make([]byte, 1024)
78+
_, err := r.Read(buf)
79+
return buf, err
80+
}
81+
82+
func NewUnexportedReader() unexportedReader { // want "unexported interface 'unexportedReader' used as return value in exported function 'NewUnexportedReader'"
83+
return nil // stub
84+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
iface:
6+
enable:
7+
- unexported

pkg/golinters/iface/testdata/iface_unused.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import "fmt"
66

77
// identical
88

9-
type Pinger interface { // want "unused: interface Pinger is declared but not used within the package"
9+
type Pinger interface { // want "unused: interface 'Pinger' is declared but not used within the package"
1010
Ping() error
1111
}
1212

13-
type Healthcheck interface { // want "unused: interface Healthcheck is declared but not used within the package"
13+
type Healthcheck interface { // want "unused: interface 'Healthcheck' is declared but not used within the package"
1414
Ping() error
1515
}
1616

@@ -39,7 +39,7 @@ type User struct {
3939
Name string
4040
}
4141

42-
type UserRepository interface { // want "unused: interface UserRepository is declared but not used within the package"
42+
type UserRepository interface { // want "unused: interface 'UserRepository' is declared but not used within the package"
4343
UserOf(id string) (*User, error)
4444
}
4545

0 commit comments

Comments
 (0)