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

[chore] - Use config struct instead of pointer for engine scans. #709

Merged
merged 2 commits into from
Aug 12, 2022

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Aug 12, 2022

Use a config struct instead of pointer when scanning engine sources.
Remove the nil check from each scan.

@ahrav ahrav requested a review from a team as a code owner August 12, 2022 16:02
Copy link
Collaborator

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

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

Nice!

main.go Outdated
@@ -200,7 +200,7 @@ func run(state overseer.State) {
c.Filter = filter
}

if err = e.ScanGit(ctx, sources.NewConfig(g)); err != nil {
if err = e.ScanGit(ctx, *sources.NewConfig(g)); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: make sources.NewConfig return the struct instead of a pointer so we don't have to deref here.

Copy link
Collaborator Author

@ahrav ahrav Aug 12, 2022

Choose a reason for hiding this comment

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

yea i had thought about going that route. I guess I left it this way since it was the standard way that everyone is used to seeing this functional options implemented. One of those things where when you take a quick glance you just kinda go, "oh its doing that" and almost automatically think it should return a pointer. Similar to how we are used to seeing err != nil and when we see err == nil it usually requires a double take, or like e being used instead of err.

That being said I don't have a strong personal pref on this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool, thanks for sharing your reasoning! I'm not familiar with that pattern so it didn't occur to me.

@ahrav ahrav requested a review from a team as a code owner August 12, 2022 16:48
@ahrav ahrav merged commit 73f9d3f into main Aug 12, 2022
@ahrav ahrav deleted the chore-refactor-engine-scan-config branch August 12, 2022 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants