Skip to content

Commit 7e0ceec

Browse files
committed
fix more linting rules
1 parent d9b665c commit 7e0ceec

File tree

13 files changed

+25
-50
lines changed

13 files changed

+25
-50
lines changed

cli/remoteforward.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func validateRemoteForward(flag string) bool {
4040
return isRemoteForwardTCP(flag) || isRemoteForwardUnixSocket(flag)
4141
}
4242

43-
func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
43+
func parseRemoteForwardTCP(matches []string) (local net.Addr, remote net.Addr, err error) {
4444
remotePort, err := strconv.Atoi(matches[1])
4545
if err != nil {
4646
return nil, nil, xerrors.Errorf("remote port is invalid: %w", err)
@@ -69,7 +69,7 @@ func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
6969
// parseRemoteForwardUnixSocket parses a remote forward flag. Note that
7070
// we don't verify that the local socket path exists because the user
7171
// may create it later. This behavior matches OpenSSH.
72-
func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error) {
72+
func parseRemoteForwardUnixSocket(matches []string) (local net.Addr, remote net.Addr, err error) {
7373
remoteSocket := matches[1]
7474
localSocket := matches[2]
7575

@@ -85,7 +85,7 @@ func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error)
8585
return localAddr, remoteAddr, nil
8686
}
8787

88-
func parseRemoteForward(flag string) (net.Addr, net.Addr, error) {
88+
func parseRemoteForward(flag string) (local net.Addr, remote net.Addr, err error) {
8989
tcpMatches := remoteForwardRegexTCP.FindStringSubmatch(flag)
9090

9191
if len(tcpMatches) > 0 {

cli/root.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command) {
172172
err = exitErr.err
173173
}
174174
if errors.Is(err, cliui.ErrCanceled) {
175-
//nolint:revive
175+
//nolint:revive,gocritic
176176
os.Exit(code)
177177
}
178178
f := PrettyErrorFormatter{w: os.Stderr, verbose: r.verbose}
179179
if err != nil {
180180
f.Format(err)
181181
}
182-
//nolint:revive
182+
//nolint:revive,gocritic
183183
os.Exit(code)
184184
}
185185
}
@@ -891,7 +891,7 @@ func DumpHandler(ctx context.Context, name string) {
891891

892892
done:
893893
if sigStr == "SIGQUIT" {
894-
//nolint:revive
894+
//nolint:revive,gocritic
895895
os.Exit(1)
896896
}
897897
}

cmd/coder/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
func main() {
16+
panic("hey")
1617
if len(os.Args) > 1 && os.Args[1] == "agent-exec" {
1718
err := agentexec.CLI()
1819
_, _ = fmt.Fprintln(os.Stderr, err)

coderd/database/dbauthz/dbauthz.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,8 +1663,8 @@ func (q *querier) GetDeploymentWorkspaceStats(ctx context.Context) (database.Get
16631663
return q.db.GetDeploymentWorkspaceStats(ctx)
16641664
}
16651665

1666-
func (q *querier) GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context, provisionerJobIds []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow, error) {
1667-
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx, provisionerJobIds)
1666+
func (q *querier) GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context, provisionerJobIDs []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow, error) {
1667+
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx, provisionerJobIDs)
16681668
}
16691669

16701670
func (q *querier) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) {
@@ -3017,11 +3017,11 @@ func (q *querier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, created
30173017
return q.db.GetWorkspaceResourcesCreatedAfter(ctx, createdAt)
30183018
}
30193019

3020-
func (q *querier) GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx context.Context, templateIds []uuid.UUID) ([]database.GetWorkspaceUniqueOwnerCountByTemplateIDsRow, error) {
3020+
func (q *querier) GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx context.Context, templateIDs []uuid.UUID) ([]database.GetWorkspaceUniqueOwnerCountByTemplateIDsRow, error) {
30213021
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem); err != nil {
30223022
return nil, err
30233023
}
3024-
return q.db.GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx, templateIds)
3024+
return q.db.GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx, templateIDs)
30253025
}
30263026

30273027
func (q *querier) GetWorkspaces(ctx context.Context, arg database.GetWorkspacesParams) ([]database.GetWorkspacesRow, error) {

coderd/rbac/regosql/compile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func convertQuery(cfg ConvertConfig, q ast.Body) (sqltypes.BooleanNode, error) {
7878

7979
func convertExpression(cfg ConvertConfig, e *ast.Expr) (sqltypes.BooleanNode, error) {
8080
if e.IsCall() {
81+
//nolint:forcetypeassert
8182
n, err := convertCall(cfg, e.Terms.([]*ast.Term))
8283
if err != nil {
8384
return nil, xerrors.Errorf("call: %w", err)

coderd/util/tz/tz_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TimezoneIANA() (*time.Location, error) {
3535
if err != nil {
3636
return nil, xerrors.Errorf("read location of %s: %w", etcLocaltime, err)
3737
}
38-
stripped := strings.Replace(lp, zoneInfoPath, "", -1)
38+
stripped := strings.ReplaceAll(lp, zoneInfoPath, "")
3939
stripped = strings.TrimPrefix(stripped, string(filepath.Separator))
4040
loc, err = time.LoadLocation(stripped)
4141
if err != nil {

coderd/workspaces_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestWorkspace(t *testing.T) {
129129
want = want[:32-5] + "-test"
130130
}
131131
// Sometimes truncated names result in `--test` which is not an allowed name.
132-
want = strings.Replace(want, "--", "-", -1)
132+
want = strings.ReplaceAll(want, "--", "-")
133133
err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{
134134
Name: want,
135135
})

helm/provisioner/tests/chart_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func TestRenderChart(t *testing.T) {
160160
require.NoError(t, err, "failed to read golden file %q", goldenFilePath)
161161

162162
// Remove carriage returns to make tests pass on Windows.
163-
goldenBytes = bytes.Replace(goldenBytes, []byte("\r"), []byte(""), -1)
163+
goldenBytes = bytes.ReplaceAll(goldenBytes, []byte("\r"), []byte(""))
164164
expected := string(goldenBytes)
165165

166166
require.NoError(t, err, "failed to load golden file %q")

provisioner/terraform/provision_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"net/http"
1212
"os"
1313
"path/filepath"
14-
"runtime"
1514
"sort"
1615
"strings"
1716
"testing"
@@ -119,10 +118,6 @@ func sendApply(sess proto.DRPCProvisioner_SessionClient, transition proto.Worksp
119118
// one process tries to do this simultaneously, it can cause "text file busy"
120119
// nolint: paralleltest
121120
func TestProvision_Cancel(t *testing.T) {
122-
if runtime.GOOS == "windows" {
123-
t.Skip("This test uses interrupts and is not supported on Windows")
124-
}
125-
126121
cwd, err := os.Getwd()
127122
require.NoError(t, err)
128123
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel.sh")
@@ -215,10 +210,6 @@ func TestProvision_Cancel(t *testing.T) {
215210
// one process tries to do this, it can cause "text file busy"
216211
// nolint: paralleltest
217212
func TestProvision_CancelTimeout(t *testing.T) {
218-
if runtime.GOOS == "windows" {
219-
t.Skip("This test uses interrupts and is not supported on Windows")
220-
}
221-
222213
cwd, err := os.Getwd()
223214
require.NoError(t, err)
224215
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel_hang.sh")
@@ -278,10 +269,6 @@ func TestProvision_CancelTimeout(t *testing.T) {
278269
// terraform-provider-coder
279270
// nolint: paralleltest
280271
func TestProvision_TextFileBusy(t *testing.T) {
281-
if runtime.GOOS == "windows" {
282-
t.Skip("This test uses unix sockets and is not supported on Windows")
283-
}
284-
285272
cwd, err := os.Getwd()
286273
require.NoError(t, err)
287274
fakeBin := filepath.Join(cwd, "testdata", "fake_text_file_busy.sh")

provisioner/terraform/resources_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,27 +1210,16 @@ func TestParameterValidation(t *testing.T) {
12101210
tfPlanGraph, err := os.ReadFile(filepath.Join(dir, "rich-parameters.tfplan.dot"))
12111211
require.NoError(t, err)
12121212

1213-
// Change all names to be identical.
1214-
var names []string
1215-
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
1216-
if resource.Type == "coder_parameter" {
1217-
resource.AttributeValues["name"] = "identical"
1218-
names = append(names, resource.Name)
1219-
}
1220-
}
1221-
12221213
state, err := terraform.ConvertState(ctx, []*tfjson.StateModule{tfPlan.PriorState.Values.RootModule}, string(tfPlanGraph), logger)
12231214
require.Nil(t, state)
12241215
require.Error(t, err)
12251216
require.ErrorContains(t, err, "coder_parameter names must be unique but \"identical\" appears multiple times")
12261217

12271218
// Make two sets of identical names.
12281219
count := 0
1229-
names = nil
12301220
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
12311221
if resource.Type == "coder_parameter" {
12321222
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%2)
1233-
names = append(names, resource.Name)
12341223
count++
12351224
}
12361225
}
@@ -1242,11 +1231,9 @@ func TestParameterValidation(t *testing.T) {
12421231

12431232
// Once more with three sets.
12441233
count = 0
1245-
names = nil
12461234
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
12471235
if resource.Type == "coder_parameter" {
12481236
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%3)
1249-
names = append(names, resource.Name)
12501237
count++
12511238
}
12521239
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy