All code in any code-base should look like a single person typed it, no matter how many people contributed.
- write DRY (Don't repeat yourself) Code
- do document and comment your code
- consistent naming scheme per language (further defined in the language guidelines)
- avoid deep nesting of code
- keep short line length
- Use tabs for indenting to visualize your codes hierarchy
- Use spaces for indenting to align your code
Tabs for hierarchy
function alertSomething() {
» alert('Something!');
}
Spaces for aligning
var foo = '',
····bar = '',
····baz = '';
Both mixed
function alertSomething() {
» var foo = 'Something',
» ····bar = '!';
» alert(foo + bar);
}
This is a really helpful practice. Code can be aligned and it will still be aligned for any monospaced font but you also preserve the semantic tab and every developer can decide his tab size by personal preference.
Commit Message Format (inspired by Angular Contributing Guidelines)
Each commit message consists of a header and a body:
<type>: <subject>
<body>
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various Git tools.
Must be one of the following:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
- content: Changes to site content or texts for websites or marketing
The subject contains succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize first letter
- no dot (.) at the end
In case you want to commit a fix, use the present passive voice to describe the problem you fix:
fix: passwords aren't encrypted
fix: emojis are missing
instead of or fix: encrypt passwords
fix: add emojis
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body further specifies what changed and may include the motivation for the change and contrast this with previous behavior.
- follow codeguide.co
- follow PSR-2
- follow PHPDoc
- the
@param
tag is followed by two spaces, the argument type, two more spaces and the variable name - use the short term for all primitives
- the
- follow GitHub Ruby Styleguide