Skip to content

Commit 489d99e

Browse files
author
schlehlein
committed
refactor: match func names
1 parent f6aef1e commit 489d99e

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

parse.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ const (
3232
)
3333

3434
var DefaultMatchers = []Matcher{
35-
MatcherFunc(EmailMatcher),
36-
MatcherFunc(TeamMatcher),
37-
MatcherFunc(UsernameMatcher),
35+
MatcherFunc(MatchEmail),
36+
MatcherFunc(MatchTeam),
37+
MatcherFunc(MatchUsername),
3838
}
3939

4040
type Matcher interface {
41+
// Matches give string agains a pattern e.g. a regexp.
42+
// Should return ErrNoMatch if the pattern doesn't match.
4143
Match(s string) (Owner, error)
4244
}
4345

@@ -47,7 +49,7 @@ func (f MatcherFunc) Match(s string) (Owner, error) {
4749
return f(s)
4850
}
4951

50-
func EmailMatcher(s string) (Owner, error) {
52+
func MatchEmail(s string) (Owner, error) {
5153
match := emailRegexp.FindStringSubmatch(s)
5254
if match == nil {
5355
return Owner{}, ErrNoMatch
@@ -56,7 +58,7 @@ func EmailMatcher(s string) (Owner, error) {
5658
return Owner{Value: match[0], Type: EmailOwner}, nil
5759
}
5860

59-
func TeamMatcher(s string) (Owner, error) {
61+
func MatchTeam(s string) (Owner, error) {
6062
match := teamRegexp.FindStringSubmatch(s)
6163
if match == nil {
6264
return Owner{}, ErrNoMatch
@@ -65,7 +67,7 @@ func TeamMatcher(s string) (Owner, error) {
6567
return Owner{Value: match[1], Type: TeamOwner}, nil
6668
}
6769

68-
func UsernameMatcher(s string) (Owner, error) {
70+
func MatchUsername(s string) (Owner, error) {
6971
match := usernameRegexp.FindStringSubmatch(s)
7072
if match == nil {
7173
return Owner{}, ErrNoMatch

parse_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,26 @@ func TestParseRule(t *testing.T) {
147147
name: "email owners without email matcher",
148148
rule: "file.txt foo@example.com",
149149
matcher: []Matcher{
150-
MatcherFunc(TeamMatcher),
151-
MatcherFunc(UsernameMatcher),
150+
MatcherFunc(MatchTeam),
151+
MatcherFunc(MatchUsername),
152152
},
153153
err: "invalid owner format 'foo@example.com' at position 10",
154154
},
155155
{
156156
name: "team owners without team matcher",
157157
rule: "file.txt @org/team",
158158
matcher: []Matcher{
159-
MatcherFunc(EmailMatcher),
160-
MatcherFunc(UsernameMatcher),
159+
MatcherFunc(MatchEmail),
160+
MatcherFunc(MatchUsername),
161161
},
162162
err: "invalid owner format '@org/team' at position 10",
163163
},
164164
{
165165
name: "username owners without username matcher",
166166
rule: "file.txt @user",
167167
matcher: []Matcher{
168-
MatcherFunc(EmailMatcher),
169-
MatcherFunc(TeamMatcher),
168+
MatcherFunc(MatchEmail),
169+
MatcherFunc(MatchTeam),
170170
},
171171
err: "invalid owner format '@user' at position 10",
172172
},

0 commit comments

Comments
 (0)