<div id="doc" class="markdown-body container-fluid"><h2 id="Development-Code-Review-Procedures-and-Guidelines">Development Code Review Procedures and Guidelines</h2><p>
    This topic should give you as a developer a brief overview about what you <em>should</em> do, <em>must</em> do, aswell as <em>can</em> and <em>can not</em> do. What you as devepoler can expect from Armbian and what we expect from you.
</p><p>
</p><h2 id="Requirements"><strong>Requirements:</strong></h2><p></p><p>
	Even though you may already be a developer, just to make sure, here is an outline of the expectations for this process:
</p><table>
<thead>
<tr>
<th></th>
<th style="text-align:center">Review</th>
<th style="text-align:center">Approve</th>
<th style="text-align:center">Merge</th>
</tr>
</thead>
<tbody>
<tr>
<td>Github ID</td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
<td style="text-align:center"><img class="emoji" alt=":x:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/x.png"></td>
<td style="text-align:center"><img class="emoji" alt=":x:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/x.png"></td>
</tr>
<tr>
<td>Armbian Github Organisation Collaborator</td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
<td style="text-align:center"><img class="emoji" alt=":x:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/x.png"></td>
</tr>
<tr>
<td>Armbian Github Organisation Member</td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
<td style="text-align:center"><img class="emoji" alt=":white_check_mark:" src="https://docs.lane-fu.com/build/emojify.js/dist/images/basic/white_check_mark.png"></td>
</tr>
</tbody>
</table><p>Armbian Organization Members are required to have:</p><ul>
<li>An account on Armbian Community Forums</li>
<li>An account on Armbian Jira</li>
        <ol>
        <li><a href=https://id.atlassian.com>Register Atlassian account</a></li>
        <li><a href=https://armbian.atlassian.net/login.jsp>Request R/W access to Armbian Jira</a></li>
        </ol>
<li>Enabled 2FA for their GitHub account</li>
</ul><p>You <strong>should </strong>know development basics like how to get an Armbian image running on your hardware, do basic debugging, building a kernel and how to use the Armbian build system.</p><p>
</p><h2 id="Code-Review"><strong>Code Review:</strong></h2><p></p><p>
    <b>Some helpful guidelines for pull requests and code reviews</b>
</p><p>
	It has often been said that programming is part art, part science - that is because lots of times there is no single, simple solution to a problem. Or if there is, we might not know about it. There is also an infamous joke that if there are n developers in the room, then there are n+1 opinions on how things should be done. That being said, here are some guidelines that should prevent friction when submitting or reviewing code.
