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

enable golint lll check #1305

Merged
merged 1 commit into from
Jan 18, 2020
Merged

Conversation

camilamacedo86
Copy link
Member

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 12, 2020
@camilamacedo86
Copy link
Member Author

/assign @pmorie

@camilamacedo86
Copy link
Member Author

/assign @mengqiy

Copy link
Contributor

@Adirio Adirio left a 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.

cmd/init_project.go Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
cmd/init_project.go Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Show resolved Hide resolved
test/e2e/utils/test_context.go Outdated Show resolved Hide resolved
test/e2e/v1/e2e_suite.go Outdated Show resolved Hide resolved
test/e2e/v1/e2e_suite.go Outdated Show resolved Hide resolved
test/e2e/v2/e2e_suite.go Outdated Show resolved Hide resolved
test/e2e/v2/e2e_suite.go Show resolved Hide resolved
pkg/scaffold/util/util.go Outdated Show resolved Hide resolved
@@ -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",
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

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
},

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

cmd/webhook_v1.go Outdated Show resolved Hide resolved
@Adirio

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2020
@Adirio

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2020
@Adirio Adirio mentioned this pull request Jan 14, 2020
41 tasks
@@ -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.`,
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

solved

@mengqiy
Copy link
Member

mengqiy commented Jan 16, 2020

Need rebase

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2020
@mengqiy
Copy link
Member

mengqiy commented Jan 17, 2020

@camilamacedo86 Please rebase

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 17, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 17, 2020
Copy link
Contributor

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 17, 2020
@@ -26,6 +26,7 @@ import (
"sigs.k8s.io/kubebuilder/pkg/scaffold/resource"
)

// nolint:lll
Copy link
Member

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},
Copy link
Member

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.

Copy link
Contributor

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,

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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) {

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jan 17, 2020

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 👍

Copy link
Member

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,

Comment on lines 43 to 44
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.`,
Copy link
Contributor

@Adirio Adirio Jan 17, 2020

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

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jan 17, 2020

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 :-)

api.Resource,
api.project.Repo,
api.project.Domain,
api.project.MultiGroup)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// --clusterrole=cluster-admin --user=myname@mycompany.com
// --clusterrole=cluster-admin --user=myname@mycompany.com

Visual indent

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jan 17, 2020

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// --clusterrole=cluster-admin --user=myname@mycompany.com
// --clusterrole=cluster-admin --user=myname@mycompany.com

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jan 17, 2020

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, sorry.

Copy link
Member Author

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.

Comment on lines -1 to +2
# 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.
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Comment on lines -1 to +2
# 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Member Author

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.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 17, 2020
@camilamacedo86
Copy link
Member Author

Hi @mengqiy now I think we can move forward with this one 👍

@mengqiy
Copy link
Member

mengqiy commented Jan 18, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 18, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8f8905a into kubernetes-sigs:master Jan 18, 2020
@camilamacedo86 camilamacedo86 deleted the lint-lll branch January 18, 2020 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants