-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
doc: adding "rules of thumb" #12744
doc: adding "rules of thumb" #12744
Conversation
CONTRIBUTING.md
Outdated
### Rules of thumb | ||
|
||
1. __Provide motivation for the change__ | ||
Why will this change make the code better; does it fix a but, is it a new |
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.
but -> bug
CONTRIBUTING.md
Outdated
30 files is a reasonable size limit, so unless you have a good reason to make | ||
a bigger PR, try to break it into smaller pieces (still as self-contained | ||
as possible), and cross-reference them. You can also mark some of them as | ||
`blocked` pending the others. |
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.
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.
I'll reword, but IMHO something should be put in writing. For example @vsemozhetbyt made #12735 which is good, but very hard to review ( @vsemozhetbyt ment with love )
CONTRIBUTING.md
Outdated
|
||
1. __Provide motivation for the change__ | ||
Why will this change make the code better; does it fix a but, is it a new | ||
feature, etc. |
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.
This should go into the commit message section, imho.
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.
Ok, good!
Also some PRs don't follow the rules and don't include the original commit messages.
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.
Added.
CONTRIBUTING.md
Outdated
@@ -30,6 +30,22 @@ works. | |||
|
|||
This document will guide you through the contribution process. | |||
|
|||
### Rules of thumb | |||
|
|||
1. __Provide motivation for the change__ |
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.
No need to make the headings bold, we don’t do that elsewhere either. If you want these to be headings, then go with Markdown’s built-in support for, well, headings ;)
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.
Fixed.
CONTRIBUTING.md
Outdated
As part of the projects strategy we maintain several lines of code, code | ||
churn might hinder back-porting changes to other branches. Also when you | ||
change a line, your name will come up in `git blame` and might hide the | ||
previous writer of the 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.
This doesn’t really sound like a “rule of thumb” to me – It doesn’t really tell contributors anything about what they should or should not do, does it? (Also: “churn” might be a bit too much of a jargon-y term, I could imagine a lot of people don’t know what that means)
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.
"churn" is also quite subjective. At the code and learn events, we intentionally encourage participants to focus on very small changes that end up leading to quite a bit of churn individually. We have also become much better at very quickly reviewing and landing smaller changes.
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.
What I meant was changes that are just personal style changes (or a result of some automatic tool).
I'll make it more explicit, to things like
- renaming variables
- adding/removing white spaces
- reordering lines
Anything else?
(By the way: I assume it’s by accident, but you keep opening PRs from the nodejs/node repo instead of your fork … we don’t do that except for releases branches, can you try to make sure you open PRs from your fork for the future?) |
CONTRIBUTING.md
Outdated
use Google's cpplint (with some ajustments) so following their [style-guide](https://github.com/google/styleguide) | ||
should keep you in line. | ||
For JS we use this [ruleset](https://github.com/nodejs/node/blob/master/.eslintrc.yaml) | ||
for ESLint plus some of our own rules [custom rules](https://github.com/nodejs/node/tree/master/tools/eslint-rules) |
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.
This basically comes down to “run make test
/make lint
” before submitting a PR, right?
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.
Be aware (also changed title) so less surprises when actually doing make lint
Sorry, apparently it happens when I use the (limited) web interface. |
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.
Can you also format the commit message according to the commit guidelines, please?
(s/adding/add).
CONTRIBUTING.md
Outdated
feature, etc. This should be in the commit messages as well as in the PR | ||
description. | ||
2. #### Don't make _unnecessary_ code changes | ||
Things that are changed because of personal preferance or style, like: |
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.
s/preferance/preference
CONTRIBUTING.md
Outdated
renaming of variables or functions, adding or removing white spaces, | ||
reordering lines or whole code blocks. These sort of changes should have | ||
a good reason since they cause unnecessary ["code churn"](https://blog.gitprime.com/why-code-churn-matters). | ||
As part of the projects strategy we maintain several lines of code, 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.
I believe something like "we maintain multiple release lines" would be more clear?
CONTRIBUTING.md
Outdated
use Google's cpplint (with some ajustments) so following their [style-guide](https://github.com/google/styleguide) | ||
should keep you in line. | ||
For JS we use this [ruleset](https://github.com/nodejs/node/blob/master/.eslintrc.yaml) | ||
for ESLint plus some of our own rules [custom rules](https://github.com/nodejs/node/tree/master/tools/eslint-rules) |
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.
This will turn into duplicate phrases when rendered. Making "our own custom rules" a single link instead of "our own rules" text followed by the "custom rules" link would be better.
Addressed comments. PTAL. |
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.
I still mostly think point 1 should be moved into the section that’s actually about commit messages, and I’m not sure points 2 and 3 need to be described in that much detail…
CONTRIBUTING.md
Outdated
1. #### Provide motivation for the change | ||
Why will this change make the code better; does it fix a bug, is it a new | ||
feature, etc. This should be in the commit messages as well as in the PR | ||
description. |
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.
I still think this should go into the section describing commit messages
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.
Do you mean having it there as well?
Since this is a general section, IMHO people should have this is mind when thinking about a contribution.
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.
Well, I don’t think I’ve ever seen somebody make a PR without having a reason to do so 😄
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.
Sometimes I just like to churn 😄, reindent, reorder lines, rethink names etc... But I keep it to my code.
I ment the contributor should know they will need to explicitly provide their motivation.
P.S. adding to section about commit message
CONTRIBUTING.md
Outdated
### Rules of thumb | ||
|
||
1. #### Provide motivation for the change | ||
Why will this change make the code better; does it fix a bug, is it a new |
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.
It might be helpful to use full sentences here
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.
I tried, PTAL
CONTRIBUTING.md
Outdated
2. #### Don't make _unnecessary_ code changes | ||
Things that are changed because of personal preference or style, like: | ||
renaming of variables or functions, adding or removing white spaces, | ||
reordering lines or whole code blocks. These sort of changes should have |
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.
ditto for using full sentences, that will at least help everyone who’s not a native English speaker
CONTRIBUTING.md
Outdated
churn might hinder back-porting changes to other lines. Also when you | ||
change a line, your name will come up in `git blame` and might hide the | ||
previous writer of the code. | ||
3. #### Keep your change-set self contained but at a reasonable size |
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.
typo: self-contained
CONTRIBUTING.md
Outdated
4. #### Be aware of our style rules | ||
As part of acceptance of a PR the changes must pass our linters. For C++ we | ||
use Google's cpplint (with some ajustments) so following their [style-guide](https://github.com/google/styleguide) | ||
should keep you in line. |
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.
“keep you in line”?
CONTRIBUTING.md
Outdated
You can also mark some of them as `blocked` pending the others. | ||
4. #### Be aware of our style rules | ||
As part of acceptance of a PR the changes must pass our linters. For C++ we | ||
use Google's cpplint (with some ajustments) so following their [style-guide](https://github.com/google/styleguide) |
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.
typo: adjustments
@refack I dismissed that red cross sign, but not explicitly approving, I'm +0 on this. Generally it looks good but I have several concerns that overweight it.
|
I'd rather see less text, not more, in the CONTRIBUTING.md. I'd prefer a PR that removes everything that isn't absolutely essential. If we're going to provide helpful hints like this, I'd prefer they be below the instructions for forking etc., rather than at the top of the doc. I think most people will be discouraged by a wall of a text and won't read it. If we want to include this content, it should be one sentence per point with links to other docs if further explanation should be required. |
CONTRIBUTING.md
Outdated
@@ -122,6 +164,7 @@ changed and why. Follow these guidelines when writing one: | |||
Refs: http://eslint.org/docs/rules/space-in-parens.html | |||
Refs: https://github.com/nodejs/node/pull/3615 | |||
``` | |||
- It's it's not a fix, you should document the motivation for the change |
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.
It's it's
-> If it's
Punctuation at the end of the change.
Avoid you
.
So something like this perhaps:
If it's not a fix, document the motivation for the change.
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.
Fixed and removed you
, but there are a ton of previously existing your
in there.
I agree on less text but would go the other way, leave this guideline, and split technical stuff to another file. IMHO People should think a little bit beforehand, they can figure out the technical stuff later. (yeah, I heard that too. Funny that it is coming from me |
CONTRIBUTING.md
Outdated
<details> | ||
<summary><strong>Provide motivation for the change</strong></summary> | ||
Try to explain why this change will make the code better. For example, does | ||
it fix a bug, or is it a new feature, etc. This should expressed in the |
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.
Missing "be" in "This should be expressed".
CONTRIBUTING.md
Outdated
Use good judgment when making a big change. If a reason doesn't come to mid | ||
but a very big chage needs to be made, try to break it into smaller | ||
pieces (still as self-contained as possible), and cross-reference them, and | ||
marking some of them as `blocked` pending the others. |
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.
I think that asking this to a first time contributor is a bit too much. In the unlikely case where they will propose a big change we can still ask them to apply the necessary tweaks.
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.
I think only Collaborators can label issues, so the people who actually read this guide (that is: non-Collaborators) won't be able to do as instructed (mark something as blocked
).
@refack I don't know what problem this is trying to solve. To the extent that I am aware of problems with the CONTRIBUTING.md doc, this would seem to exacerbate them. This doc is mostly for new or infrequent contributors. While there are exceptions, the usual problem we have with these types of contributions is not (for example) that the change set lacks an obvious motivation. Yes, it happens, but it's not the biggest or most obvious pain point. The problems we see frequently stem from the fact that people either don't read it or don't understand this document. So, for example, we get commits that don't adhere to the commit message guidelines. If we're trying to solve that problem (which would be laudable), I would say the solution is to make the material in the CONTRIBUTING.md more succinct and more scannable. Perhaps we can make it more visual (although there may be problems with that too). I don't see any Collaborators (or anyone else for that matter) agreeing that either these changes or #12748 are needed or a good idea. I'm not even seeing positive GitHub reaction emoji things for either of them. I think the whole approach needs a re-think. Documentation is difficult (and the difficulty is greatly exacerbated by people thinking it's not difficult but that's a long comment for another day). I don't have any concrete suggestions as to how to make the doc more concise and scannable, but that's what I'd focus on instead. (Oh, here's a concrete idea: Maybe a short table of contents or set of internal links near the top, just below the Code of Conduct text: If you're opening an issue, go here; if you're trying to contribute code, go here. Might help the doc feel less overwhelmingly long. Maybe. Just an idea.) /cc @nodejs/documentation for some contrary/varied/other/concurring opinions/ideas |
@Trott I wasn't sure either that My motivation is that these "rules of thumb" or "best practices" are generally agreed upon, but the knowledge is not transferred or easily findable to new/infrequent contributors (in the wide sense not the @ nodejs/collaborators sense). I've refed some PRs that didn't consider these "rules" and so had to be addressed ad-hoc. I agree the general mood for the PR is ambiguous, but the participation and commenting was fairly extensive, so I figure people agree with what's written, or in the least care 👍 |
Added |
Two quick things
1) maybe a bunch of this content would make a good blog post for the nodejs
medium
2) would prefer we avoided the term "rule of thumb"... Check out the
Wikipedia article, but there is a chance some people may get the wrong idea
|
Ohh dear. |
@MylesBorins who edits the medium? I could turn this list into a "how to submit your first PR" or "how to submit a good PR" post for editing. |
@refack you should make a post over in @nodejs/evangelism |
Discussion moved to #12791
Fixes: #12636
[edit]
As I understand the term "rules of thumb", they are guidelines one should have in mind and try to adhere to, but are not necessarily hard requirements. Our requirements should be stated in the other parts of the document.
[/edit]
My suggestion for a few "rules of thumb" for code contributions.
These are obviously my personal opinion, so this PR welcomes edit and suggestions. I do think that we should put some loose guidelines in writing.
The following made me think of this, and are not critique!
Ref: #12603 - motivation
Ref: #12735 - size
Open questions:
Checklist
Affected core subsystem(s)
doc