go-zookeeper / zk

Native ZooKeeper client for Go
BSD 3-Clause "New" or "Revised" License
504 stars 130 forks source link

Create static_checks.yaml #129

Open jeffbean opened 4 months ago

jeffbean commented 4 months ago

Lets see if we static check this repo.

github-actions[bot] commented 4 months ago

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package {sec:: [-: malformed import path "{sec:": invalid char '{']
github-actions[bot] commented 4 months ago

⚠ golint failed (.)

Found 37 lint suggestions; failing.

Show Detail ``` conn.go:233:32: exported func WithDialer returns unexported type zk.connOption, which can be annoying to use conn.go:240:50: exported func WithHostProvider returns unexported type zk.connOption, which can be annoying to use conn.go:247:32: exported func WithLogger returns unexported type zk.connOption, which can be annoying to use conn.go:255:32: exported func WithLogInfo returns unexported type zk.connOption, which can be annoying to use conn.go:267:42: exported func WithEventCallback returns unexported type zk.connOption, which can be annoying to use conn.go:297:43: exported func WithMaxBufferSize returns unexported type zk.connOption, which can be annoying to use conn.go:307:47: exported func WithMaxConnBufferSize returns unexported type zk.connOption, which can be annoying to use constants.go:21:2: const opGetAcl should be opGetACL constants.go:22:2: const opSetAcl should be opSetACL constants.go:43:2: exported const EventNodeDeleted should have comment (or a comment on this block) or be unexported constants.go:66:2: exported const StateDisconnected should have comment (or a comment on this block) or be unexported constants.go:81:2: exported const FlagSequence should have comment (or a comment on this block) or be unexported constants.go:117:2: exported var ErrUnknown should have comment or be unexported constants.go:186:2: const errInvalidAcl should be errInvalidACL constants.go:255:2: exported const ModeUnknown should have comment (or a comment on this block) or be unexported server_java_test.go:38:91: exported func NewIntegrationTestServer returns unexported type *zk.server, which can be annoying to use structs.go:14:2: exported var ErrUnhandledFieldType should have comment or be unexported structs.go:25:6: exported type ACL should have comment or be unexported structs.go:31:6: exported type Stat should have comment or be unexported structs.go:123:6: exported type PathVersionRequest should have comment or be unexported structs.go:143:6: exported type CheckVersionRequest should have comment or be unexported structs.go:162:6: exported type CreateRequest should have comment or be unexported structs.go:165:2: struct field Acl should be ACL structs.go:169:6: exported type CreateContainerRequest should have comment or be unexported structs.go:171:6: exported type CreateTTLRequest should have comment or be unexported structs.go:174:2: struct field Acl should be ACL structs.go:176:2: struct field Ttl should be TTL structs.go:180:6: exported type DeleteRequest should have comment or be unexported structs.go:189:6: type getAclRequest should be getACLRequest structs.go:191:6: type getAclResponse should be getACLResponse structs.go:192:2: struct field Acl should be ACL structs.go:229:6: type setAclRequest should be setACLRequest structs.go:231:2: struct field Acl should be ACL structs.go:235:6: type setAclResponse should be setACLResponse structs.go:237:6: exported type SetDataRequest should have comment or be unexported structs.go:299:2: struct field CurConfigId should be CurConfigID util.go:27:1: exported function DigestACL should have comment or be unexported ```
github-actions[bot] commented 4 months ago

⚠ shadow failed (.)

malformed import path "{sec:": invalid char '{'
malformed import path "-exclude=G104}": leading dash
github-actions[bot] commented 4 months ago

⚠ staticcheck failed (.)

-: malformed import path "-exclude=G104}": leading dash (compile)
-: malformed import path "{sec:": invalid char '{' (compile)
cluster_test.go:155:6: should use time.Since instead of time.Now().Sub (S1012)
dnshostprovider.go:49:10: error strings should not be capitalized (ST1005)
lock.go:77:8: should omit comparison to bool constant, can be simplified to exists (S1002)
lock_test.go:37:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    lock_test.go:43:4: call to T.Fatal
server_help_test.go:236:4: this value of err is never used (SA4006)
server_help_test.go:236:10: Errorf doesn't have side effects and its return value is ignored (SA4017)
structs.go:183:6: type errorResponse is unused (U1000)
structs.go:216:6: type getMaxChildrenRequest is unused (U1000)
structs.go:218:6: type getMaxChildrenResponse is unused (U1000)
structs.go:222:6: type getSaslRequest is unused (U1000)
structs.go:227:6: type pingResponse is unused (U1000)
structs.go:245:6: type setMaxChildren is unused (U1000)
structs.go:250:6: type setSaslRequest is unused (U1000)
structs.go:254:6: type setSaslResponse is unused (U1000)
throttle_test.go:88:14: should use time.Until instead of t.Sub(time.Now()) (S1024)
zk_test.go:205:36: unnecessary use of fmt.Sprintf (S1039)
zk_test.go:347:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:351:5: call to T.Fatal
zk_test.go:696:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:723:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:1127:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:1132:6: call to T.Fatalf
zk_test.go:1154:7: empty branch (SA9003)
zk_test.go:1160:6: empty branch (SA9003)

Checks Document

github-actions[bot] commented 4 months ago

⚠ gosec failed (.)

2024/04/20 21:58:41 internal error: package "fmt" without types was imported from "command-line-arguments"
Show Detail ``` 2024/04/20 21:58:41 internal error: package "fmt" without types was imported from "command-line-arguments" ``` [Code Reference](https://github.com/securego/gosec#available-rules)
github-actions[bot] commented 4 months ago
github-actions[bot] commented 4 months ago

⚠ errcheck failed (.)

cluster_test.go:24:15:  defer ts.Stop()
cluster_test.go:57:15:  defer tc.Stop()
cluster_test.go:99:15:  defer tc.Stop()
cluster_test.go:195:15: defer ts.Stop()
cluster_test.go:231:15: defer ts.Stop()
cluster_test.go:242:15: zk.conn.Close()
conn.go:440:16: c.conn.Close()
conn.go:452:23: defer c.conn.Close() // causes recv loop to EOF/exit
conn.go:675:25: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout * 10))
conn.go:677:25: c.conn.SetWriteDeadline(time.Time{})
conn.go:683:24: c.conn.SetReadDeadline(time.Now().Add(c.recvTimeout * 10))
conn.go:685:24: c.conn.SetReadDeadline(time.Time{})
conn.go:750:25: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout))
conn.go:752:25: c.conn.SetWriteDeadline(time.Time{})
conn.go:755:15: c.conn.Close()
conn.go:780:27: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout))
conn.go:782:27: c.conn.SetWriteDeadline(time.Time{})
conn.go:784:17: c.conn.Close()
conn.go:818:23: conn.SetReadDeadline(time.Time{})
conn_test.go:17:16: defer zkC.Stop()
conn_test.go:28:16: waitForSession(ctx, evtC)
conn_test.go:30:14: conn.AddAuth("digest", []byte("test:test"))
conn_test.go:47:16: waitForSession(ctx, evtC)
dnshostprovider_test.go:23:15:  defer ts.Stop()
dnshostprovider_test.go:104:15: defer ts.Stop()
dnshostprovider_test.go:146:34: ts.Servers[serverIndex].Srv.Stop()
dnshostprovider_test.go:147:35: ts.Servers[serverIndex].Srv.Start()
flw.go:257:18:  defer conn.Close()
flw.go:259:23:  conn.SetWriteDeadline(time.Now().Add(timeout))
flw.go:265:22:  conn.SetReadDeadline(time.Now().Add(timeout))
flw_test.go:33:15:  defer l.Close()
flw_test.go:52:15:  defer l.Close()
flw_test.go:71:15:  defer l.Close()
flw_test.go:144:15: defer l.Close()
flw_test.go:296:18: defer conn.Close()
flw_test.go:311:14: conn.Write([]byte("imok"))
flw_test.go:318:14: conn.Write([]byte(zkSrvrOut))
flw_test.go:325:14: conn.Write([]byte(zkConsOut))
flw_test.go:328:13: conn.Write([]byte("This ZooKeeper instance is not currently serving requests."))
lock_test.go:13:15: defer ts.Stop()
lock_test.go:71:15: defer ts.Stop()
lock_test.go:87:17: defer zk.Delete("/test-multi-level", -1) // Clean up what we've created for this test
lock_test.go:88:17: defer zk.Delete("/test-multi-level/lock", -1)
server_help_test.go:60:16:  cluster.Stop()
server_help_test.go:90:11:  fi.Close()
server_help_test.go:96:11:  fi.Close()
server_help_test.go:147:15: srv.Srv.Stop()
server_help_test.go:201:15: s.Srv.Start()
server_help_test.go:211:14: s.Srv.Stop()
server_java_test.go:101:14: fmt.Fprintln(w, "admin.enableServer=false")
server_java_test.go:105:13: fmt.Fprintf(w, "dataDir=%s\n", sc.DataDir)
server_java_test.go:109:13: fmt.Fprintf(w, "tickTime=%d\n", sc.TickTime)
server_java_test.go:113:13: fmt.Fprintf(w, "initLimit=%d\n", sc.InitLimit)
server_java_test.go:117:13: fmt.Fprintf(w, "syncLimit=%d\n", sc.SyncLimit)
server_java_test.go:121:13: fmt.Fprintf(w, "clientPort=%d\n", sc.ClientPort)
server_java_test.go:126:14: fmt.Fprintf(w, "autopurge.snapRetainCount=%d\n", sc.AutoPurgeSnapRetainCount)
server_java_test.go:127:14: fmt.Fprintf(w, "autopurge.purgeInterval=%d\n", sc.AutoPurgePurgeInterval)
server_java_test.go:131:14: fmt.Fprintln(w, "reconfigEnabled=true")
server_java_test.go:132:14: fmt.Fprintln(w, "4lw.commands.whitelist=*")
server_java_test.go:140:14: fmt.Fprintln(w, "standaloneEnabled=false")
server_java_test.go:149:14: fmt.Fprintf(w, "server.%d=%s:%d:%d\n", srv.ID, srv.Host, srv.PeerPort, srv.LeaderElectionPort)
tcp_server_test.go:18:15:   defer l.Close()
tcp_server_test.go:35:12:   conn.Close()
zk_test.go:27:15:   defer ts.Stop()
zk_test.go:73:15:   defer ts.Stop()
zk_test.go:104:15:  defer ts.Stop()
zk_test.go:156:15:  defer ts.Stop()
zk_test.go:199:15:  defer ts.Stop()
zk_test.go:227:10:  fi.Close()
zk_test.go:233:10:  fi.Close()
zk_test.go:239:23:  defer testServer.Stop()
zk_test.go:293:15:  defer ts.Stop()
zk_test.go:337:15:  defer ts.Stop()
zk_test.go:368:15:  defer ts.Stop()
zk_test.go:409:15:  defer ts.Stop()
zk_test.go:436:12:  zk.AddAuth("digest", []byte("userfoo:passbar"))
zk_test.go:443:19:  ts.StopAllServers()
zk_test.go:444:20:  ts.StartAllServers()
zk_test.go:462:15:  defer ts.Stop()
zk_test.go:505:15:  defer ts.Stop()
zk_test.go:559:15:  defer ts.Stop()
zk_test.go:609:15:  defer ts.Stop()
zk_test.go:662:15:  defer ts.Stop()
zk_test.go:733:15:  defer ts.Stop()
zk_test.go:761:14:  zk2.Delete(p, -1)
zk_test.go:790:15:  zk.conn.Close()
zk_test.go:876:15:  defer ts.Stop()
zk_test.go:897:15:  zk.conn.Close()
zk_test.go:952:15:  defer ts.Stop()
zk_test.go:983:15:  zk.conn.Close()
zk_test.go:1011:15: defer ts.Stop()
zk_test.go:1125:12: tln.Close()
zk_test.go:1140:19: defer cn.Close()
zk_test.go:1150:16: upcn.Close()
github-actions[bot] commented 4 months ago

