-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix existing LGTM issues #4592
Fix existing LGTM issues #4592
Conversation
A few warnings have been detected in the code by lgtm.com https://lgtm.com/projects/g/tektoncd/pipeline/alerts/?mode=list - Two "Useless assignment to local variable" (innocuous) - One "Useless assignment to local variable" - small bug - One "Missing error check" (innocuous) Fixing all of them in this PR. Signed-off-by: Andrea Frittoli <[email protected]>
The following is the coverage report on the affected files.
|
@@ -967,11 +967,9 @@ func combineTaskRunAndTaskSpecLabels(pr *v1beta1.PipelineRun, pipelineTask *v1be | |||
tsLabels = pipelineTask.TaskSpecMetadata().Labels | |||
} | |||
|
|||
labels := make(map[string]string, len(trLabels)+len(tsLabels)) |
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.
thanks @afrittoli but I think there was a reason to implement it using make
here. From what I can recall, labels
is suppose to initialize a new map rather than referencing the same map trLabels
. The reason being, updating labels
will also update the tsLabels
. At the same time, I am surprised its not caught by any of the existing unit tests.
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.
Thanks @pritidesai - the change I made behaves like the current code. Even if labels
is initialised via make
, it's then overwritten by the line labels = trLabels
, which renders the make
line not effective - which is the reason it triggered the issue on https://lgtm.com/projects/g/tektoncd/pipeline/alerts/?mode=list.
If you want labels
to not be the same map as trLabels
, you will have to copy the elements from the original map one by one. If that is the desired behaviour, we can do that, but like you said we should have that covered by unit tests as well :)
/test pull-tekton-pipeline-alpha-integration-tests |
/retest |
/lgtm |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester 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 |
/test pull-tekton-pipeline-alpha-integration-tests |
Changes
A few warnings have been detected in the code by lgtm.com
https://lgtm.com/projects/g/tektoncd/pipeline/alerts/?mode=list
Fixing all of them in this PR.
Signed-off-by: Andrea Frittoli [email protected]
/kind cleanup
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
Release Notes