Skip to content
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

[question] fix some megacheck issues? #2495

Closed
fuweid opened this issue Nov 23, 2018 · 4 comments
Closed

[question] fix some megacheck issues? #2495

fuweid opened this issue Nov 23, 2018 · 4 comments
Assignees

Comments

@fuweid
Copy link
Contributor

fuweid commented Nov 23, 2018

Question

I disable megacheck in circleCI because it will be killed by OOM in #2494

Even though it has been disabled, it still give us more valuable information

apis/filters/parse.go:155:2:warning: 'if err != nil { return args, err }; return args, nil' can be simplified to 'return args, err' (S1013) (megacheck)
apis/opts/config/blkio.go:69:2:warning: should replace loop with weightDevice = append(weightDevice, w.values...) (S1011) (megacheck)
apis/opts/config/blkio.go:127:2:warning: should replace loop with throttleDevice = append(throttleDevice, t.values...) (S1011) (megacheck)
apis/opts/config/blkio.go:146:19:warning: unsigned values are never < 0 (SA4003) (megacheck)
apis/opts/config/blkio.go:185:2:warning: should replace loop with throttleDevice = append(throttleDevice, t.values...) (S1011) (megacheck)
apis/opts/config/runtime.go:50:21:warning: the argument is already a string, there's no need to use fmt.Sprintf (S1025) (megacheck)
apis/server/image_bridge.go:195:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
cli/container.go:68:2:warning: field publicAll is unused (U1000) (megacheck)
cli/image_list.go:111:61:warning: should use String() instead of fmt.Sprintf (S1025) (megacheck)
cli/image_list.go:113:48:warning: should use String() instead of fmt.Sprintf (S1025) (megacheck)
cli/tag.go:15:2:warning: field args is unused (U1000) (megacheck)
cli/top.go:20:2:warning: field args is unused (U1000) (megacheck)
cli/update.go:20:2:warning: field image is unused (U1000) (megacheck)
client/request.go:86:16:warning: httputil.NewClientConn is deprecated: Use the Client or Transport in package net/http instead.  (SA1019) (megacheck)
client/request.go:105:2:warning: unnecessary nil check around range (S1031) (megacheck)
client/request.go:160:3:warning: tr.CancelRequest is deprecated: Use Request.WithContext to create a request with a cancelable context instead. CancelRequest cannot cancel HTTP/2 requests.  (SA1019) (megacheck)
cri/criservice.go:42:2:warning: redundant return statement (S1023) (megacheck)
cri/stream/portforward/httpstream.go:115:29:warning: func (*httpStreamHandler).hasStreamPair is unused (U1000) (megacheck)
cri/stream/portforward/httpstream.go:143:2:warning: empty branch (SA9003) (megacheck)
cri/stream/portforward/portforward.go:32:2:warning: redundant return statement (S1023) (megacheck)
ctrd/client.go:35:2:warning: field rpcAddr is unused (U1000) (megacheck)
ctrd/container.go:704:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
ctrd/snapshot.go:35:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
ctrd/supervisord/config.go:27:2:warning: field md is unused (U1000) (megacheck)
daemon/config/config.go:182:44:warning: should use make(map[string]interface{}) instead (S1019) (megacheck)
daemon/logger/jsonfile/jsonfile_read.go:46:31:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/jsonfile_read_test.go:34:7:warning: should write _ = <-watcher.Msgs instead of _, _ = <-watcher.Msgs (S1005) (megacheck)
daemon/logger/jsonfile/jsonfile_read_test.go:67:7:warning: should write _ = <-watcher.Msgs instead of _, _ = <-watcher.Msgs (S1005) (megacheck)
daemon/logger/jsonfile/utils.go:186:26:warning: os.SEEK_END is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils.go:209:30:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils_test.go:70:31:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils_test.go:141:2:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
daemon/mgr/container.go:1529:30:warning: func (*ContainerManager).updateNetworkSettings is unused (U1000) (megacheck)
daemon/mgr/container.go:1817:2:warning: redundant return statement (S1023) (megacheck)
daemon/mgr/container_logger.go:65:2:warning: redundant return statement (S1023) (megacheck)
daemon/mgr/container_storage.go:739:38:warning: file mode '755' evaluates to 01363; did you mean '0755'? (SA9002) (megacheck)
daemon/mgr/container_types.go:455:34:warning: should use make(map[string]string) instead (S1019) (megacheck)
daemon/mgr/image_store.go:174:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
daemon/mgr/spec_linux.go:326:72:warning: argument e is overwritten before first use (SA4009) (megacheck)
lxcfs/lxcfs.go:47:5:warning: should omit comparison to bool constant, can be simplified to !isMount (S1002) (megacheck)
pkg/archive/archive.go:53:3:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
pkg/archive/archive.go:53:3:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
pkg/kmutex/kmutex_test.go:18:3:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
pkg/kmutex/kmutex_test.go:18:3:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
pkg/kmutex/kmutex_test.go:18:3:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
pkg/kmutex/kmutex_test.go:23:7:warning: should omit comparison to bool constant, can be simplified to !m.Trylock(k) (S1002) (megacheck)
pkg/kmutex/kmutex_test.go:26:7:warning: should omit comparison to bool constant, can be simplified to m.Trylock(k) (S1002) (megacheck)
pkg/kmutex/kmutex_test.go:32:7:warning: should omit comparison to bool constant, can be simplified to !m.Trylock(k) (S1002) (megacheck)
pkg/kmutex/kmutex_test.go:46:2:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
pkg/kmutex/kmutex_test.go:47:6:warning: should omit comparison to bool constant, can be simplified to !m.Trylock("key") (S1002) (megacheck)
pkg/kmutex/kmutex_test.go:59:2:warning: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) (megacheck)
pkg/kmutex/kmutex_test.go:64:5:warning: should omit comparison to bool constant, can be simplified to m.LockWithTimeout("key", time.Second*5) (S1002) (megacheck)
pkg/meta/local.go:42:3:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
pkg/meta/local.go:42:3:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
pkg/meta/store.go:263:2:warning: 'if err != nil { return keys, err }; return keys, nil' can be simplified to 'return keys, err' (S1013) (megacheck)
pkg/meta/store_test.go:184:6:warning: func testRemove is unused (U1000) (megacheck)
pkg/netutils/interface_test.go:302:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:319:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:336:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:353:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:397:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:414:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:431:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/netutils/interface_test.go:477:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/reference/parse_test.go:13:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
pkg/user/user.go:36:2:warning: field finger is unused (U1000) (megacheck)
pkg/user/user.go:37:2:warning: field userdir is unused (U1000) (megacheck)
pkg/user/user.go:38:2:warning: field shell is unused (U1000) (megacheck)
pkg/user/user.go:46:2:warning: field otherGroup is unused (U1000) (megacheck)
pkg/utils/timeutils.go:36:10:warning: should use time.Since instead of time.Now().Sub (S1012) (megacheck)
pkg/utils/utils.go:371:33:warning: should use make(map[string]string) instead (S1019) (megacheck)
registry/auth.go:27:2:warning: field tlsConfig is unused (U1000) (megacheck)
registry/auth_challenge.go:52:18:warning: should use strings.ContainsRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) instead (S1003) (megacheck)
registry/auth_challenge.go:53:6:warning: should use strings.ContainsRune(" \t\r\n", rune(c)) instead (S1003) (megacheck)
storage/plugins/client.go:54:26:warning: should omit comparison to bool constant, can be simplified to !tlsconfig.InsecureSkipVerify (S1002) (megacheck)
storage/quota/grpquota.go:93:53:warning: file mode '644' evaluates to 01204; did you mean '0644'? (SA9002) (megacheck)
storage/quota/quota.go:32:2:warning: var hasQuota is unused (U1000) (megacheck)
storage/quota/quota.go:306:6:warning: ineffective break statement. Did you mean to break out of the outer loop? (SA4011) (megacheck)
storage/quota/quota.go:347:40:warning: should use make(map[uint32]struct{}) instead (S1019) (megacheck)
storage/volume/core_test.go:173:6:warning: should omit comparison to bool constant, can be simplified to !found (S1002) (megacheck)
storage/volume/core_test.go:256:6:warning: should omit comparison to bool constant, can be simplified to !found (S1002) (megacheck)
storage/volume/core_test.go:268:6:warning: should omit comparison to bool constant, can be simplified to !found (S1002) (megacheck)
storage/volume/driver/driver.go:52:3:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
storage/volume/driver/driver.go:60:3:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
storage/volume/driver/driver.go:179:38:warning: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000) (megacheck)
storage/volume/driver/driver.go:228:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
storage/volume/driver/driver_test.go:29:5:warning: should omit comparison to bool constant, can be simplified to !success (S1002) (megacheck)
storage/volume/driver/driver_test.go:52:7:warning: should omit comparison to bool constant, can be simplified to !success (S1002) (megacheck)
storage/volume/driver/driver_test.go:83:7:warning: should omit comparison to bool constant, can be simplified to !success (S1002) (megacheck)
storage/volume/driver/remote.go:118:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
test/cli_exec_test.go:62:2:warning: this value of res is never used (SA4006) (megacheck)
test/cli_ps_test.go:233:34:warning: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000) (megacheck)
test/cli_rich_container_test.go:101:6:warning: func checkInitScriptWorks is unused (U1000) (megacheck)
test/cli_run_blkio_test.go:82:16:warning: cutset contains duplicate characters (SA1024) (megacheck)
test/cli_run_cgroup_test.go:58:2:warning: should replace this if statement with an unconditional strings.TrimPrefix (S1017) (megacheck)
test/cli_run_test.go:341:2:warning: empty branch (SA9003) (megacheck)
test/daemon/daemon.go:171:5:warning: should omit comparison to bool constant, can be simplified to !util.WaitTimeout(time.Duration(d.timeout)*time.Second, d.IsDaemonUp) (S1002) (megacheck)
test/daemon/daemon.go:172:6:warning: should omit comparison to bool constant, can be simplified to d.Debug (S1002) (megacheck)
test/daemon/daemon.go:204:5:warning: should omit comparison to bool constant, can be simplified to !d.IsDaemonUp() (S1002) (megacheck)
test/daemon/daemon.go:218:2:warning: redundant return statement (S1023) (megacheck)
test/environment/env.go:119:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
test/environment/env.go:136:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
test/environment/env.go:150:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
test/environment/env.go:177:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
test/environment/env.go:186:2:warning: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008) (megacheck)
test/request/request.go:197:16:warning: httputil.NewClientConn is deprecated: Use the Client or Transport in package net/http instead.  (SA1019) (megacheck)
test/request/request.go:214:12:warning: httputil.ErrPersistEOF is deprecated: No longer used.  (SA1019) (megacheck)
test/util/util.go:33:7:warning: should omit comparison to bool constant, can be simplified to condition() (S1002) (megacheck)
test/utils.go:72:6:warning: should omit comparison to bool constant, can be simplified to !con() (S1002) (megacheck)

I think some issues can be fixed in pouch or contribute to go-swagger community. Could we move it to task in pouch?

ping @alibaba/pouch

@ZYecho
Copy link
Contributor

ZYecho commented Nov 23, 2018

/assign
work it in next week.

@ZYecho
Copy link
Contributor

ZYecho commented Nov 26, 2018

leave unhandled issue below

apis/opts/config/blkio.go:142:19:warning: unsigned values are never < 0 (SA4003) (megacheck)
client/request.go:86:16:warning: httputil.NewClientConn is deprecated: Use the Client or Transport in package net/http instead.  (SA1019) (megacheck)
client/request.go:158:3:warning: tr.CancelRequest is deprecated: Use Request.WithContext to create a request with a cancelable context instead. CancelRequest cannot cancel HTTP/2 requests.  (SA1019) (megacheck)
cri/stream/portforward/httpstream.go:136:2:warning: empty branch (SA9003) (megacheck)
daemon/logger/jsonfile/jsonfile_read.go:46:31:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils.go:186:26:warning: os.SEEK_END is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils.go:209:30:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/logger/jsonfile/utils_test.go:70:31:warning: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.  (SA1019) (megacheck)
daemon/mgr/spec_linux.go:326:72:warning: argument e is overwritten before first use (SA4009) (megacheck)
pkg/meta/store_test.go:184:6:warning: func testRemove is unused (U1000) (megacheck)
pkg/reference/parse_test.go:13:2:warning: should merge variable declaration with assignment on next line (S1021) (megacheck)
storage/quota/quota.go:304:6:warning: ineffective break statement. Did you mean to break out of the outer loop? (SA4011) (megacheck)
storage/volume/driver/driver.go:173:38:warning: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000) (megacheck)
test/cli_ps_test.go:233:34:warning: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000) (megacheck)
test/cli_rich_container_test.go:101:6:warning: func checkInitScriptWorks is unused (U1000) (megacheck)
test/cli_run_test.go:341:2:warning: empty branch (SA9003) (megacheck)
test/request/request.go:197:16:warning: httputil.NewClientConn is deprecated: Use the Client or Transport in package net/http instead.  (SA1019) (megacheck)
test/request/request.go:214:12:warning: httputil.ErrPersistEOF is deprecated: No longer used.  (SA1019) (megacheck)

@ZYecho
Copy link
Contributor

ZYecho commented Nov 26, 2018

cc @allencloud could you help invite more eyes to see this issue? Because of most of issue leaved are valuable, but I didn't how fix it or don't know there' a plan to upgrade some packages?

@ZYecho ZYecho self-assigned this Nov 30, 2018
@allencloud
Copy link
Collaborator

Since the first PR has been merged. I think we could try to move on.
The next megacheck issue is a little bit complicated, we need to keep an eye on that. Since it seems changing the code logic.

@rudyfly rudyfly closed this as completed Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants