Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 title=Coding Style | 1 title=Coding Style |
2 | 2 |
3 | 3 |
4 <h2 id="precedence">{{s1 Precedence}}</h2> | 4 <h2 id="precedence">{{s1 Precedence}}</h2> |
5 | 5 |
6 <p>{{s2 The Adblock Plus coding style is based on others. Our rules (both genera l and language specific) always overrule referenced style guides. The language s pecific sections overrule the general section.}}</p> | 6 <p>{{s2 The Adblock Plus coding style is based on others. Our rules (both genera l and language specific) always overrule referenced style guides. The language s pecific sections overrule the general section.}}</p> |
7 | 7 |
8 <h2 id="consistency">{{s3 Consistency}}</h2> | 8 <h2 id="consistency">{{s3 Consistency}}</h2> |
9 | 9 |
10 <p>{{s4 Consistency is most important: Be consistent within functions, files, mo dules and projects. Making existing code conform with this style guide is fine, but it should happen in dedicated commits, preferably for a whole module or proj ect at once.}}</p> | 10 <p>{{s4 Consistency is most important: Be consistent within functions, files, mo dules and projects. Making existing code conform with this style guide is fine, but it should happen in dedicated commits, preferably for a whole module or proj ect at once.}}</p> |
(...skipping 25 matching lines...) Expand all Loading... | |
36 <li>{{html-css-optional-tag Don't omit optional HTML tags.}}</li> | 36 <li>{{html-css-optional-tag Don't omit optional HTML tags.}}</li> |
37 <li>{{html-css-hexadecimal CSS color values should be specified in hexadecimal where possible.}}</li> | 37 <li>{{html-css-hexadecimal CSS color values should be specified in hexadecimal where possible.}}</li> |
38 <li>{{html-css-shorthand CSS shorthand properties usage is optional.}}</li> | 38 <li>{{html-css-shorthand CSS shorthand properties usage is optional.}}</li> |
39 <li>{{html-css-order CSS rule declaration order should follow the <a href="htt ps://make.wordpress.org/core/handbook/best-practices/coding-standards/css/#prope rty-ordering">WordPress CSS Coding Standards</a>.}}</li> | 39 <li>{{html-css-order CSS rule declaration order should follow the <a href="htt ps://make.wordpress.org/core/handbook/best-practices/coding-standards/css/#prope rty-ordering">WordPress CSS Coding Standards</a>.}}</li> |
40 <li>{{html-css-units CSS number values should specify units where possible.}}< /li> | 40 <li>{{html-css-units CSS number values should specify units where possible.}}< /li> |
41 <li>{{html-css-leading-zero Don't omit the optional leading 0 for decimal numb ers.}}</li> | 41 <li>{{html-css-leading-zero Don't omit the optional leading 0 for decimal numb ers.}}</li> |
42 </ul> | 42 </ul> |
43 | 43 |
44 <h2 id="python">{{s19 Python}}</h2> | 44 <h2 id="python">{{s19 Python}}</h2> |
45 <ul> | 45 <ul> |
46 <li>{{python-general Follow <a href="https://www.python.org/dev/peps/pep-0008/ ">PEP-8</a> and the recommendations in the offical Python documentation.}}</li> | 46 <li>{{python-general Follow <a href="https://www.python.org/dev/peps/pep-0008/ ">PEP-8</a> and the recommendations in the offical Python documentation.}}</li> |
Sebastian Noack
2016/05/11 16:20:02
I removed the reference to Mozilla's Python practi
| |
47 <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/2/library/functions.html#func-repr"><code><fix >repr()</fix></code></a> in Python 2, or <a href="https://docs.python.org/3/libr ary/functions.html#ascii"><code><fix>ascii()</fix></code></a> in Python 3, i.e. use single quotes except to avoid escaping of embedded quotes and escape special and non-ascii characters. For docstrings however follow <a href="https://www.py thon.org/dev/peps/pep-0257/">PEP-257</a>.}}</li> | 47 <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/2/library/functions.html#func-repr"><code><fix >repr()</fix></code></a> in Python 2, or <a href="https://docs.python.org/3/libr ary/functions.html#ascii"><code><fix>ascii()</fix></code></a> in Python 3, i.e. use single quotes except to avoid escaping of embedded quotes and escape special and non-ascii characters. For docstrings, however, follow <a href="https://www. python.org/dev/peps/pep-0257/">PEP-257</a>.}}</li> |
Vasily Kuznetsov
2016/05/11 16:55:42
Perhaps add commas around "however" in the last se
Sebastian Noack
2016/05/11 17:07:44
Well, it's an exception to the rule in the first s
| |
48 <li>{{python-prefix In modules, prefix private functions and variables with a single underscore.}}</li> | 48 <li>{{python-prefix In modules, prefix private functions and variables with a single underscore.}}</li> |
49 <li>{{python-concatenation Use the <code><fix>+</fix></code> operator when con catenating exactly two strings, use the <a href="https://docs.python.org/2/libra ry/stdtypes.html#str.format"><code><fix>format()</fix></code> method</a> for mor e complex string formatting, use the <a href="https://docs.python.org/2/library/ stdtypes.html#str.join"><code><fix>join()</fix></code> method</a> when concatena ting pre-existing sequences.}}</li> | 49 <li>{{python-concatenation Use the <code><fix>+</fix></code> operator when con catenating exactly two strings, use the <a href="https://docs.python.org/2/libra ry/stdtypes.html#str.format"><code><fix>format()</fix></code> method</a> for mor e complex string formatting, use the <a href="https://docs.python.org/2/library/ stdtypes.html#str.join"><code><fix>join()</fix></code> method</a> when concatena ting pre-existing sequences.}}</li> |
50 <li>{{python-tuple-vs-list Use tuples for data that have structure, use lists for data that have order.}}</li> | 50 <li>{{python-tuple-vs-list Use tuples for data that have structure, use lists for data that have order.}}</li> |
51 <li>{{python-builtins Don't override builtins except for <a href="https://docs .python.org/2/library/functions.html#non-essential-built-in-funcs">non-essential builtins</a> and <code><fix>file</fix></code> which is superfluos in modern cod e as well.}}</li> | 51 <li>{{python-builtins Don't override builtins except for <a href="https://docs .python.org/2/library/functions.html#non-essential-built-in-funcs">non-essential builtins</a> and <code><fix>file</fix></code> which is superfluos in modern cod e as well.}}</li> |
52 <li>{{python-map-filter Use list comprehensions or generator expressions inste ad calling <code><fix>map()</fix></code> or <code><fix>filter()</fix></code> wit h a lambda function.}}</li> | 52 <li>{{python-map-filter Use list comprehensions or generator expressions inste ad of calling <code><fix>map()</fix></code> or <code><fix>filter()</fix></code> with a lambda function.}}</li> |
Vasily Kuznetsov
2016/05/11 16:55:42
"instead of"? :)
Sebastian Noack
2016/05/11 17:07:44
Done.
| |
53 <li>{{python-regexp Use <a href="https://docs.python.org/2/library/re.html#re. search"><code><fix>re.search()</fix></code></a> instead <code><fix>re.match()</f ix></code> to avoid <a href="https://docs.python.org/2/library/re.html#search-vs -match">confusion</a> about implied beginning of the string but not the ending.} }</li> | 53 <li>{{python-regexp Use <a href="https://docs.python.org/2/library/re.html#re. search"><code><fix>re.search()</fix></code></a> instead of <code><fix>re.match() </fix></code> to avoid <a href="https://docs.python.org/2/library/re.html#search -vs-match">confusion</a> about implied beginning of the string but not the endin g.}}</li> |
Vasily Kuznetsov
2016/05/11 16:55:42
And here too, "instead of".
Sebastian Noack
2016/05/11 17:07:44
Done.
| |
54 <li>{{python-flake8 Run <a href="https://pypi.python.org/pypi/flake8">flake8</ a> with the <a href="https://hg.adblockplus.org/codingtools/file/tip/flake8-abp" >flake8-abp</a> and <a href="https://pypi.python.org/pypi/pep8-naming">pep8-nami ng</a> extensions and fix any warning.}}</li> | 54 <li>{{python-flake8 Run <a href="https://pypi.python.org/pypi/flake8">flake8</ a> with the <a href="https://hg.adblockplus.org/codingtools/file/tip/flake8-abp" >flake8-abp</a> and <a href="https://pypi.python.org/pypi/pep8-naming">pep8-nami ng</a> extensions and fix any warning.}}</li> |
55 <li>{{python-tests Write tests and have them run along flake8 using <a href="h ttps://pypi.python.org/pypi/tox">tox</a>.}}</li> | 55 <li>{{python-tests Write tests and have them run along flake8 using <a href="h ttps://pypi.python.org/pypi/tox">tox</a>.}}</li> |
56 </ul> | 56 </ul> |
57 | 57 |
58 <h2 id="java">{{s22 Java}}</h2> | 58 <h2 id="java">{{s22 Java}}</h2> |
59 <ul> | 59 <ul> |
60 <li>{{s23 Follow the Mozilla Coding Style's <a href="https://developer.mozilla .org/en-US/docs/Developer_Guide/Coding_Style#Java_practices">Java practices</a>. }}</li> | 60 <li>{{s23 Follow the Mozilla Coding Style's <a href="https://developer.mozilla .org/en-US/docs/Developer_Guide/Coding_Style#Java_practices">Java practices</a>. }}</li> |
61 <li>{{s24 Imports should be organised consistently per file, we don't use glob al rules.}}</li> | 61 <li>{{s24 Imports should be organised consistently per file, we don't use glob al rules.}}</li> |
62 </ul> | 62 </ul> |
63 | 63 |
(...skipping 10 matching lines...) Expand all Loading... | |
74 <ul> | 74 <ul> |
75 <li>{{objc-conventions Follow Apple's <a href="https://developer.apple.com/lib rary/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Conventions/Co nventions.html">conventions</a>}}.</li> | 75 <li>{{objc-conventions Follow Apple's <a href="https://developer.apple.com/lib rary/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Conventions/Co nventions.html">conventions</a>}}.</li> |
76 </ul> | 76 </ul> |
77 | 77 |
78 <h2 id="puppet">{{s31 Puppet}}</h2> | 78 <h2 id="puppet">{{s31 Puppet}}</h2> |
79 <ul> | 79 <ul> |
80 <li>{{s32 Follow the <a href="http://docs.puppetlabs.com/guides/style_guide.ht ml">Puppet Style Guide</a>.}}</li> | 80 <li>{{s32 Follow the <a href="http://docs.puppetlabs.com/guides/style_guide.ht ml">Puppet Style Guide</a>.}}</li> |
81 <li>{{s33 Opening braces don't go on their own line.}}</li> | 81 <li>{{s33 Opening braces don't go on their own line.}}</li> |
82 <li>{{s34 Arrows should not be aligned.}}</li> | 82 <li>{{s34 Arrows should not be aligned.}}</li> |
83 </ul> | 83 </ul> |
LEFT | RIGHT |