Skip to content

AWS CodeCommit source - avoid "for" loops #159

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

Merged
merged 1 commit into from
Jun 15, 2020
Merged

Conversation

tzununbekov
Copy link
Member

@tzununbekov tzununbekov commented Jun 15, 2020

  • preparePullRequests doesn't have for loop anymore:
    it's not explicitly documented, but it looks like nextToken in response is set only when we either specify list limit or there are more then 1000 items in list. However, our current loop break condition doesn't seem to do a correct check anyway and we're not hanging there forever only because nextToken is not used.
  • sendPushEvent and sendPREvent functions merged into a single sendEvent with event type assertion

mentioned in #58

@tzununbekov tzununbekov requested a review from antoineco June 15, 2020 13:07
@tzununbekov tzununbekov self-assigned this Jun 15, 2020
Comment on lines 250 to 253
err := event.SetData(cloudevents.ApplicationJSON, v)
if err != nil {
return fmt.Errorf("failed to set event data: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it matter that the interface is asserted here? Can't we move that outside of the switch? SetData accepts interfaces.

if err != nil {
return pullRequests, fmt.Errorf("failed to get PR info: %w", err)
}
//Get pull request IDs
Copy link
Contributor

Choose a reason for hiding this comment

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

A convention more than a written rule, but it's idiomatic to have a leading space for comments that are not meant to be consumed by machines (golang/go#37974 (comment)).

@tzununbekov tzununbekov force-pushed the codecommit-avoid-loop branch from 4cbf8e2 to 5550cb1 Compare June 15, 2020 13:52
@tzununbekov tzununbekov requested a review from antoineco June 15, 2020 13:53
@tzununbekov tzununbekov merged commit d4d0e87 into master Jun 15, 2020
@tzununbekov tzununbekov deleted the codecommit-avoid-loop branch June 15, 2020 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants