Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Add a coding style guide #953

Merged
merged 1 commit into from
Oct 8, 2020
Merged

Add a coding style guide #953

merged 1 commit into from
Oct 8, 2020

Conversation

johananl
Copy link
Member

This PR adds an initial code style guide for Lokomotive. The guide currently focuses mainly on Go code, however we could add guidelines for other types of code (e.g. HCL, Markdown).

I find it useful to maintain such a guide as I find myself commenting the same things over and over again in PRs and would love to have a document I could link to. I think that following a common and agreed-upon guide could make code reviews more efficient.

The document should be agreed upon by the team and is expected to evolve over time. The current state is by no means a comprehensive list of guidelines. Rather, it currently contains a small set of initial guidelines which I believe already have consensus in the team so we might as well formalize them.

@johananl johananl added the kind/documentation Issues about documentation label Sep 11, 2020
@invidian
Copy link
Member

@johananl did you see #883?

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Great start @johananl!

docs/development/coding-style-guide.md Outdated Show resolved Hide resolved
docs/development/coding-style-guide.md Show resolved Hide resolved
docs/development/coding-style-guide.md Show resolved Hide resolved
@johananl
Copy link
Member Author

@johananl did you see #883?

Nope, thanks for the pointer. I'm deliberately avoiding adding all the guidelines we know about from the start. Rather, I wanted to start by merging something simple and encourage the team to add more guidelines as the need arises.

@johananl johananl force-pushed the johananl/coding-style-guide branch 4 times, most recently from a3e6db1 to 72dd915 Compare September 11, 2020 14:58
invidian
invidian previously approved these changes Sep 11, 2020
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

LGTM ✔️

iaguis
iaguis previously approved these changes Sep 16, 2020
Copy link
Contributor

@iaguis iaguis left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

surajssd
surajssd previously approved these changes Sep 16, 2020
Copy link
Member

@surajssd surajssd left a comment

Choose a reason for hiding this comment

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

LGTM

knrt10
knrt10 previously approved these changes Sep 16, 2020
Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

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

Thank you for adding this. +1

ipochi
ipochi previously approved these changes Sep 16, 2020
Copy link
Member

@ipochi ipochi left a comment

Choose a reason for hiding this comment

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

minor suggestion but LGTM.

Great start @johananl

docs/development/coding-style-guide.md Show resolved Hide resolved
Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

Mostly LGTM.

The only thing I'm unsure about is the errors. I'm unsure if errors won't become cryptic or if we will simply have ton of review comments on error fromatting without much benefit.

Is there any other project using that style rule for errors? I guess from the blog post example maybe the go project itself?

docs/development/coding-style-guide.md Show resolved Hide resolved
docs/development/coding-style-guide.md Show resolved Hide resolved
docs/development/coding-style-guide.md Show resolved Hide resolved
docs/development/coding-style-guide.md Show resolved Hide resolved
@johananl
Copy link
Member Author

The only thing I'm unsure about is the errors. I'm unsure if errors won't become cryptic or if we will simply have ton of review comments on error fromatting without much benefit.

Not sure I got your point. What change are you suggesting? Removing the guidelines about errors?

Is there any other project using that style rule for errors? I guess from the blog post example maybe the go project itself?

There is https://github.com/golang/go/wiki/CodeReviewComments#error-strings if you're looking for an official recommendation. But it also just makes sense IMO because error strings are chained. These guidelines produce consistently-formatted, readable errors.

@rata
Copy link
Member

rata commented Sep 17, 2020

Not sure I got your point. What change are you suggesting? Removing the guidelines about errors?

Yes, that can be simpler. But no problem, we can remove it later if we find that it creates overhead and little benefit :)

@johananl
Copy link
Member Author

johananl commented Sep 17, 2020

Not sure I got your point. What change are you suggesting? Removing the guidelines about errors?

Yes, that can be simpler. But no problem, we can remove it later if we find that it creates overhead and little benefit :)

I've added only things which I've found myself constantly commenting on in PRs. That was actually the trigger for me starting this document. IMO not having guidelines for error strings is what's causing overhead. But anyway - sure, the idea is to evolve this doc over time and of course if some guideline proves to be counterproductive we should revisit.

@johananl johananl force-pushed the johananl/coding-style-guide branch 3 times, most recently from 441c793 to 51d748e Compare September 17, 2020 15:30
@johananl
Copy link
Member Author

johananl commented Oct 8, 2020

Thanks to everybody who chimed in. I will merge this since we don't seem to have any major disagreements around the content.
Please feel free to propose new additions or modify existing guidelines in new PRs.

@johananl johananl merged commit 63d6d78 into master Oct 8, 2020
@johananl johananl deleted the johananl/coding-style-guide branch October 8, 2020 17:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/documentation Issues about documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants