Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
New label processor #20
New label processor #20
Changes from 6 commits
44377ad
c653728
07bb04a
cead14f
dc2c51b
2c4f5b6
8ef60c3
fe6d263
a2ee231
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
You can save some repetition if you have this outer loop build into
deDuplicateAndAppend
function. So like:So basically have the
deDuplicateAndAppend
to deal with looping through configured labels. If you do this, the above 3 functions would have less duplicate code.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.
great idea, will do
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.
nit: while this comment is good, it explains what the function is doing not "how", but consider if you can use better name for the function such that you don't need to have a comment for it.
DeDuplicateAndAppend
is a bit misleading here because this function is not really doing "deduplicate"; it is either overwriting or append. The code is actually overwriting the label value regardless if the label value is "duplicated" or not. So maybe a term like "Upsert" or "UpdateOrInsert" would be a better term to use.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 that I think about it, I agree the function name is not very representative of what it is actually doing, I will change it to "upsert" as that is a term used in other parts of the collector as well
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.
nit: Usually comment like this is not useful as we can see what you are doing from the code quite easily. Also comment like this may start to be a lie as time goes; when other started to modify code but not the comment.
If you really think that comment like this is needed, then consider restructuring your code like the following to use method name as comment (but I don't think it's needed in your case, so following is just example).
This applies to the
// If it does not exist, append it
comment too.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.
Makes sense to me, comments will be removed