</p><h2 id="The-most-important-thing"><strong>The most important thing</strong></h2><b>The code has to work.</b><br><br><p>Unless you open a PR (“pull request”) as a work in progress, the code should be built and tested on a device or emulator. Do not rely on CI test automation!</p><p>If you have touched the build files and changed build setup, it is useful to test the whole build from scratch (clean build) and all of the types and flavours. If you updated external libraries, test the pertaining features. If you changed the build version, make a build and test that the version is correct.</p><p>Having people review your code is one thing, but you should not expect them to also test the code for you when not explicitly asked for.</p><p></p><h2 id="Context">Context</h2><p>One important thing that lots of guidelines forget to mention is the context of the pull request: Sometimes it is a big refactor, sometimes it is a new feature, sometimes it is a bugfix. Some of those might be more urgent than others, and sometimes you might be under pressure to ship ASAP so the code might not be perfect or there will not be any tests or code might not be extendable. <b>That is ok.</b></p><h2 id="Everyone">Everyone</h2><li>There is no perfect code: good enough is usually good enough. That being said, try to keep the number of WTFs per minute to a minimum.</li><li>Accept that many programming decisions are opinions. Discuss trade-offs, which you prefer, and reach a resolution quickly.</li><li>Ask for clarification. ("I didn't understand. Can you clarify?")</li><li>Offer clarification, explain the decisions you made to reach a solution in question.
    Avoid using terms that could be seen as referring to personal traits. ("dumb", "stupid"). Assume everyone is intelligent and well-meaning.</li><li>Be humble. ("I'm not sure - let's look it up.")</li><li>Do not use hyperbole ("always", "never", "endlessly", "nothing"). Avoid sarcasm.</li><li>Remember that you are both on the same side - the goal is to make the code better. Understand that sometimes your ideas will be overruled. Even if you do turn out to be right, do not take revenge or say, "I told you so".</li><li>Talk synchronously (e.g. chat, screensharing, in person) if there are too many "I didn't understand" or "Alternative solution:" comments. Pull requests should not be the place for long discussions, architectural or otherwise. </li><li>Put notes on what is missing or could be improved in the PR description or comments. You can also make a Jira ticket with discussions points and possible problems or things to do and discuss it offline.</li><h2 id="As-a-Code-Submitter">As a Code Submitter</h2><li>PRs should be about one thing. If you do multiple things in one PR, it is hard to review. If you are fixing stuff as you go, you might want to make atomic commits and then cherry-pick those commits into separate branches, leaving the PR clean.</li><li>Try to keep the PRs small. </li><li>Having a PR description is useful. Additionally, you can also link to the Jira ticket. </li><li>Ideally, the PR should be finished when submitted. If the PR is work in progress, add (WIP) or [WIP] to the title.</li><li>You should have tests that at least cover the logic, and ideally also cover the input/output parameters and methods. (depends on context)</li><li>Make sure to add a documentation PR when needed https://github.com/armbian/documentation</li><h2 id="As-a-Reviewer">As a Reviewer</h2><li>Reviewing code is part of a normal workday. You should check for open/updated PRs / Jira ticket as often as you can.</li><li>Ask, do not tell. (“What do you think about trying…?” rather than “Don’t do…”)</li><li>Offer ways to simplify or improve code.</li><li>Code beautification and refactoring ought to be tasks in the next sprint, except for obvious and easy-to-fix things.</li><li>Communicate which ideas you feel strongly about and those you do not. Explain your reasons why code should be changed. (Not in line with the style guide? A personal preference?)</li><li>If you disagree strongly, consider giving it a few minutes before responding; think before you react.</li><li>Offer alternative implementations, but assume the author already considered them. ("What do you think about using a custom validator here?")</li><li>If discussions turn too theoretical or touch big architectural questions, move the discussion offline. In the meantime, let the author make the final decision on alternative implementations.</li><li>Do not keep the code hostage. Keep in mind the context and the most important thing - does it work?</li><h2 id="Merging-a-merge-request"><strong>Merging a merge request</strong></h2><h4 id="Before-making-the-decision-to-merge">Before making the decision to merge:</h4><li>Set a milestone.</li><li>Consider warnings and errors from Github CI bots, code quality bots, and other reports. Unless a strong case can be made for the violation, these should be resolved before merging. A comment must be posted if the PR is merged with any failed job.</li><li>If the PR contains both quality and non-quality-related changes, the PR should be merged by the relevant maintainer or senior software engineer after the quality related changes are approved by more then one software engineer.</li><br><p>If a pull request is fundamentally ready, but needs only trivial fixes (such as typos), consider demonstrating a bias for action by making those changes directly without going back to the author. You can do this by using the suggest changes feature to apply your own suggestions to the pull request.</p><p><b>Note that:</b></p><li>merging is limited to Armbian Github Organization members, you can  <a href="https://www.armbian.com/contact" target="_blank" rel="noopener">apply here</a> to become one, if you have not already been invited.</li><li>If the changes are not straightforward, please prefer allowing the author to make the change.</li><li>Before applying suggestions, edit the pull request to make sure squash and merge is enabled</li><br><p><em><strong>Authors are not authorized to merge their own pull requests and need to seek approval from another maintainer / developer to merge.</strong></em></p><h2 id="Armbians-Assistance"><strong>Armbian's Assistance</strong></h2><p></p><p>If you have questions about being a developer or want to learn more and deeper insights about the build framework, Armbian will try to guide you to the appropriate documentation or information in a <em>best-effort</em> fashion. If time allows, at our descrection, we will try our best to explain and teach you personally various aspects about our processes. If best effort guidance is not enough, contact us for <a href="https://www.armbian.com/contact" target="_blank" rel="noopener">professional assistance</a>.</p><p>If you have any concerns please do not hesitate to reach out via forums, IRC or Discord. <em><strong>Armbian cares about the people who care about Armbian</strong></em>&nbsp; <span><img alt=":)" data-emoticon="true" height="20" src="https://forum.armbian.com/uploads/emoticons/default_smile.png" title=":)" width="20"></span></p><h3 id="References--Sources"><i>References / Sources:</i></h3><ul>
<li><a href="https://github.com/thoughtbot/guides/tree/master/code-review" target="_blank" rel="noopener">https://github.com/thoughtbot/guides/tree/master/code-review</a></li>
<li><a href="https://github.com/blog/1943-how-to-write-the-perfect-pull-request" target="_blank" rel="noopener">https://github.com/blog/1943-how-to-write-the-perfect-pull-request</a></li>
<li><a href="https://blog.codinghorror.com/the-ten-commandments-of-egoless-programming/" target="_blank" rel="noopener">https://blog.codinghorror.com/the-ten-commandments-of-egoless-programming/</a></li>
<li><a href="https://hackernoon.com/tagged/code-review" target="_blank" rel="noopener">https://hackernoon.com/tagged/code-review</a></li>
<li><a href="https://hackernoon.com/the-art-of-pull-requests-6f0f099850f9" target="_blank" rel="noopener">https://hackernoon.com/the-art-of-pull-requests-6f0f099850f9</a></li>
<li><a href="https://gist.github.com/mrsasha/8d511770ad9b282f3a5d0f5c8acdd10e" target="_blank" rel="noopener">https://gist.github.com/mrsasha/8d511770ad9b282f3a5d0f5c8acdd10e</a></li>
<li><a href="https://docs.gitlab.com/ee/development/code_review.html#everyone" target="_blank" rel="noopener">https://docs.gitlab.com/ee/development/code_review.html#everyone</a></li>
</ul></div>
