-
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
bugfix: fix deadcode reports by gometalinter #2426
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2426 +/- ##
==========================================
+ Coverage 68.35% 68.77% +0.42%
==========================================
Files 272 272
Lines 18206 18155 -51
==========================================
+ Hits 12445 12487 +42
+ Misses 4332 4254 -78
+ Partials 1429 1414 -15
|
code check fails with the error:
Please take a look. |
updated. |
test/util_api.go
Outdated
@@ -150,15 +141,6 @@ func PauseContainerOk(c *check.C, cname string) { | |||
CheckRespStatus(c, resp, 204) | |||
} | |||
|
|||
// UnpauseContainerOk unpauses the container and asserts success.. |
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.
For this part, I do not think removal of code is a good idea. Instead, I am afraid that we should try to take advantages of that in the test code, like:
// unpause it
resp, err = request.Post("/containers/" + cname + "/unpause")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
WDYT? @ZYecho
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.
In addition, maybe in another pr, we could use PauseContainerOk
to replace
resp, err := request.Post("/containers/" + cname + "/pause")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
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.
good catch, replace it in the next patch.
aadc4ea
to
cf12a38
Compare
ctrd/utils.go
Outdated
"net" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/alibaba/pouch/apis/types" | ||
"github.com/alibaba/pouch/pkg/errtypes" | ||
"github.com/alibaba/pouch/pkg/utils" | ||
|
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.
Keep the blank line, thanks
@@ -373,45 +373,17 @@ func setupNamespaces(ctx context.Context, c *Container, specWrapper *SpecWrapper | |||
return setupUtsNamespace(ctx, c, specWrapper) | |||
} | |||
|
|||
// isEmpty indicates whether namespace mode is empty. |
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.
cc @Ace-Tang to check this part.
@@ -258,23 +257,6 @@ func initLog() { | |||
logrus.SetFormatter(formatter) | |||
} | |||
|
|||
// define lxcfs processe. | |||
func setLxcfsProcess(processes exec.Processes) exec.Processes { |
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.
cc @CodeJuan to check lxcfs part.
@@ -18,10 +18,6 @@ import ( | |||
"github.com/sirupsen/logrus" | |||
) | |||
|
|||
var ( |
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.
cc @rudyfly to check quota part.
Signed-off-by: zhangyue <[email protected]>
LGTM |
Thanks a lot for your work. @ZYecho This will definitely decrease the maintenance effort. And please help continue a followup pr to take advantages of common code in the test code, like |
Signed-off-by: zhangyue [email protected]
Ⅰ. Describe what this PR did
As the title desc.
Ⅱ. Does this pull request fix one issue?
fix #2423
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
None.
Ⅳ. Describe how to verify it
None.
Ⅴ. Special notes for reviews
The go tool's report about the deadcode have many errors, such as
PullImage
andinspectFilter
func obviously being used in other code, maybe caused by lacking of--tests
opt when use gometalinter.I have double-check based on the reports.
updated:
still have errors even if use
gometalinter --tests --enable=deadcode ./...
more deadcode not included in the report, such as
rootFSToAPIType
inpouch/ctrd/utils.go