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

bugfix: fix repeated strings reported by goconst #2454

Merged
merged 2 commits into from
Nov 11, 2018

Conversation

mathspanda
Copy link
Contributor

@mathspanda mathspanda commented Nov 8, 2018

Signed-off-by: mathspanda mathspanda826@gmail.com

Ⅰ. Describe what this PR did

  1. Fix repeated strings reported by goconst.
  2. Add goconst check into ci.

Ⅱ. Does this pull request fix one issue?

#2424

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

None

Ⅳ. Describe how to verify it

gometalinter --disable-all --skip vendor -E goconst ./...

Ⅴ. Special notes for reviews

None

@codecov
Copy link

codecov bot commented Nov 8, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@e7e89c8). Click here to learn what that means.
The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2454   +/-   ##
=========================================
  Coverage          ?   68.87%           
=========================================
  Files             ?      277           
  Lines             ?    18296           
  Branches          ?        0           
=========================================
  Hits              ?    12602           
  Misses            ?     4260           
  Partials          ?     1434
Flag Coverage Δ
#criv1alpha1test 31.47% <17.39%> (?)
#criv1alpha2test 35.76% <52.17%> (?)
#integrationtest 40.45% <36.95%> (?)
#nodee2etest 32.93% <39.13%> (?)
#unittest 26.67% <2.17%> (?)
Impacted Files Coverage Δ
apis/opts/config/blkio.go 69.66% <0%> (ø)
daemon/mgr/system.go 73.28% <100%> (ø)
daemon/mgr/spec_mount.go 84.25% <100%> (ø)
apis/server/image_bridge.go 74.1% <100%> (ø)
apis/server/container_bridge.go 87.42% <100%> (ø)
cri/v1alpha2/cri.go 69.65% <81.81%> (ø)

@pouchrobot pouchrobot added kind/bug This is bug report for project size/L labels Nov 8, 2018
@@ -26,6 +26,12 @@ import (
"github.com/sirupsen/logrus"
)

const (
unknownHostName = "<unknown>"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there is need to add three different const for "unknown", since they're all same ? Just looks weird

Copy link
Contributor Author

@mathspanda mathspanda Nov 8, 2018

Choose a reason for hiding this comment

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

Yeap, i have thought about this. Although their value are all same, they represent value of different system info field in unknown scene.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it depends on how the three value diverged, it's possible to be different in the future?

Copy link
Contributor Author

@mathspanda mathspanda Nov 8, 2018

Choose a reason for hiding this comment

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

It may be hard to confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, I think it's ok here.

@ZYecho
Copy link
Contributor

ZYecho commented Nov 8, 2018

Maybe We can make verify step more accurate in desc, such as gometalinter --enable=goconst ./...

@@ -13,6 +13,23 @@ func init() {
Register()
}

// Action labels for different pod/image operations
const (
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution. In fact, the pouch's HTTP server also needs to collect metrics. So could you please to do the samething for api/servers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mathspanda mathspanda force-pushed the lint-const branch 3 times, most recently from 2f569c5 to 882e19a Compare November 8, 2018 14:34

// Action labels for different pod/container/image operations.
const (
ActionCreate = "create"
Copy link
Collaborator

@allencloud allencloud Nov 9, 2018

Choose a reason for hiding this comment

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

How about changing all this const variables' naming to be XXXActionLabel?
I think this will be a little bit more readable.

@@ -14,6 +14,21 @@ import (
"github.com/sirupsen/logrus"
)

const (
// PropagationRPrivate represents mount propagation rprivate.
PropagationRPrivate = "rprivate"
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about changing all this const variables' naming to be XXXXXPropagationMode?
I think this will be a little bit more readable.

@allencloud
Copy link
Collaborator

@mathspanda
I think when you finish this pr, we could add goconst in .circleci/config.yml, right?

How about you directly adding -E goconst in https://github.com/alibaba/pouch/blob/master/.circleci/config.yml#L41 ?

gometalinter --disable-all --skip vendor -E gofmt -E goimports -E golint -E ineffassign -E misspell -E vet -E megacheck ./...

Then no one needs to fix config.yml and goconst could serve all the following pull request.

In addition, does the update satisfy you? @starnop

Signed-off-by: mathspanda <mathspanda826@gmail.com>
Signed-off-by: mathspanda <mathspanda826@gmail.com>
@mathspanda mathspanda changed the title bugfix: fix part of repeated strings reported by goconst bugfix: fix repeated strings reported by goconst Nov 10, 2018
@mathspanda
Copy link
Contributor Author

How about you directly adding -E goconst in https://github.com/alibaba/pouch/blob/master/.circleci/config.yml#L41 ?

gometalinter --disable-all --skip vendor -E gofmt -E goimports -E golint -E ineffassign -E misspell -E vet -E megacheck ./...

Then no one needs to fix config.yml and goconst could serve all the following pull request.

Done.

@allencloud
Copy link
Collaborator

That is so great to see this fixed in code and add a defender in circleCI. LGTM

@allencloud allencloud merged commit af17db3 into AliyunContainerService:master Nov 11, 2018
@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants