Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: pages/coding-style.html

Issue 29572574: Noissue - Added usage of flake8-docstrings to our coding practices (Closed)
Patch Set: Turned list of flake8 extensions into a bullet list Created Oct. 10, 2017, 5:55 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 <ul> 58 <ul>
59 <li>{{python-general Follow <a href="https://www.python.org/dev/peps/pep-0008/ "><fix>PEP-8</fix></a> and the recommendations in the offical <fix>Python</fix> documentation.}}</li> 59 <li>{{python-general Follow <a href="https://www.python.org/dev/peps/pep-0008/ "><fix>PEP-8</fix></a> and the recommendations in the offical <fix>Python</fix> documentation.}}</li>
60 <li>{{python-version Make the code compatible with both <fix>Python 2.7</fix> and <fix>Python 3.5+</fix> (see <a href="https://docs.python.org/dev/howto/pypor ting.html">this guide</a>). Use <a href="https://docs.python.org/2/library/__fut ure__.html"><fix>__future__</fix> imports</a> to address syntactic differences b ut avoid <a href="https://pythonhosted.org/six/"><fix>six</fix></a>, <a href="ht tp://python-future.org/compatible_idioms.html"><fix>python-future</fix></a>, etc . to not introduce additional dependencies.}}</li> 60 <li>{{python-version Make the code compatible with both <fix>Python 2.7</fix> and <fix>Python 3.5+</fix> (see <a href="https://docs.python.org/dev/howto/pypor ting.html">this guide</a>). Use <a href="https://docs.python.org/2/library/__fut ure__.html"><fix>__future__</fix> imports</a> to address syntactic differences b ut avoid <a href="https://pythonhosted.org/six/"><fix>six</fix></a>, <a href="ht tp://python-future.org/compatible_idioms.html"><fix>python-future</fix></a>, etc . to not introduce additional dependencies.}}</li>
61 <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/3/library/functions.html#ascii"><code><fix>asc ii()</fix></code></a>, i.e. use single quotes except to avoid escaping of embedd ed quotes and use <code><fix>\u</fix></code> escapes for non-ascii characters bu t don't prefix strings with <code><fix>u</fix></code>. For docstrings, however, follow <a href="https://www.python.org/dev/peps/pep-0257/">PEP-257</a>.}}</li> 61 <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/3/library/functions.html#ascii"><code><fix>asc ii()</fix></code></a>, i.e. use single quotes except to avoid escaping of embedd ed quotes and use <code><fix>\u</fix></code> escapes for non-ascii characters bu t don't prefix strings with <code><fix>u</fix></code>. For docstrings, however, follow <a href="https://www.python.org/dev/peps/pep-0257/">PEP-257</a>.}}</li>
62 <li>{{python-prefix In modules, prefix private functions and variables with a single underscore.}}</li> 62 <li>{{python-prefix In modules, prefix private functions and variables with a single underscore.}}</li>
63 <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> 63 <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>
64 <li>{{python-tuple-vs-list Use tuples for data that have structure, use lists for data that have order.}}</li> 64 <li>{{python-tuple-vs-list Use tuples for data that have structure, use lists for data that have order.}}</li>
65 <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> 65 <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>
66 <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> 66 <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>
67 <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> 67 <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>
68 <li>{{python-flake8 Run <a href="https://pypi.python.org/pypi/flake8"><fix>fla ke8</fix></a> with the <a href="https://hg.adblockplus.org/codingtools/file/tip/ flake8-eyeo"><fix>flake8-eyeo</fix></a> and <a href="https://pypi.python.org/pyp i/pep8-naming"><fix>pep8-naming</fix></a> extensions and fix any warning.}}</li> 68 <li>
69 {{python-flake8 Run <a href="https://pypi.python.org/pypi/flake8"><fix>flake 8</fix></a> with following extensions and fix all reported errors:}}
70 <ul>
71 <li><a href="https://hg.adblockplus.org/codingtools/file/tip/flake8-eyeo"> flake8-eyeo</a></li>
72 <li><a href="https://pypi.python.org/pypi/flake8-docstrings">flake8-docstr ings</a> ({{python-flake8-docstring-exception with <code><fix>D1</fix></code> ig nored}})</li>
73 <li><a href="https://pypi.python.org/pypi/pep8-naming">pep8-naming</a></li >
74 </ul>
75 </li>
69 <li>{{python-tests Write tests and have them run along <fix>flake8</fix> using <a href="https://pypi.python.org/pypi/tox"><fix>tox</fix></a>.}}</li> 76 <li>{{python-tests Write tests and have them run along <fix>flake8</fix> using <a href="https://pypi.python.org/pypi/tox"><fix>tox</fix></a>.}}</li>
70 </ul> 77 </ul>
71 78
72 <h2 id="java">{{s22 Java}}</h2> 79 <h2 id="java">{{s22 Java}}</h2>
73 <ul> 80 <ul>
74 <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> 81 <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>
75 <li>{{s24 Imports should be organised consistently per file, we don't use glob al rules.}}</li> 82 <li>{{s24 Imports should be organised consistently per file, we don't use glob al rules.}}</li>
76 </ul> 83 </ul>
77 84
78 <h2 id="cpp">{{s25 C++}}</h2> 85 <h2 id="cpp">{{s25 C++}}</h2>
79 <ul> 86 <ul>
80 <li>{{s26 Follow the Mozilla Coding Style's <a href="https://developer.mozilla .org/en-US/docs/Developer_Guide/Coding_Style#C.2FC.2B.2B_practices">C++ practice s</a>.}}</li> 87 <li>{{s26 Follow the Mozilla Coding Style's <a href="https://developer.mozilla .org/en-US/docs/Developer_Guide/Coding_Style#C.2FC.2B.2B_practices">C++ practice s</a>.}}</li>
81 <li>{{s27 Indent namespace bodies.}}</li> 88 <li>{{s27 Indent namespace bodies.}}</li>
82 <li>{{s28 Avoid manual memory management: Use references and values when possi ble, smart pointers when necessary, raw pointers only for weak references.}}</li > 89 <li>{{s28 Avoid manual memory management: Use references and values when possi ble, smart pointers when necessary, raw pointers only for weak references.}}</li >
83 <li>{{s29 Don't use C-style casts unless its exact semantics are required.}}</ li> 90 <li>{{s29 Don't use C-style casts unless its exact semantics are required.}}</ li>
84 <li>{{s30 We tend to use anonymous namespaces instead of static.}}</li> 91 <li>{{s30 We tend to use anonymous namespaces instead of static.}}</li>
85 </ul> 92 </ul>
86 93
87 <h2 id="objc">{{objective-c Objective-C}}</h2> 94 <h2 id="objc">{{objective-c Objective-C}}</h2>
88 <ul> 95 <ul>
89 <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> 96 <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>
90 </ul> 97 </ul>
91 98
92 <h2 id="puppet">{{s31 Puppet}}</h2> 99 <h2 id="puppet">{{s31 Puppet}}</h2>
93 <ul> 100 <ul>
94 <li>{{s32 Follow the <a href="http://docs.puppetlabs.com/guides/style_guide.ht ml">Puppet Style Guide</a>.}}</li> 101 <li>{{s32 Follow the <a href="http://docs.puppetlabs.com/guides/style_guide.ht ml">Puppet Style Guide</a>.}}</li>
95 <li>{{s33 Opening braces don't go on their own line.}}</li> 102 <li>{{s33 Opening braces don't go on their own line.}}</li>
96 <li>{{s34 Arrows should not be aligned.}}</li> 103 <li>{{s34 Arrows should not be aligned.}}</li>
97 </ul> 104 </ul>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld