Skip to content

Commit d47559a

Browse files
authored
chore: Enable 'modernize'; bump golangci-lint to v2.6.1 (#3817)
1 parent 5953276 commit d47559a

File tree

10 files changed

+14
-9
lines changed

10 files changed

+14
-9
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v2.2.2
1+
version: v2.6.1
22
plugins:
33
- module: "github.com/google/go-github/v78/tools/fmtpercentv"
44
path: ./tools/fmtpercentv

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters:
1818
- intrange
1919
- jsonfieldname
2020
- misspell
21+
- modernize
2122
- musttag
2223
- nakedret
2324
- paralleltest
@@ -84,6 +85,9 @@ linters:
8485
ignore-rules:
8586
- analyses # returned by the GitHub API
8687
- cancelled # returned by the GitHub API
88+
modernize:
89+
disable:
90+
- omitzero # TODO: fix
8791
perfsprint:
8892
errorf: true
8993
strconcat: false

example/commitpr/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func getTree(ref *github.Reference) (tree *github.Tree, err error) {
100100
entries := []*github.TreeEntry{}
101101

102102
// Load each file into the tree.
103-
for _, fileArg := range strings.Split(*sourceFiles, ",") {
103+
for fileArg := range strings.SplitSeq(*sourceFiles, ",") {
104104
file, content, err := getFileContent(fileArg)
105105
if err != nil {
106106
return nil, err

github/github.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ func NewClientWithEnvProxy() *Client {
506506
}
507507

508508
// NewTokenClient returns a new GitHub API client authenticated with the provided token.
509+
//
509510
// Deprecated: Use NewClient(nil).WithAuthToken(token) instead.
510511
func NewTokenClient(_ context.Context, token string) *Client {
511512
// This always returns a nil error.
@@ -709,7 +710,7 @@ func newResponse(r *http.Response) *Response {
709710
// various pagination link values in the Response.
710711
func (r *Response) populatePageValues() {
711712
if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 {
712-
for _, link := range strings.Split(links[0], ",") {
713+
for link := range strings.SplitSeq(links[0], ",") {
713714
segments := strings.Split(strings.TrimSpace(link), ";")
714715

715716
// link must at least have href and rel

github/github_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ func TestWithEnterpriseURLs(t *testing.T) {
540540
// Ensure that length of Client.rateLimits is the same as number of fields in RateLimits struct.
541541
func TestClient_rateLimits(t *testing.T) {
542542
t.Parallel()
543-
if got, want := len(Client{}.rateLimits), reflect.TypeOf(RateLimits{}).NumField(); got != want {
543+
if got, want := len(Client{}.rateLimits), reflect.TypeFor[RateLimits]().NumField(); got != want {
544544
t.Errorf("len(Client{}.rateLimits) is %v, want %v", got, want)
545545
}
546546
}

github/issue_import_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestIssueImportService_CheckStatusSince(t *testing.T) {
225225
testHeader(t, r, "Accept", mediaTypeIssueImportAPI)
226226
w.WriteHeader(http.StatusOK)
227227
//nolint:fmtpercentv
228-
assertWrite(t, w, []byte(fmt.Sprintf("[%s]", issueImportResponseJSON)))
228+
assertWrite(t, w, fmt.Appendf(nil, "[%s]", issueImportResponseJSON))
229229
})
230230

231231
ctx := t.Context()

github/migrations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestMigrationService_ListMigrations(t *testing.T) {
6666

6767
w.WriteHeader(http.StatusOK)
6868
//nolint:fmtpercentv
69-
assertWrite(t, w, []byte(fmt.Sprintf("[%s]", migrationJSON)))
69+
assertWrite(t, w, fmt.Appendf(nil, "[%s]", migrationJSON))
7070
})
7171

7272
ctx := t.Context()

github/migrations_user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestMigrationService_ListUserMigrations(t *testing.T) {
6262

6363
w.WriteHeader(http.StatusOK)
6464
//nolint:fmtpercentv
65-
assertWrite(t, w, []byte(fmt.Sprintf("[%s]", userMigrationJSON)))
65+
assertWrite(t, w, fmt.Appendf(nil, "[%s]", userMigrationJSON))
6666
})
6767

6868
ctx := t.Context()

github/strings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"reflect"
1212
)
1313

14-
var timestampType = reflect.TypeOf(Timestamp{})
14+
var timestampType = reflect.TypeFor[Timestamp]()
1515

1616
// Stringify attempts to create a reasonable string representation of types in
1717
// the GitHub library. It does things like resolve pointers to their values

script/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
set -e
77

8-
GOLANGCI_LINT_VERSION="2.3.0"
8+
GOLANGCI_LINT_VERSION="2.6.1"
99

1010
CDPATH="" cd -- "$(dirname -- "$0")/.."
1111
BIN="$(pwd -P)"/bin

0 commit comments

Comments
 (0)