-
Notifications
You must be signed in to change notification settings - Fork 612
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
[Bug]: Unused variable warning in mutating_webhook.go #901
Comments
I'm assuming that you're talking about https://github.com/k8sgpt-ai/k8sgpt/blob/main/pkg/analyzer/mutating_webhook.go. k8sgpt/pkg/analyzer/mutating_webhook.go Line 133 in 60853fe
|
Due to the continue statement, the code exits the inner for loop prematurely, causing line 133 to never execute. I also tested it in cases where no service is defined, and in such instances, it does not return any result. k8sgpt/pkg/analyzer/mutating_webhook.go Line 78 in 60853fe
|
Ahh, now I get it. Great analysis! |
Also, there is same bug on k8sgpt/pkg/analyzer/validating_webhook.go Lines 59 to 78 in 60853fe
|
Yepp. I noticed this too in https://github.com/k8sgpt-ai/k8sgpt/actions/runs/7746749007/job/21166974081 |
Checklist
Affected Components
K8sGPT Version
v0.3.26
Kubernetes Version
v1.29.1
Host OS and its Version
Linux
Steps to reproduce
failures
is appended for first time when service is not found casefailures
is never used"Expected behaviour
The
failures
variable should be used after being declared and appended to, or it should be removed if it's not needed.Actual behaviour
In the file
mutating_webhook.go
, there's a warning indicating that the variable failures is declared but never used. This implies that in the current code structure, if an error occurs while creating services, we append the failure but continue the loop without storing it. As a result, this failure is never accounted for.Additional Information
This warning could potentially indicate dead code or a bug where the
failures
variable should be used but isn't. It's also a code quality issue as unused variables can lead to confusion and make the code harder to understand. If this issue is valid then I want to fix this.The text was updated successfully, but these errors were encountered: