Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e0ceec

Browse files
committed
fix more linting rules
1 parentd9b665c commit7e0ceec

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
returnisRemoteForwardTCP(flag)||isRemoteForwardUnixSocket(flag)
4141
}
4242

43-
funcparseRemoteForwardTCP(matches []string) (net.Addr, net.Addr,error) {
43+
funcparseRemoteForwardTCP(matches []string) (localnet.Addr,remotenet.Addr,errerror) {
4444
remotePort,err:=strconv.Atoi(matches[1])
4545
iferr!=nil {
4646
returnnil,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-
funcparseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr,error) {
72+
funcparseRemoteForwardUnixSocket(matches []string) (localnet.Addr,remotenet.Addr,errerror) {
7373
remoteSocket:=matches[1]
7474
localSocket:=matches[2]
7575

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

88-
funcparseRemoteForward(flagstring) (net.Addr, net.Addr,error) {
88+
funcparseRemoteForward(flagstring) (localnet.Addr,remotenet.Addr,errerror) {
8989
tcpMatches:=remoteForwardRegexTCP.FindStringSubmatch(flag)
9090

9191
iflen(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
iferrors.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
iferr!=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
ifsigStr=="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
funcmain() {
16+
panic("hey")
1617
iflen(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
returnq.db.GetDeploymentWorkspaceStats(ctx)
16641664
}
16651665

1666-
func (q*querier)GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context,provisionerJobIds []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow,error) {
1667-
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx,provisionerJobIds)
1666+
func (q*querier)GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context,provisionerJobIDs []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow,error) {
1667+
returnfetchWithPostFilter(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
returnq.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
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceSystem);err!=nil {
30223022
returnnil,err
30233023
}
3024-
returnq.db.GetWorkspaceUniqueOwnerCountByTemplateIDs(ctx,templateIds)
3024+
returnq.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
funcconvertExpression(cfgConvertConfig,e*ast.Expr) (sqltypes.BooleanNode,error) {
8080
ife.IsCall() {
81+
//nolint:forcetypeassert
8182
n,err:=convertCall(cfg,e.Terms.([]*ast.Term))
8283
iferr!=nil {
8384
returnnil,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
iferr!=nil {
3636
returnnil,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
iferr!=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
funcTestProvision_Cancel(t*testing.T) {
122-
ifruntime.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
funcTestProvision_CancelTimeout(t*testing.T) {
218-
ifruntime.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
funcTestProvision_TextFileBusy(t*testing.T) {
281-
ifruntime.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-
varnames []string
1215-
for_,resource:=rangetfPlan.PriorState.Values.RootModule.Resources {
1216-
ifresource.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:=rangetfPlan.PriorState.Values.RootModule.Resources {
12311221
ifresource.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:=rangetfPlan.PriorState.Values.RootModule.Resources {
12471235
ifresource.Type=="coder_parameter" {
12481236
resource.AttributeValues["name"]=fmt.Sprintf("identical-%d",count%3)
1249-
names=append(names,resource.Name)
12501237
count++
12511238
}
12521239
}

‎provisioner/terraform/tfparse/tfparse.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func WriteArchive(bs []byte, mimetype string, path string) error {
279279
returnxerrors.Errorf("read zip file: %w",err)
280280
}elseiftarBytes,err:=archive.CreateTarFromZip(zr,maxFileSizeBytes);err!=nil {
281281
returnxerrors.Errorf("convert zip to tar: %w",err)
282-
}else {
282+
}else {//nolint:revive
283283
rdr=bytes.NewReader(tarBytes)
284284
}
285285
default:
@@ -558,9 +558,8 @@ func CtyValueString(val cty.Value) (string, error) {
558558
casecty.Bool:
559559
ifval.True() {
560560
return"true",nil
561-
}else {
562-
return"false",nil
563561
}
562+
return"false",nil
564563
casecty.Number:
565564
returnval.AsBigFloat().String(),nil
566565
casecty.String:

‎scripts/echoserver/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ func main() {
2020
deferl.Close()
2121
tcpAddr,valid:=l.Addr().(*net.TCPAddr)
2222
if!valid {
23-
log.Fatal("address is not valid")
23+
log.Panic("address is not valid")
2424
}
2525

2626
remotePort:=tcpAddr.Port
2727
_,err=fmt.Println(remotePort)
2828
iferr!=nil {
29-
log.Fatalf("print error: err=%s",err)
29+
log.Panicf("print error: err=%s",err)
3030
}
3131

3232
for {
3333
conn,err:=l.Accept()
3434
iferr!=nil {
35-
log.Fatalf("accept error, err=%s",err)
35+
log.Panicf("accept error, err=%s",err)
3636
return
3737
}
3838

@@ -43,7 +43,7 @@ func main() {
4343
iferrors.Is(err,io.EOF) {
4444
return
4545
}elseiferr!=nil {
46-
log.Fatalf("copy error, err=%s",err)
46+
log.Panicf("copy error, err=%s",err)
4747
}
4848
}()
4949
}

‎scripts/migrate-test/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,25 @@ func main() {
8282
_,_=fmt.Fprintf(os.Stderr,"Init database at version %q\n",migrateFromVersion)
8383
iferr:=migrations.UpWithFS(conn,migrateFromFS);err!=nil {
8484
friendlyError(os.Stderr,err,migrateFromVersion,migrateToVersion)
85-
os.Exit(1)
85+
panic("")
8686
}
8787

8888
_,_=fmt.Fprintf(os.Stderr,"Migrate to version %q\n",migrateToVersion)
8989
iferr:=migrations.UpWithFS(conn,migrateToFS);err!=nil {
9090
friendlyError(os.Stderr,err,migrateFromVersion,migrateToVersion)
91-
os.Exit(1)
91+
panic("")
9292
}
9393

9494
_,_=fmt.Fprintf(os.Stderr,"Dump schema at version %q\n",migrateToVersion)
9595
dumpBytesAfter,err:=dbtestutil.PGDumpSchemaOnly(postgresURL)
9696
iferr!=nil {
9797
friendlyError(os.Stderr,err,migrateFromVersion,migrateToVersion)
98-
os.Exit(1)
98+
panic("")
9999
}
100100

101101
ifdiff:=cmp.Diff(string(dumpBytesAfter),string(stripGenPreamble(expectedSchemaAfter)));diff!="" {
102102
friendlyError(os.Stderr,xerrors.Errorf("Schema differs from expected after migration: %s",diff),migrateFromVersion,migrateToVersion)
103-
os.Exit(1)
103+
panic("")
104104
}
105105
_,_=fmt.Fprintf(os.Stderr,"OK\n")
106106
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp