Skip to content

ci: re-enable revive and gosec linters #17225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ linters-settings:
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
exclude: "**/*_test.go"
- name: unused-receiver
- name: var-declaration
- name: var-naming
Expand Down Expand Up @@ -195,8 +196,6 @@ issues:
- errcheck
- forcetypeassert
- exhaustruct # This is unhelpful in tests.
- revive # TODO(JonA): disabling in order to update golangci-lint
- gosec # TODO(JonA): disabling in order to update golangci-lint
- path: scripts/*
linters:
- exhaustruct
Expand Down
4 changes: 2 additions & 2 deletions coderd/agentapi/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestBatchCreateLogs(t *testing.T) {
level = database.LogLevel(strings.ToLower(logEntry.Level.String()))
}
insertWorkspaceAgentLogsParams.Level[i] = level
insertWorkspaceAgentLogsParams.OutputLength += int32(len(logEntry.Output))
insertWorkspaceAgentLogsParams.OutputLength += int32(len(logEntry.Output)) // nolint:gosec

insertWorkspaceAgentLogsReturn[i] = database.WorkspaceAgentLog{
AgentID: agent.ID,
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestBatchCreateLogs(t *testing.T) {
CreatedAt: now,
Output: []string{"hello world"},
Level: []database.LogLevel{database.LogLevelInfo},
OutputLength: int32(len(req.Logs[0].Output)),
OutputLength: int32(len(req.Logs[0].Output)), // nolint:gosec
}
dbInsertRes := []database.WorkspaceAgentLog{
{
Expand Down
2 changes: 1 addition & 1 deletion coderd/idpsync/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ func (o orgSetupDefinition) Assert(t *testing.T, orgID uuid.UUID, db database.St
}
}

func (o orgGroupAssert) Assert(t *testing.T, orgID uuid.UUID, db database.Store, user database.User) {
func (o *orgGroupAssert) Assert(t *testing.T, orgID uuid.UUID, db database.Store, user database.User) {
t.Helper()

ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion coderd/metricscache/metricscache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestCache_BuildTime(t *testing.T) {
})

dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
BuildNumber: int32(1 + buildNumber),
BuildNumber: int32(1 + buildNumber), // nolint:gosec
WorkspaceID: workspace.ID,
InitiatorID: user.ID,
TemplateVersionID: templateVersion.ID,
Expand Down
4 changes: 2 additions & 2 deletions coderd/notifications/reports/generator_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ func TestReportFailedWorkspaceBuilds(t *testing.T) {
at := now.Add(-time.Duration(i) * time.Hour)

pj1 := dbgen.ProvisionerJob(t, db, ps, database.ProvisionerJob{OrganizationID: org.ID, Error: jobError, ErrorCode: jobErrorCode, CompletedAt: sql.NullTime{Time: at, Valid: true}})
_ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{WorkspaceID: w1.ID, BuildNumber: int32(i), TemplateVersionID: t1v1.ID, JobID: pj1.ID, CreatedAt: at, Transition: database.WorkspaceTransitionStart, Reason: database.BuildReasonInitiator})
_ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{WorkspaceID: w1.ID, BuildNumber: int32(i), TemplateVersionID: t1v1.ID, JobID: pj1.ID, CreatedAt: at, Transition: database.WorkspaceTransitionStart, Reason: database.BuildReasonInitiator}) // nolint:gosec

pj2 := dbgen.ProvisionerJob(t, db, ps, database.ProvisionerJob{OrganizationID: org.ID, Error: jobError, ErrorCode: jobErrorCode, CompletedAt: sql.NullTime{Time: at, Valid: true}})
_ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{WorkspaceID: w1.ID, BuildNumber: int32(i) + 100, TemplateVersionID: t1v2.ID, JobID: pj2.ID, CreatedAt: at, Transition: database.WorkspaceTransitionStart, Reason: database.BuildReasonInitiator})
_ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{WorkspaceID: w1.ID, BuildNumber: int32(i) + 100, TemplateVersionID: t1v2.ID, JobID: pj2.ID, CreatedAt: at, Transition: database.WorkspaceTransitionStart, Reason: database.BuildReasonInitiator}) // nolint:gosec
}

// When
Expand Down
4 changes: 2 additions & 2 deletions coderd/util/xio/limitwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestLimitWriter(t *testing.T) {
n, err := cryptorand.Read(data)
require.NoError(t, err, "crand read")
require.Equal(t, wc.N, n, "correct bytes read")
max := data[:wc.ExpN]
maxSeen := data[:wc.ExpN]
n, err = w.Write(data)
if wc.Err {
require.Error(t, err, "exp error")
Expand All @@ -131,7 +131,7 @@ func TestLimitWriter(t *testing.T) {

// Need to use this to compare across multiple writes.
// Each write appends to the expected output.
allBuff.Write(max)
allBuff.Write(maxSeen)

require.Equal(t, wc.ExpN, n, "correct bytes written")
require.Equal(t, allBuff.Bytes(), buf.Bytes(), "expected data")
Expand Down
2 changes: 1 addition & 1 deletion enterprise/coderd/license/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func TestLicenseEntitlements(t *testing.T) {
generatedLicenses := make([]database.License, 0, len(tc.Licenses))
for i, lo := range tc.Licenses {
generatedLicenses = append(generatedLicenses, database.License{
ID: int32(i),
ID: int32(i), // nolint:gosec
UploadedAt: time.Now().Add(time.Hour * -1),
JWT: lo.Generate(t),
Exp: lo.GraceAt,
Expand Down
8 changes: 4 additions & 4 deletions enterprise/coderd/workspacequota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func TestWorkspaceQuota(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
max := 1
maxWorkspaces := 1
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
UserWorkspaceQuota: max,
UserWorkspaceQuota: maxWorkspaces,
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
Expand Down Expand Up @@ -195,9 +195,9 @@ func TestWorkspaceQuota(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
max := 1
maxWorkspaces := 1
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
UserWorkspaceQuota: max,
UserWorkspaceQuota: maxWorkspaces,
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
Expand Down
8 changes: 4 additions & 4 deletions mcp/mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ func makeJSONRPCRequest(t *testing.T, method, name string, args map[string]any)
JSONRPC: "2.0",
Request: mcp.Request{Method: method},
Params: struct { // Unfortunately, there is no type for this yet.
Name string "json:\"name\""
Arguments map[string]any "json:\"arguments,omitempty\""
Name string `json:"name"`
Arguments map[string]any `json:"arguments,omitempty"`
Meta *struct {
ProgressToken mcp.ProgressToken "json:\"progressToken,omitempty\""
} "json:\"_meta,omitempty\""
ProgressToken mcp.ProgressToken `json:"progressToken,omitempty"`
} `json:"_meta,omitempty"`
}{
Name: name,
Arguments: args,
Expand Down
Loading