Skip to content

Commit a154189

Browse files
committed
chore: update linter, dependencies, and code
1 parent 15d2bcb commit a154189

File tree

8 files changed

+41
-65
lines changed

8 files changed

+41
-65
lines changed

.github/workflows/go-cross.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
# https://github.com/marketplace/actions/setup-go-environment
2424
- name: Set up Go ${{ matrix.go-version }}
25-
uses: actions/setup-go@v4
25+
uses: actions/setup-go@v5
2626
with:
2727
go-version: ${{ matrix.go-version }}
2828

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
env:
1717
GO_VERSION: stable
18-
GOLANGCI_LINT_VERSION: v1.55.1
18+
GOLANGCI_LINT_VERSION: v1.56.1
1919
CGO_ENABLED: 0
2020

2121
steps:

LICENCE

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176

177177
END OF TERMS AND CONDITIONS
178178

179-
Copyright 2013-2017 Docker, Inc.
179+
Copyright 2013-2024 Fernandez Ludovic
180180

181181
Licensed under the Apache License, Version 2.0 (the "License");
182182
you may not use this file except in compliance with the License.

core/generator.go

+16-35
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"log"
99
"os"
10+
"slices"
1011
"sort"
1112
"strings"
1213
"time"
@@ -99,7 +100,7 @@ func searchAllIssues(ctx context.Context, client *github.Client, query string, s
99100
log.Fatal(err)
100101
}
101102
for _, issue := range issuesSearchResult.Issues {
102-
if containsLeastOne(issue.Labels, config.LabelExcludes) {
103+
if containsLeastOneLabel(issue.Labels, config.LabelExcludes) {
103104
if config.Debug {
104105
log.Println("Exclude:", issue.GetNumber(), issue.GetTitle())
105106
}
@@ -123,11 +124,11 @@ func display(config *types.Configuration, issues []*github.Issue, commitCurrentR
123124

124125
for _, issue := range issues {
125126
switch {
126-
case contains(issue.Labels, config.LabelDocumentation):
127+
case containsLabel(issue.Labels, config.LabelDocumentation):
127128
summary.Documentation = makeAndAppendIssueSummary(summary.Documentation, issue, config)
128-
case contains(issue.Labels, config.LabelEnhancement):
129+
case containsLabel(issue.Labels, config.LabelEnhancement):
129130
summary.Enhancement = makeAndAppendIssueSummary(summary.Enhancement, issue, config)
130-
case contains(issue.Labels, config.LabelBug):
131+
case containsLabel(issue.Labels, config.LabelBug):
131132
summary.Bug = makeAndAppendIssueSummary(summary.Bug, issue, config)
132133
default:
133134
summary.Other = makeAndAppendIssueSummary(summary.Other, issue, config)
@@ -176,44 +177,24 @@ func display(config *types.Configuration, issues []*github.Issue, commitCurrentR
176177
}
177178

178179
func newGitHubClient(ctx context.Context, token string) *github.Client {
179-
var client *github.Client
180180
if token == "" {
181-
client = github.NewClient(nil)
182-
} else {
183-
ts := oauth2.StaticTokenSource(
184-
&oauth2.Token{AccessToken: token},
185-
)
186-
tc := oauth2.NewClient(ctx, ts)
187-
client = github.NewClient(tc)
181+
return github.NewClient(nil)
188182
}
189-
return client
190-
}
191183

192-
func contains(labels []*github.Label, str string) bool {
193-
for _, lbl := range labels {
194-
if *lbl.Name == str {
195-
return true
196-
}
197-
}
198-
return false
184+
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
185+
return github.NewClient(oauth2.NewClient(ctx, ts))
199186
}
200187

201-
func containsLeastOne(labels []*github.Label, values []string) bool {
202-
for _, lbl := range labels {
203-
if isIn(lbl.GetName(), values) {
204-
return true
205-
}
206-
}
207-
return false
188+
func containsLabel(labels []*github.Label, str string) bool {
189+
return slices.ContainsFunc(labels, func(lbl *github.Label) bool {
190+
return lbl.GetName() == str
191+
})
208192
}
209193

210-
func isIn(name string, values []string) bool {
211-
for _, value := range values {
212-
if value == name {
213-
return true
214-
}
215-
}
216-
return false
194+
func containsLeastOneLabel(labels []*github.Label, values []string) bool {
195+
return slices.ContainsFunc(labels, func(lbl *github.Label) bool {
196+
return slices.Contains(values, lbl.GetName())
197+
})
217198
}
218199

219200
func makeAndAppendIssueSummary(summaries []types.IssueSummary, issue *github.Issue, config *types.Configuration) []types.IssueSummary {

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ require (
88
github.com/google/go-github/v32 v32.1.0
99
github.com/ogier/pflag v0.0.1
1010
github.com/stretchr/testify v1.8.4
11-
golang.org/x/oauth2 v0.13.0
11+
golang.org/x/oauth2 v0.17.0
1212
)
1313

1414
require (
15-
github.com/BurntSushi/toml v1.2.1 // indirect
15+
github.com/BurntSushi/toml v1.3.2 // indirect
1616
github.com/abronan/valkeyrie v0.0.0-20190802193736-ed4c4a229894 // indirect
1717
github.com/davecgh/go-spew v1.1.1 // indirect
1818
github.com/golang/protobuf v1.5.3 // indirect
1919
github.com/google/go-querystring v1.1.0 // indirect
2020
github.com/mitchellh/mapstructure v1.5.0 // indirect
2121
github.com/pmezard/go-difflib v1.0.0 // indirect
22-
golang.org/x/crypto v0.14.0 // indirect
22+
golang.org/x/crypto v0.19.0 // indirect
2323
google.golang.org/appengine v1.6.8 // indirect
24-
google.golang.org/protobuf v1.31.0 // indirect
24+
google.golang.org/protobuf v1.32.0 // indirect
2525
gopkg.in/yaml.v3 v3.0.1 // indirect
2626
)

go.sum

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2-
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
3-
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
2+
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
3+
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
44
github.com/abronan/valkeyrie v0.0.0-20190802193736-ed4c4a229894 h1:6oe+/ZnkM+gEJL+28sgHiCvO6qt15NE2lm52BuzBees=
55
github.com/abronan/valkeyrie v0.0.0-20190802193736-ed4c4a229894/go.mod h1:sQZ/48uDt1GRBDNsLboJGPD2w/HxEOhqf3JiikfHj1I=
66
github.com/aws/aws-sdk-go v1.16.23/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
@@ -62,8 +62,8 @@ go.etcd.io/bbolt v1.3.1-etcd.8/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XK
6262
go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
6363
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
6464
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
65-
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
66-
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
65+
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
66+
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
6767
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
6868
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
6969
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -73,8 +73,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
7373
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
7474
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
7575
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
76-
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
77-
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
76+
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
77+
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
7878
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7979
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8080
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -104,8 +104,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
104104
google.golang.org/grpc v1.18.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
105105
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
106106
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
107-
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
108-
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
107+
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
108+
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
109109
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
110110
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
111111
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

label/label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ func FilterAndTransform(labels []*github.Label, filter Predicate, transform Name
99
var results []string
1010
for _, lbl := range labels {
1111
if filter(lbl) {
12-
results = append(results, transform(*lbl.Name))
12+
results = append(results, transform(lbl.GetName()))
1313
}
1414
}
1515
return results

label/predicate.go

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package label
22

33
import (
4+
"slices"
45
"strings"
56

67
"github.com/google/go-github/v32/github"
@@ -29,37 +30,31 @@ func Not(predicate Predicate) Predicate {
2930
// HasPrefix label predicate.
3031
func HasPrefix(prefix string) Predicate {
3132
return func(label *github.Label) bool {
32-
return strings.HasPrefix(*label.Name, prefix)
33+
return strings.HasPrefix(label.GetName(), prefix)
3334
}
3435
}
3536

3637
// HasSuffix label predicate.
3738
func HasSuffix(suffix string) Predicate {
3839
return func(label *github.Label) bool {
39-
return strings.HasSuffix(*label.Name, suffix)
40+
return strings.HasSuffix(label.GetName(), suffix)
4041
}
4142
}
4243

4344
// AllMatch label predicate.
4445
func AllMatch(predicates ...Predicate) Predicate {
4546
return func(label *github.Label) bool {
46-
for _, predicate := range predicates {
47-
if !predicate(label) {
48-
return false
49-
}
50-
}
51-
return true
47+
return !slices.ContainsFunc(predicates, func(predicate Predicate) bool {
48+
return !predicate(label)
49+
})
5250
}
5351
}
5452

5553
// AnyMatch label predicate.
5654
func AnyMatch(predicates ...Predicate) Predicate {
5755
return func(label *github.Label) bool {
58-
for _, predicate := range predicates {
59-
if predicate(label) {
60-
return true
61-
}
62-
}
63-
return false
56+
return slices.ContainsFunc(predicates, func(predicate Predicate) bool {
57+
return predicate(label)
58+
})
6459
}
6560
}

0 commit comments

Comments
 (0)