Skip to content

Commit a85fd8b

Browse files
committed
chore: upgrade golangci-lint to v1.60.0
1 parent c96d439 commit a85fd8b

File tree

17 files changed

+27
-82
lines changed

17 files changed

+27
-82
lines changed

.github/workflows/coder.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: golangci-lint
4343
uses: golangci/golangci-lint-action@v3.1.0
4444
with:
45-
version: v1.45.2
45+
version: v1.46.0
4646

4747
style-lint-typescript:
4848
name: "style/lint/typescript"

.golangci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ linters-settings:
105105
failOn: all
106106
rules: rules.go
107107

108+
staticcheck:
109+
# https://staticcheck.io/docs/options#checks
110+
checks: ["all", "-SA1019"]
111+
108112
goimports:
109113
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
110114

@@ -235,7 +239,7 @@ linters:
235239
# without testing any exported functions. This is enabled to promote
236240
# decomposing a package before testing it's internals. A function caller
237241
# should be able to test most of the functionality from exported functions.
238-
#
242+
#
239243
# There are edge-cases to this rule, but they should be carefully considered
240244
# to avoid structural inconsistency.
241245
- testpackage

cli/gitssh_test.go

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

6161
// start workspace agent
6262
cmd, root := clitest.New(t, "agent", "--agent-token", agentToken, "--agent-url", client.URL.String())
63-
agentClient := &*client
63+
agentClient := client
6464
clitest.SetupConfig(t, agentClient, root)
6565
ctx, cancelFunc := context.WithCancel(context.Background())
6666
defer cancelFunc()

cli/ssh.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package cli
33
import (
44
"context"
55
"io"
6-
"net"
76
"os"
87
"strings"
9-
"time"
108

119
"github.com/google/uuid"
1210
"github.com/mattn/go-isatty"
@@ -181,32 +179,3 @@ func ssh() *cobra.Command {
181179

182180
return cmd
183181
}
184-
185-
type stdioConn struct {
186-
io.Reader
187-
io.Writer
188-
}
189-
190-
func (*stdioConn) Close() (err error) {
191-
return nil
192-
}
193-
194-
func (*stdioConn) LocalAddr() net.Addr {
195-
return nil
196-
}
197-
198-
func (*stdioConn) RemoteAddr() net.Addr {
199-
return nil
200-
}
201-
202-
func (*stdioConn) SetDeadline(_ time.Time) error {
203-
return nil
204-
}
205-
206-
func (*stdioConn) SetReadDeadline(_ time.Time) error {
207-
return nil
208-
}
209-
210-
func (*stdioConn) SetWriteDeadline(_ time.Time) error {
211-
return nil
212-
}

coderd/audit/backends/postgres.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,7 @@ func (b *postgresBackend) Decision() audit.FilterDecision {
3131
}
3232

3333
func (b *postgresBackend) Export(ctx context.Context, alog database.AuditLog) error {
34-
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams{
35-
ID: alog.ID,
36-
Time: alog.Time,
37-
UserID: alog.UserID,
38-
OrganizationID: alog.OrganizationID,
39-
Ip: alog.Ip,
40-
UserAgent: alog.UserAgent,
41-
ResourceType: alog.ResourceType,
42-
ResourceID: alog.ResourceID,
43-
ResourceTarget: alog.ResourceTarget,
44-
Action: alog.Action,
45-
Diff: alog.Diff,
46-
StatusCode: alog.StatusCode,
47-
})
34+
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams(alog))
4835
if err != nil {
4936
return xerrors.Errorf("insert audit log: %w", err)
5037
}

