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

fix dead code and clean code format #2355

Conversation

chuanchang
Copy link
Contributor

default section is never hit due to Strings.Count
limitation and strings.SplitN slice, in other words,
the part is dead code, this patch will fix it.

apis.opts.mountpoint: fix dead code
apis.opts.mountpoint_test: clean code format

Signed-off-by: Alex Jia [email protected]

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

default section is never hit due to Strings.Count
limitation and strings.SplitN slice, in other words,
the part is dead code, this patch will fix it.

apis.opts.mountpoint: fix dead code
apis.opts.mountpoint_test: clean code format

Signed-off-by: Alex Jia <[email protected]>
@codecov
Copy link

codecov bot commented Oct 24, 2018

Codecov Report

Merging #2355 into master will increase coverage by 1.41%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2355      +/-   ##
==========================================
+ Coverage   66.66%   68.08%   +1.41%     
==========================================
  Files         265      265              
  Lines       18209    18207       -2     
==========================================
+ Hits        12139    12396     +257     
+ Misses       4669     4392     -277     
- Partials     1401     1419      +18
Flag Coverage Δ
#criv1alpha1test 31.62% <100%> (+0.05%) ⬆️
#criv1alpha2test 35.57% <100%> (?)
#integrationtest 39.57% <100%> (+0.03%) ⬆️
#nodee2etest 32.98% <100%> (+0.01%) ⬆️
#unittest 25.31% <100%> (ø) ⬆️
Impacted Files Coverage Δ
apis/opts/mountpoint.go 100% <100%> (+2.81%) ⬆️
cri/ocicni/cni_manager.go 59.18% <0%> (-12.25%) ⬇️
daemon/mgr/container.go 59.21% <0%> (+0.21%) ⬆️
cri/v1alpha1/cri.go 61.03% <0%> (+0.32%) ⬆️
daemon/containerio/container_io.go 75.95% <0%> (+1.09%) ⬆️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️
cri/v1alpha2/cri.go 68.44% <0%> (+2.78%) ⬆️
cri/v1alpha2/cri_utils.go 90.28% <0%> (+3%) ⬆️
cri/stream/remotecommand/httpstream.go 46.63% <0%> (+3.1%) ⬆️
... and 7 more

{bind: "volume-test::rw", len: 3, err: true, expectErr: fmt.Errorf("unknown volume bind: volume-test::rw")},
{bind: "volume-test", len: 1, err: true, expectErr: fmt.Errorf("invalid bind path: volume-test")},
{bind: ":mnt:rw", len: 3, err: true, expectErr: fmt.Errorf("invalid bind path: mnt")},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should we change one line to this structure? just caurious @chuanchang

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think the new way is much more readable. 😄

@@ -10,11 +10,7 @@ import (

// CheckBind is used to check the volume bind information.
func CheckBind(b string) ([]string, error) {
if strings.Count(b, ":") > 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete the : numbers check ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is same as using the following code arr := strings.SplitN(b, ":", 3). @HusterWan

@allencloud
Copy link
Collaborator

LGTM, while I would like to invite @rudyfly to take another review.

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Oct 25, 2018
@allencloud allencloud merged commit 6a6c159 into AliyunContainerService:master Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/storage LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants