mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
ci: re-enable revive and gosec linters (#17225)
* Reenables revive linter for test files (with an exception for the `unused-parameter` rule) * Reenables gosec linter for test files
This commit is contained in:
@ -164,6 +164,7 @@ linters-settings:
|
|||||||
- name: unnecessary-stmt
|
- name: unnecessary-stmt
|
||||||
- name: unreachable-code
|
- name: unreachable-code
|
||||||
- name: unused-parameter
|
- name: unused-parameter
|
||||||
|
exclude: "**/*_test.go"
|
||||||
- name: unused-receiver
|
- name: unused-receiver
|
||||||
- name: var-declaration
|
- name: var-declaration
|
||||||
- name: var-naming
|
- name: var-naming
|
||||||
@ -195,8 +196,6 @@ issues:
|
|||||||
- errcheck
|
- errcheck
|
||||||
- forcetypeassert
|
- forcetypeassert
|
||||||
- exhaustruct # This is unhelpful in tests.
|
- 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/*
|
- path: scripts/*
|
||||||
linters:
|
linters:
|
||||||
- exhaustruct
|
- exhaustruct
|
||||||
|
@ -118,7 +118,7 @@ func TestBatchCreateLogs(t *testing.T) {
|
|||||||
level = database.LogLevel(strings.ToLower(logEntry.Level.String()))
|
level = database.LogLevel(strings.ToLower(logEntry.Level.String()))
|
||||||
}
|
}
|
||||||
insertWorkspaceAgentLogsParams.Level[i] = level
|
insertWorkspaceAgentLogsParams.Level[i] = level
|
||||||
insertWorkspaceAgentLogsParams.OutputLength += int32(len(logEntry.Output))
|
insertWorkspaceAgentLogsParams.OutputLength += int32(len(logEntry.Output)) // nolint:gosec
|
||||||
|
|
||||||
insertWorkspaceAgentLogsReturn[i] = database.WorkspaceAgentLog{
|
insertWorkspaceAgentLogsReturn[i] = database.WorkspaceAgentLog{
|
||||||
AgentID: agent.ID,
|
AgentID: agent.ID,
|
||||||
@ -270,7 +270,7 @@ func TestBatchCreateLogs(t *testing.T) {
|
|||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
Output: []string{"hello world"},
|
Output: []string{"hello world"},
|
||||||
Level: []database.LogLevel{database.LogLevelInfo},
|
Level: []database.LogLevel{database.LogLevelInfo},
|
||||||
OutputLength: int32(len(req.Logs[0].Output)),
|
OutputLength: int32(len(req.Logs[0].Output)), // nolint:gosec
|
||||||
}
|
}
|
||||||
dbInsertRes := []database.WorkspaceAgentLog{
|
dbInsertRes := []database.WorkspaceAgentLog{
|
||||||
{
|
{
|
||||||
|
@ -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()
|
t.Helper()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -249,7 +249,7 @@ func TestCache_BuildTime(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
|
dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
|
||||||
BuildNumber: int32(1 + buildNumber),
|
BuildNumber: int32(1 + buildNumber), // nolint:gosec
|
||||||
WorkspaceID: workspace.ID,
|
WorkspaceID: workspace.ID,
|
||||||
InitiatorID: user.ID,
|
InitiatorID: user.ID,
|
||||||
TemplateVersionID: templateVersion.ID,
|
TemplateVersionID: templateVersion.ID,
|
||||||
|
@ -354,10 +354,10 @@ func TestReportFailedWorkspaceBuilds(t *testing.T) {
|
|||||||
at := now.Add(-time.Duration(i) * time.Hour)
|
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}})
|
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}})
|
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
|
// When
|
||||||
|
@ -121,7 +121,7 @@ func TestLimitWriter(t *testing.T) {
|
|||||||
n, err := cryptorand.Read(data)
|
n, err := cryptorand.Read(data)
|
||||||
require.NoError(t, err, "crand read")
|
require.NoError(t, err, "crand read")
|
||||||
require.Equal(t, wc.N, n, "correct bytes read")
|
require.Equal(t, wc.N, n, "correct bytes read")
|
||||||
max := data[:wc.ExpN]
|
maxSeen := data[:wc.ExpN]
|
||||||
n, err = w.Write(data)
|
n, err = w.Write(data)
|
||||||
if wc.Err {
|
if wc.Err {
|
||||||
require.Error(t, err, "exp error")
|
require.Error(t, err, "exp error")
|
||||||
@ -131,7 +131,7 @@ func TestLimitWriter(t *testing.T) {
|
|||||||
|
|
||||||
// Need to use this to compare across multiple writes.
|
// Need to use this to compare across multiple writes.
|
||||||
// Each write appends to the expected output.
|
// 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, wc.ExpN, n, "correct bytes written")
|
||||||
require.Equal(t, allBuff.Bytes(), buf.Bytes(), "expected data")
|
require.Equal(t, allBuff.Bytes(), buf.Bytes(), "expected data")
|
||||||
|
@ -856,7 +856,7 @@ func TestLicenseEntitlements(t *testing.T) {
|
|||||||
generatedLicenses := make([]database.License, 0, len(tc.Licenses))
|
generatedLicenses := make([]database.License, 0, len(tc.Licenses))
|
||||||
for i, lo := range tc.Licenses {
|
for i, lo := range tc.Licenses {
|
||||||
generatedLicenses = append(generatedLicenses, database.License{
|
generatedLicenses = append(generatedLicenses, database.License{
|
||||||
ID: int32(i),
|
ID: int32(i), // nolint:gosec
|
||||||
UploadedAt: time.Now().Add(time.Hour * -1),
|
UploadedAt: time.Now().Add(time.Hour * -1),
|
||||||
JWT: lo.Generate(t),
|
JWT: lo.Generate(t),
|
||||||
Exp: lo.GraceAt,
|
Exp: lo.GraceAt,
|
||||||
|
@ -73,9 +73,9 @@ func TestWorkspaceQuota(t *testing.T) {
|
|||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
max := 1
|
maxWorkspaces := 1
|
||||||
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
||||||
UserWorkspaceQuota: max,
|
UserWorkspaceQuota: maxWorkspaces,
|
||||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||||
Features: license.Features{
|
Features: license.Features{
|
||||||
codersdk.FeatureTemplateRBAC: 1,
|
codersdk.FeatureTemplateRBAC: 1,
|
||||||
@ -195,9 +195,9 @@ func TestWorkspaceQuota(t *testing.T) {
|
|||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
max := 1
|
maxWorkspaces := 1
|
||||||
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
client, _, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
||||||
UserWorkspaceQuota: max,
|
UserWorkspaceQuota: maxWorkspaces,
|
||||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||||
Features: license.Features{
|
Features: license.Features{
|
||||||
codersdk.FeatureTemplateRBAC: 1,
|
codersdk.FeatureTemplateRBAC: 1,
|
||||||
|
@ -306,11 +306,11 @@ func makeJSONRPCRequest(t *testing.T, method, name string, args map[string]any)
|
|||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
Request: mcp.Request{Method: method},
|
Request: mcp.Request{Method: method},
|
||||||
Params: struct { // Unfortunately, there is no type for this yet.
|
Params: struct { // Unfortunately, there is no type for this yet.
|
||||||
Name string "json:\"name\""
|
Name string `json:"name"`
|
||||||
Arguments map[string]any "json:\"arguments,omitempty\""
|
Arguments map[string]any `json:"arguments,omitempty"`
|
||||||
Meta *struct {
|
Meta *struct {
|
||||||
ProgressToken mcp.ProgressToken "json:\"progressToken,omitempty\""
|
ProgressToken mcp.ProgressToken `json:"progressToken,omitempty"`
|
||||||
} "json:\"_meta,omitempty\""
|
} `json:"_meta,omitempty"`
|
||||||
}{
|
}{
|
||||||
Name: name,
|
Name: name,
|
||||||
Arguments: args,
|
Arguments: args,
|
||||||
|
Reference in New Issue
Block a user