-
Notifications
You must be signed in to change notification settings - Fork 949
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
fix dead code and clean code format #2355
Conversation
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 Report
@@ 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
|
{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")}, | ||
{ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
LGTM, while I would like to invite @rudyfly to take another review. |
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