|
2 | 2 |
|
3 | 3 | Thanks for your interest in Sonata projects! |
4 | 4 |
|
| 5 | +This document is about issues and pull requests. |
| 6 | + |
5 | 7 | ## Summary |
6 | 8 |
|
7 | 9 | * [Issues](#issues) |
8 | 10 | * [Pull Requests](#pull-requests) |
9 | | -* [Label rules]() |
| 11 | +* [Code Reviews](#code-reviews) |
10 | 12 |
|
11 | 13 | ## Issues |
12 | 14 |
|
@@ -338,6 +340,88 @@ We agreed that blank color is boring and so deja vu. Pink is the new way to do. |
338 | 340 | ``` |
339 | 341 | (Obviously, this commit is fake. :wink:) |
340 | 342 |
|
| 343 | +## Code Reviews |
| 344 | + |
| 345 | +Grooming a PR until it is ready to get merged is a contribution by itself. |
| 346 | +Indeed, why contribute a PR if there are hundreds of PRs already waiting to get reviewed and hopefully, merged? |
| 347 | +By taking up this task, you will try to speed up this process by making sure the merge can be made with peace of mind. |
| 348 | + |
| 349 | +### Commenting on a PR |
| 350 | + |
| 351 | +Before doing anything refrain to dive head-first in the details of the PR and try to see the big picture, |
| 352 | +to understand the subject of the PR. If the PR fixes an issue, read the issue first. |
| 353 | +This is to avoid the pain of making a reviewer rework their whole PR and then not merging it. |
| 354 | + |
| 355 | +Things to hunt for : |
| 356 | + |
| 357 | +- missing docs . This is what you should look for first. If you think the PR lacks docs, |
| 358 | +ask for them, because you will be better at reviewing it if you understand it better, |
| 359 | +and docs help a lot with that. |
| 360 | +- missing tests : Encourage people to do TDD by making clear a PR will not get merged |
| 361 | +if it lacks tests. Not everything is easy to test though, keep that in mind. |
| 362 | +- BC breaks : If there is a BC-break, ask for a deprecation system to be created instead, |
| 363 | +and make sure the `master` branch is used. |
| 364 | +- Unclear pieces of code : does the code use clear, appropriate variable or class names, |
| 365 | +or does it use names like `data`, `result`, `WhateverManager`, `SomethingService`? |
| 366 | +Are exception names still meaningful if you remove the `Exception` suffix? Do all |
| 367 | +exceptions have a custom message? |
| 368 | +Is the contributor trying to be clever or to be clear? |
| 369 | +- Violations of the [SOLID][solid] principles : |
| 370 | + - S : If a class is 3000 lines long, maybe it does too many things? |
| 371 | + - O : Is there a big switch statement that might grow in the future? |
| 372 | + - L : Does the program behave reasonably when replacing a class with a child class? |
| 373 | + - I : Are interfaces small and easy to implement? If not, can they be split into smaller interfaces? |
| 374 | + - D : Is the name of a class hardcoded in another class, with the `new` keyword or a static call? |
| 375 | +- Spelling / grammar mistakes, including in commit messages or UPGRADE / CHANGELOG notes. |
| 376 | +- Dependency modifications : is anything new introduced, if yes is it worth it? |
| 377 | + |
| 378 | +[solid]: https://en.wikipedia.org/wiki/SOLID_(object-oriented_design) |
| 379 | + |
| 380 | +Leave no stone unturned. When in doubt, ask for a clarification. If the |
| 381 | +clarification seems useful, and does not appear in a code comment or in a commit |
| 382 | +message, say so and / or make use a squash-merge to customize the commit message. |
| 383 | +Ideally, the project history should be understandable without an internet connection, |
| 384 | +and the PR should be understandable without having a look at the changes. |
| 385 | + |
| 386 | +Also, make sure your feedback is actionable, it is important to keep the ball rolling, |
| 387 | +so if you raise a question, try to also provide solutions. |
| 388 | + |
| 389 | +### Labelling the PR |
| 390 | + |
| 391 | +Applying labels requires write access to PRs, but you can still advise if you do not have them. |
| 392 | +There are several labels that will help determine what the next version number will be. |
| 393 | +Apply the first label that matches one of this conditions, in that order: |
| 394 | + |
| 395 | +- `major`: there is a BC-break. The PR should target the `master` branch. |
| 396 | +- `minor`: there is a backwards-compatible change in the API. The PR should target the stable branch. |
| 397 | +- `patch`: this fixes an issue (not necessarily reported). The PR should target the stable branch. |
| 398 | +- `docs`: this PR is solely about the docs. `pedantic` is implied. |
| 399 | +- `pedantic`: this change does not warrant a release. |
| 400 | + |
| 401 | +Also if you see that the PR lacks documentation, tests, a changelog note, |
| 402 | +or an upgrade note, use the appropriate label. |
| 403 | + |
| 404 | +### Reviewing PRs with several commits |
| 405 | + |
| 406 | +If there are several commits in a PR, make sure you review it commit by commit, |
| 407 | +so that you can check the commit messages, and make sure the commit are independent |
| 408 | +and atomic. |
| 409 | + |
| 410 | +### Merging |
| 411 | + |
| 412 | +Do not merge something you wrote yourself. Do not merge a PR you reviewed alone, |
| 413 | +instead, merge PRs that have already be reviewed and approved by another reviewer. |
| 414 | +If there is only one commit in the PR, prefer the squash feature, otherwise, always |
| 415 | +use a regular merge. |
| 416 | +And finally, use your common sense : if you see a PR about a typo, |
| 417 | +or if there is a situation (faulty commit, revert needed) maybe you can merge it directly. |
| 418 | + |
| 419 | +### Be nice to the contributor |
| 420 | + |
| 421 | +Thank them for contributing. Encourage them if you feel this is going to be long. |
| 422 | +In short, try to make them want to contribute again. If they are stuck, try to provide them with |
| 423 | +code yourself, or ping someone who can help. |
| 424 | + |
341 | 425 | [sphinx_install]: http://www.sphinx-doc.org/en/stable/ |
342 | 426 | [pip_install]: https://pip.pypa.io/en/stable/installing/ |
343 | 427 | [sf_docs_standards]: https://symfony.com/doc/current/contributing/documentation/standards.html |
0 commit comments