coderd/coderdtest/coderdtest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func New(t *testing.T, options *Options) *codersdk.Client {
7777
db := databasefake.New()
7878
pubsub := database.NewPubsubInMemory()
7979
if os.Getenv("DB") != "" {
80-
connectionURL, close, err := postgres.Open()
80+
connectionURL, closePg, err := postgres.Open()
8181
require.NoError(t, err)
82-
t.Cleanup(close)
82+
t.Cleanup(closePg)
8383
sqlDB, err := sql.Open("postgres", connectionURL)
8484
require.NoError(t, err)
8585
t.Cleanup(func() {

coderd/database/databasefake/databasefake.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,20 +1733,7 @@ func (q *fakeQuerier) InsertAuditLog(_ context.Context, arg database.InsertAudit
17331733
q.mutex.Lock()
17341734
defer q.mutex.Unlock()
17351735

1736-
alog := database.AuditLog{
1737-
ID: arg.ID,
1738-
Time: arg.Time,
1739-
UserID: arg.UserID,
1740-
OrganizationID: arg.OrganizationID,
1741-
Ip: arg.Ip,
1742-
UserAgent: arg.UserAgent,
1743-
ResourceType: arg.ResourceType,
1744-
ResourceID: arg.ResourceID,
1745-
ResourceTarget: arg.ResourceTarget,
1746-
Action: arg.Action,
1747-
Diff: arg.Diff,
1748-
StatusCode: arg.StatusCode,
1749-
}
1736+
alog := database.AuditLog(arg)
17501737

17511738
q.auditLogs = append(q.auditLogs, alog)
17521739
slices.SortFunc(q.auditLogs, func(a, b database.AuditLog) bool {

coderd/database/postgres/postgres_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import (
66
"database/sql"
77
"testing"
88

9+
_ "github.com/lib/pq"
910
"github.com/stretchr/testify/require"
1011
"go.uber.org/goleak"
1112

1213
"github.com/coder/coder/coderd/database/postgres"
13-
14-
_ "github.com/lib/pq"
1514
)
1615

1716
func TestMain(m *testing.M) {
@@ -26,9 +25,9 @@ func TestPostgres(t *testing.T) {
2625
return
2726
}
2827

29-
connect, close, err := postgres.Open()
28+
connect, closePg, err := postgres.Open()
3029
require.NoError(t, err)
31-
defer close()
30+
defer closePg()
3231
db, err := sql.Open("postgres", connect)
3332
require.NoError(t, err)
3433
err = db.Ping()

coderd/database/pubsub_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func TestPubsub(t *testing.T) {
2727
ctx, cancelFunc := context.WithCancel(context.Background())
2828
defer cancelFunc()
2929

30-
connectionURL, close, err := postgres.Open()
30+
connectionURL, closePg, err := postgres.Open()
3131
require.NoError(t, err)
32-
defer close()
32+
defer closePg()
3333
db, err := sql.Open("postgres", connectionURL)
3434
require.NoError(t, err)
3535
defer db.Close()
@@ -56,9 +56,9 @@ func TestPubsub(t *testing.T) {
5656
t.Parallel()
5757
ctx, cancelFunc := context.WithCancel(context.Background())
5858
defer cancelFunc()
59-
connectionURL, close, err := postgres.Open()
59+
connectionURL, closePg, err := postgres.Open()
6060
require.NoError(t, err)
61-
defer close()
61+
defer closePg()
6262
db, err := sql.Open("postgres", connectionURL)
6363
require.NoError(t, err)
6464
defer db.Close()

coderd/httpmw/oauth2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
4848
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
4949
if config == nil {
5050
httpapi.Write(rw, http.StatusPreconditionRequired, httpapi.Response{
51-
Message: fmt.Sprintf("The oauth2 method requested is not configured!"),
51+
Message: "The oauth2 method requested is not configured!",
5252
})
5353
return
5454
}

coderd/members.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package coderd
22

33
import (
44
"context"
5-
"fmt"
65
"net/http"
76

87
"github.com/google/uuid"
@@ -29,7 +28,7 @@ func (api *api) putMemberRoles(rw http.ResponseWriter, r *http.Request) {
2928
// the selected organization. Until then, allow anarchy
3029
if apiKey.UserID != user.ID {
3130
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
32-
Message: fmt.Sprintf("modifying other users is not supported at this time"),
31+
Message: "modifying other users is not supported at this time",
3332
})
3433
return
3534
}

coderd/rbac/authz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (a RegoAuthorizer) Authorize(ctx context.Context, subjectID string, roles [
6767

6868
results, err := a.query.Eval(ctx, rego.EvalInput(input))
6969
if err != nil {
70-
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w, err"), input, results)
70+
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w", err), input, results)
7171
}
7272

7373
if len(results) != 1 {

coderd/userauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (api *api) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
5858
}
5959
if selectedMembership == nil {
6060
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
61-
Message: fmt.Sprintf("You aren't a member of the authorized Github organizations!"),
61+
Message: "You aren't a member of the authorized Github organizations!",
6262
})
6363
return
6464
}

coderd/users.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func (api *api) putUserProfile(rw http.ResponseWriter, r *http.Request) {
266266
})
267267
}
268268
httpapi.Write(rw, http.StatusConflict, httpapi.Response{
269-
Message: fmt.Sprintf("user already exists"),
269+
Message: "user already exists",
270270
Errors: responseErrors,
271271
})
272272
return
@@ -391,7 +391,7 @@ func (api *api) putUserRoles(rw http.ResponseWriter, r *http.Request) {
391391
apiKey := httpmw.APIKey(r)
392392
if apiKey.UserID != user.ID {
393393
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
394-
Message: fmt.Sprintf("modifying other users is not supported at this time"),
394+
Message: "modifying other users is not supported at this time",
395395
})
396396
return
397397
}

coderd/workspaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (api *api) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
213213
return xerrors.Errorf("insert provisioner job: %w", err)
214214
}
215215
state := createBuild.ProvisionerState
216-
if state == nil || len(state) == 0 {
216+
if len(state) == 0 {
217217
state = priorHistory.ProvisionerState
218218
}
219219

codersdk/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, erro
307307
// Users returns all users according to the request parameters. If no parameters are set,
308308
// the default behavior is to return all users in a single page.
309309
func (c *Client) Users(ctx context.Context, req UsersRequest) ([]User, error) {
310-
res, err := c.request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users"), nil,
310+
res, err := c.request(ctx, http.MethodGet, "/api/v2/users", nil,
311311
req.Pagination.asRequestOption(),
312312
func(r *http.Request) {
313313
q := r.URL.Query()

scripts/apitypings/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (g *Generator) generateAll() (*TypescriptTypes, error) {
176176
st, _ := obj.Type().Underlying().(*types.Struct)
177177
codeBlock, err := g.buildStruct(obj, st)
178178
if err != nil {
179-
return nil, xerrors.Errorf("generate %q: %w", obj.Name())
179+
return nil, xerrors.Errorf("generate %q: %w", obj.Name(), err)
180180
}
181181
structs[obj.Name()] = codeBlock
182182
case *types.Basic:

0 commit comments

Comments
 (0)