⚠ vet failed (.)

# github.com/go-zookeeper/zk
# [github.com/go-zookeeper/zk]
./lock_test.go:39:4: call to (*testing.T).Fatal from a non-test goroutine
./lock_test.go:43:4: call to (*testing.T).Fatal from a non-test goroutine
./zk_test.go:351:5: call to (*testing.T).Fatal from a non-test goroutine
./zk_test.go:1132:6: call to (*testing.T).Fatalf from a non-test goroutine
github-actions[bot] commented 4 months ago

⚠ staticcheck failed (.)

cluster_test.go:155:6: should use time.Since instead of time.Now().Sub (S1012)
dnshostprovider.go:49:10: error strings should not be capitalized (ST1005)
lock.go:77:8: should omit comparison to bool constant, can be simplified to exists (S1002)
lock_test.go:37:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    lock_test.go:43:4: call to T.Fatal
server_help_test.go:236:4: this value of err is never used (SA4006)
server_help_test.go:236:10: Errorf doesn't have side effects and its return value is ignored (SA4017)
structs.go:183:6: type errorResponse is unused (U1000)
structs.go:216:6: type getMaxChildrenRequest is unused (U1000)
structs.go:218:6: type getMaxChildrenResponse is unused (U1000)
structs.go:222:6: type getSaslRequest is unused (U1000)
structs.go:227:6: type pingResponse is unused (U1000)
structs.go:245:6: type setMaxChildren is unused (U1000)
structs.go:250:6: type setSaslRequest is unused (U1000)
structs.go:254:6: type setSaslResponse is unused (U1000)
throttle_test.go:88:14: should use time.Until instead of t.Sub(time.Now()) (S1024)
zk_test.go:205:36: unnecessary use of fmt.Sprintf (S1039)
zk_test.go:347:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:351:5: call to T.Fatal
zk_test.go:696:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:723:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:1127:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:1132:6: call to T.Fatalf
zk_test.go:1154:7: empty branch (SA9003)
zk_test.go:1160:6: empty branch (SA9003)

Checks Document

github-actions[bot] commented 4 months ago
github-actions[bot] commented 3 months ago

⚠ errcheck failed (.)

cluster_test.go:24:15:  defer ts.Stop()
cluster_test.go:57:15:  defer tc.Stop()
cluster_test.go:99:15:  defer tc.Stop()
cluster_test.go:195:15: defer ts.Stop()
cluster_test.go:231:15: defer ts.Stop()
cluster_test.go:242:15: zk.conn.Close()
conn.go:440:16: c.conn.Close()
conn.go:452:23: defer c.conn.Close() // causes recv loop to EOF/exit
conn.go:675:25: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout * 10))
conn.go:677:25: c.conn.SetWriteDeadline(time.Time{})
conn.go:683:24: c.conn.SetReadDeadline(time.Now().Add(c.recvTimeout * 10))
conn.go:685:24: c.conn.SetReadDeadline(time.Time{})
conn.go:750:25: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout))
conn.go:752:25: c.conn.SetWriteDeadline(time.Time{})
conn.go:755:15: c.conn.Close()
conn.go:780:27: c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout))
conn.go:782:27: c.conn.SetWriteDeadline(time.Time{})
conn.go:784:17: c.conn.Close()
conn.go:818:23: conn.SetReadDeadline(time.Time{})
conn_test.go:17:16: defer zkC.Stop()
conn_test.go:28:16: waitForSession(ctx, evtC)
conn_test.go:30:14: conn.AddAuth("digest", []byte("test:test"))
conn_test.go:47:16: waitForSession(ctx, evtC)
dnshostprovider_test.go:23:15:  defer ts.Stop()
dnshostprovider_test.go:104:15: defer ts.Stop()
dnshostprovider_test.go:146:34: ts.Servers[serverIndex].Srv.Stop()
dnshostprovider_test.go:147:35: ts.Servers[serverIndex].Srv.Start()
flw.go:257:18:  defer conn.Close()
flw.go:259:23:  conn.SetWriteDeadline(time.Now().Add(timeout))
flw.go:265:22:  conn.SetReadDeadline(time.Now().Add(timeout))
flw_test.go:33:15:  defer l.Close()
flw_test.go:52:15:  defer l.Close()
flw_test.go:71:15:  defer l.Close()
flw_test.go:144:15: defer l.Close()
flw_test.go:296:18: defer conn.Close()
flw_test.go:311:14: conn.Write([]byte("imok"))
flw_test.go:318:14: conn.Write([]byte(zkSrvrOut))
flw_test.go:325:14: conn.Write([]byte(zkConsOut))
flw_test.go:328:13: conn.Write([]byte("This ZooKeeper instance is not currently serving requests."))
lock_test.go:13:15: defer ts.Stop()
lock_test.go:71:15: defer ts.Stop()
lock_test.go:87:17: defer zk.Delete("/test-multi-level", -1) // Clean up what we've created for this test
lock_test.go:88:17: defer zk.Delete("/test-multi-level/lock", -1)
server_help_test.go:60:16:  cluster.Stop()
server_help_test.go:90:11:  fi.Close()
server_help_test.go:96:11:  fi.Close()
server_help_test.go:147:15: srv.Srv.Stop()
server_help_test.go:201:15: s.Srv.Start()
server_help_test.go:211:14: s.Srv.Stop()
server_java_test.go:101:14: fmt.Fprintln(w, "admin.enableServer=false")
server_java_test.go:105:13: fmt.Fprintf(w, "dataDir=%s\n", sc.DataDir)
server_java_test.go:109:13: fmt.Fprintf(w, "tickTime=%d\n", sc.TickTime)
server_java_test.go:113:13: fmt.Fprintf(w, "initLimit=%d\n", sc.InitLimit)
server_java_test.go:117:13: fmt.Fprintf(w, "syncLimit=%d\n", sc.SyncLimit)
server_java_test.go:121:13: fmt.Fprintf(w, "clientPort=%d\n", sc.ClientPort)
server_java_test.go:126:14: fmt.Fprintf(w, "autopurge.snapRetainCount=%d\n", sc.AutoPurgeSnapRetainCount)
server_java_test.go:127:14: fmt.Fprintf(w, "autopurge.purgeInterval=%d\n", sc.AutoPurgePurgeInterval)
server_java_test.go:131:14: fmt.Fprintln(w, "reconfigEnabled=true")
server_java_test.go:132:14: fmt.Fprintln(w, "4lw.commands.whitelist=*")
server_java_test.go:140:14: fmt.Fprintln(w, "standaloneEnabled=false")
server_java_test.go:149:14: fmt.Fprintf(w, "server.%d=%s:%d:%d\n", srv.ID, srv.Host, srv.PeerPort, srv.LeaderElectionPort)
tcp_server_test.go:18:15:   defer l.Close()
tcp_server_test.go:35:12:   conn.Close()
zk_test.go:28:15:   defer ts.Stop()
zk_test.go:74:15:   defer ts.Stop()
zk_test.go:105:15:  defer ts.Stop()
zk_test.go:157:15:  defer ts.Stop()
zk_test.go:194:15:  defer ts.Stop()
zk_test.go:222:10:  fi.Close()
zk_test.go:228:10:  fi.Close()
zk_test.go:234:23:  defer testServer.Stop()
zk_test.go:282:15:  defer ts.Stop()
zk_test.go:326:15:  defer ts.Stop()
zk_test.go:357:15:  defer ts.Stop()
zk_test.go:398:15:  defer ts.Stop()
zk_test.go:425:12:  zk.AddAuth("digest", []byte("userfoo:passbar"))
zk_test.go:432:19:  ts.StopAllServers()
zk_test.go:433:20:  ts.StartAllServers()
zk_test.go:451:15:  defer ts.Stop()
zk_test.go:494:15:  defer ts.Stop()
zk_test.go:548:15:  defer ts.Stop()
zk_test.go:598:15:  defer ts.Stop()
zk_test.go:651:15:  defer ts.Stop()
zk_test.go:722:15:  defer ts.Stop()
zk_test.go:750:14:  zk2.Delete(p, -1)
zk_test.go:779:15:  zk.conn.Close()
zk_test.go:865:15:  defer ts.Stop()
zk_test.go:886:15:  zk.conn.Close()
zk_test.go:941:15:  defer ts.Stop()
zk_test.go:972:15:  zk.conn.Close()
zk_test.go:1000:15: defer ts.Stop()
zk_test.go:1114:12: tln.Close()
zk_test.go:1129:19: defer cn.Close()
zk_test.go:1139:16: upcn.Close()
github-actions[bot] commented 3 months ago

⚠ vet failed (.)

# github.com/go-zookeeper/zk
# [github.com/go-zookeeper/zk]
./lock_test.go:39:4: call to (*testing.T).Fatal from a non-test goroutine
./lock_test.go:43:4: call to (*testing.T).Fatal from a non-test goroutine
./zk_test.go:340:5: call to (*testing.T).Fatal from a non-test goroutine
./zk_test.go:1121:6: call to (*testing.T).Fatalf from a non-test goroutine
github-actions[bot] commented 3 months ago

⚠ staticcheck failed (.)

cluster_test.go:155:6: should use time.Since instead of time.Now().Sub (S1012)
dnshostprovider.go:49:10: error strings should not be capitalized (ST1005)
lock.go:77:8: should omit comparison to bool constant, can be simplified to exists (S1002)
lock_test.go:37:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    lock_test.go:43:4: call to T.Fatal
server_help_test.go:236:4: this value of err is never used (SA4006)
server_help_test.go:236:10: Errorf doesn't have side effects and its return value is ignored (SA4017)
structs.go:183:6: type errorResponse is unused (U1000)
structs.go:216:6: type getMaxChildrenRequest is unused (U1000)
structs.go:218:6: type getMaxChildrenResponse is unused (U1000)
structs.go:222:6: type getSaslRequest is unused (U1000)
structs.go:227:6: type pingResponse is unused (U1000)
structs.go:245:6: type setMaxChildren is unused (U1000)
structs.go:250:6: type setSaslRequest is unused (U1000)
structs.go:254:6: type setSaslResponse is unused (U1000)
throttle_test.go:88:14: should use time.Until instead of t.Sub(time.Now()) (S1024)
zk_test.go:200:36: unnecessary use of fmt.Sprintf (S1039)
zk_test.go:336:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:340:5: call to T.Fatal
zk_test.go:685:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:712:7: unnecessary assignment to the blank identifier (S1005)
zk_test.go:1116:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
    zk_test.go:1121:6: call to T.Fatalf
zk_test.go:1143:7: empty branch (SA9003)
zk_test.go:1149:6: empty branch (SA9003)

Checks Document

github-actions[bot] commented 3 months ago
codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.36%. Comparing base (6131812) to head (a2ff478).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #129 +/- ## ========================================== + Coverage 77.98% 78.36% +0.37% ========================================== Files 7 7 Lines 1322 1322 ========================================== + Hits 1031 1036 +5 + Misses 199 195 -4 + Partials 92 91 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.