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

Project scaffold by default has some lint errors which must be fixed #4376

Closed
camilamacedo86 opened this issue Nov 22, 2024 · 2 comments · Fixed by #4384
Closed

Project scaffold by default has some lint errors which must be fixed #4376

camilamacedo86 opened this issue Nov 22, 2024 · 2 comments · Fixed by #4384
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@camilamacedo86
Copy link
Member

What broke? What's expected?

I expected to create a project and push it for the repo and see all actions passing successfully
However, the lint is broken

Running [/home/runner/golangci-lint-1.61.0-linux-amd64/golangci-lint run] in [/home/runner/work/test-project/test-project] ...
  Error: internal/webhook/v1alpha1/busybox_webhook.go:84:2: comment-spacings: no space between comment delimiter and comment text (revive)
  	//TODO(user): Add more fields as needed for validation
  	^
  Error: test/utils/utils.go:95:36: unnecessary conversion (unconvert)
  	crdList := GetNonEmptyLines(string(output))
  	                                  ^
  Error: test/utils/utils.go:156:36: unnecessary conversion (unconvert)
  	crdList := GetNonEmptyLines(string(output))
  	                                  ^
  Error: test/e2e/e2e_test.go:319:30: unnecessary conversion (unconvert)
  		err = json.Unmarshal([]byte(output), &token)
  		                           ^
  Error: internal/controller/busybox_controller.go:102:5: S1009: should omit nil check; len() for []k8s.io/apimachinery/pkg/apis/meta/v1.Condition is defined as zero (gosimple)
  	if busybox.Status.Conditions == nil || len(busybox.Status.Conditions) == 0 {
  	   ^
  Error: test/e2e/e2e_test.go:96:38: printf: non-constant format string in call to fmt.Fprintf (govet)
  				_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Controller logs:\n %s", controllerLogs))
  				                                 ^
  Error: test/e2e/e2e_test.go:98:38: printf: non-constant format string in call to fmt.Fprintf (govet)
  				_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Controller logs: %s", err))
  				                                 ^
  Error: test/e2e/e2e_test.go:105:38: printf: non-constant format string in call to fmt.Fprintf (govet)
  				_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Kubernetes events:\n%s", eventsOutput))
  				                                 ^
  
  Error: issues found
  Ran golangci-lint in 1037[28](https://github.com/camilamacedo86/test-project/actions/runs/11970757483/job/33374161657#step:4:30)ms

The scaffold should generate should not have those issues

Reproducing this issue

Run

kubebuilder init
kubebuilder create api --group example.com --version v1alpha1 --kind Busybox --image=busybox:1.36.1 --plugins="deploy-image/v1-alpha"
kubebuilder create webhook --group example.com --version v1alpha1 --kind Busybox --defaulting --programmatic-validation

Then, push the code for a GitHub repo and validate if the lint action will pass

NOTE We should fix the issues and validate the actions of our github to lint the scaffolded projects.
We should get this error in our CI to avoid this scenario.
We must ensure that we are validating all samples under testdata

KubeBuilder (CLI) Version

master

PROJECT version

No response

Plugin versions

No response

Other versions

No response

Extra Labels

No response

@camilamacedo86 camilamacedo86 added kind/bug Categorizes issue or PR as related to a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Nov 22, 2024
@sokori
Copy link

sokori commented Nov 22, 2024

Running [/home/runner/golangci-lint-1.61.0-linux-amd64/golangci-lint run] in [/home/runner/work/test-project/test-project] ...
Error: internal/webhook/v1alpha1/busybox_webhook.go:84:2: comment-spacings: no space between comment delimiter and comment text (revive)
//TODO(user): Add more fields as needed for validation

as per the error message there should be a space after the "//"
(x) //TODO(user)
(R) // TODO(user)

@monteiro-renato
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants