-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
enable golint lll check #1305
enable golint lll check #1305
Conversation
/assign @pmorie |
/assign @mengqiy |
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.
I leave 30 comments but don't worry, most of them are duplicates, we can keep the discussion in the first appearance of each unless there is something specific to one of them.
8fd555f
to
a850c22
Compare
@@ -39,39 +39,44 @@ var _ = Describe("Webhook", func() { | |||
serverName := "default" | |||
inputs := []*webhookTestcase{ | |||
{ | |||
Resource: resource.Resource{Group: "crew", Version: "v1", Kind: "FirstMate", Namespaced: true, CreateExampleReconcileBody: true}, | |||
Resource: resource.Resource{Group: "crew", Version: "v1", Kind: "FirstMate", |
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.
Better to put all Resource fields on their own line for consistency.
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.
if we put all in one line it is long and will no pass in the lint.
It is harder understanding if we need to use the scroll.
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.
I'd do this which IMO read better. I guess that's also what @estroz means.
Resource: resource.Resource{
Group: "crew",
Version: "v1",
Kind: "FirstMate",
Namespaced: true,
CreateExampleReconcileBody: true
},
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.
It makes sense. I did not understand that. Tks.
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.
Done
a850c22
to
5a80e39
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5a80e39
to
4b78b0c
Compare
cmd/webhook_v2.go
Outdated
@@ -40,7 +40,8 @@ func newWebhookV2Cmd() *cobra.Command { | |||
cmd := &cobra.Command{ | |||
Use: "webhook", | |||
Short: "Scaffold a webhook for an API resource.", | |||
Long: `Scaffold a webhook for an API resource. You can choose to scaffold defaulting, validating and (or) conversion webhooks.`, | |||
Long: `Scaffold a webhook for an API resource. You can choose to scaffold defaulting, | |||
validating and (or) conversion webhooks.`, |
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 not identical to what we used to have, since backquotes "`" are being used. You are introducing a newline here.
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.
solved
Need rebase |
4b78b0c
to
3e52fa9
Compare
badebf1
to
5f4c516
Compare
@camilamacedo86 Please rebase |
5f4c516
to
9032028
Compare
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.
/lgtm
pkg/scaffold/util/util.go
Outdated
@@ -26,6 +26,7 @@ import ( | |||
"sigs.k8s.io/kubebuilder/pkg/scaffold/resource" | |||
) | |||
|
|||
// nolint:lll |
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 can be fixed by either split the arguments across multiple lines or split the return values across multiple lines.
Version: "v1", | ||
Kind: "FirstMate", | ||
Namespaced: true, | ||
CreateExampleReconcileBody: true}, |
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.
IMO it's better to move the closed bracket }
to its own line.
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.
And add a comma at the end of CreateExampleReconcileBody: true,
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.
Done.
pkg/scaffold/util/util.go
Outdated
@@ -26,6 +26,7 @@ import ( | |||
"sigs.k8s.io/kubebuilder/pkg/scaffold/resource" | |||
) | |||
|
|||
// nolint:lll | |||
func GetResourceInfo(r *resource.Resource, repo, domain string, isMultiGroup bool) (resourcePackage, groupDomain string) { |
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.
func GetResourceInfo(r *resource.Resource, repo, domain string, isMultiGroup bool) (resourcePackage, groupDomain string) { | |
func GetResourceInfo( | |
r *resource.Resource, | |
repo, | |
domain string, | |
isMultiGroup bool, | |
) (resourcePackage, groupDomain string) { |
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.
I one of the 100 comments was requested to keep it. I agree with you 👍
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.
I guess these 2 lines are causing the problem.
repo,
domain string,
I guess you can change it to:
repo string,
domain string,
cmd/webhook_v2.go
Outdated
Long: `Scaffold a webhook for an API resource. You can choose to scaffold defaulting, validating and (or) conversion webhooks.`, | ||
Long: `Scaffold a webhook for an API resource. You can choose to scaffold defaulting,` + | ||
`validating and (or) conversion webhooks.`, |
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.
I think you are missing an space to indent this properly.
Also, I would use double quotes instead of back quotes if no special functionality given by backquote is needed.
And I also think you are missing an space after the comma
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.
I think you are missing a space to indent this properly.
The gofmt check indentation issues.
Also, I would use double quotes instead of back quotes if no special functionality given by backquote is needed.
The long ones require ``
And I also think you are missing an space after the comma
👍 yes, this we can address :-)
pkg/scaffold/api.go
Outdated
api.Resource, | ||
api.project.Repo, | ||
api.project.Domain, | ||
api.project.MultiGroup) |
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.
api.project.MultiGroup) | |
api.project.MultiGroup, | |
) |
@@ -108,7 +108,8 @@ var _ = Describe("kubebuilder", func() { | |||
|
|||
// NOTE: If you want to run the test against a GKE cluster, you will need to grant yourself permission. | |||
// Otherwise, you may see "... is forbidden: attempt to grant extra privileges" | |||
// $ kubectl create clusterrolebinding myname-cluster-admin-binding --clusterrole=cluster-admin --user=myname@mycompany.com | |||
// $ kubectl create clusterrolebinding myname-cluster-admin-binding \ | |||
// --clusterrole=cluster-admin --user=myname@mycompany.com |
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.
// --clusterrole=cluster-admin --user=myname@mycompany.com | |
// --clusterrole=cluster-admin --user=myname@mycompany.com |
Visual indent
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.
1 of 100 comments requests to add \ and remove the spaces. :-)
I prefer this other suggestion either if you do not mind.
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.
Did I request to remove the spaces? Well it seems I changed my mind sorry for that. The /
is needed but thats already there.
@@ -159,7 +159,8 @@ var _ = Describe("kubebuilder", func() { | |||
|
|||
// NOTE: If you want to run the test against a GKE cluster, you will need to grant yourself permission. | |||
// Otherwise, you may see "... is forbidden: attempt to grant extra privileges" | |||
// $ kubectl create clusterrolebinding myname-cluster-admin-binding --clusterrole=cluster-admin --user=myname@mycompany.com | |||
// $ kubectl create clusterrolebinding myname-cluster-admin-binding \ | |||
// --clusterrole=cluster-admin --user=myname@mycompany.com |
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.
// --clusterrole=cluster-admin --user=myname@mycompany.com | |
// --clusterrole=cluster-admin --user=myname@mycompany.com |
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.
1 of 100 comments requests to add \ and remove the spaces. :-)
I prefer this other suggestion either, if you do not mind.
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.
Again, sorry.
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.
Now worry. Thank you a lot for your contributions btw.
# This patch inject a sidecar container which is a HTTP proxy for the controller manager, | ||
# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. | ||
# This patch inject a sidecar container which is a HTTP proxy for the | ||
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. |
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.
How can this pass the lll
test if it the second line is longer after the change than the first line before the change?
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 line is in the correct size.
The lint issue was in the line where the const is defined.
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 sounds like a bug in lll linter...
I guess we can keep what we have now in the PR for now.
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.
It is not. The GitHub diff is making harder you folks get what was a change here.
The change/fix is regarding the above line where the const is defined.
# This patch inject a sidecar container which is a HTTP proxy for the controller manager, | ||
# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. | ||
# This patch inject a sidecar container which is a HTTP proxy for the | ||
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. |
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.
Same as above
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 line is in the correct size.
The lint issue was in the line where the const is defined.
9032028
to
4fa7843
Compare
4fa7843
to
c52ba01
Compare
Hi @mengqiy now I think we can move forward with this one 👍 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, mengqiy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Enable the lint check lll
(It will ensure the size of lines since is not a good practice be required to use the scroll to check the code.)
NOTE: issues fix as always that is possible or ignored.