eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Naming.NamingStyleChecker.html

changeset 7784
3257703e10c5
child 7989
a21d673a8f99
equal deleted inserted replaced
7783:36f66ce496bd 7784:3257703e10c5
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Naming.NamingStyleChecker</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body>
22 <a NAME="top" ID="top"></a>
23 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Naming.NamingStyleChecker</h1>
24
25 <p>
26 Module implementing a checker for naming conventions.
27 </p>
28 <h3>Global Attributes</h3>
29
30 <table>
31 <tr><td>None</td></tr>
32 </table>
33 <h3>Classes</h3>
34
35 <table>
36
37 <tr>
38 <td><a href="#NamingStyleChecker">NamingStyleChecker</a></td>
39 <td>Class implementing a checker for naming conventions.</td>
40 </tr>
41 </table>
42 <h3>Functions</h3>
43
44 <table>
45 <tr><td>None</td></tr>
46 </table>
47 <hr />
48 <hr />
49 <a NAME="NamingStyleChecker" ID="NamingStyleChecker"></a>
50 <h2>NamingStyleChecker</h2>
51
52 <p>
53 Class implementing a checker for naming conventions.
54 </p>
55 <h3>Derived from</h3>
56 object
57 <h3>Class Attributes</h3>
58
59 <table>
60 <tr><td>CamelcaseRegexp</td></tr><tr><td>Codes</td></tr><tr><td>LowercaseRegex</td></tr><tr><td>MixedcaseRegexp</td></tr><tr><td>UppercaseRegexp</td></tr>
61 </table>
62 <h3>Class Methods</h3>
63
64 <table>
65 <tr><td>None</td></tr>
66 </table>
67 <h3>Methods</h3>
68
69 <table>
70
71 <tr>
72 <td><a href="#NamingStyleChecker.__init__">NamingStyleChecker</a></td>
73 <td>Constructor (according to 'extended' pycodestyle.py API)</td>
74 </tr>
75 <tr>
76 <td><a href="#NamingStyleChecker.__checkClassName">__checkClassName</a></td>
77 <td>Private class to check the given node for class name conventions (N801).</td>
78 </tr>
79 <tr>
80 <td><a href="#NamingStyleChecker.__checkFunctionArgumentNames">__checkFunctionArgumentNames</a></td>
81 <td>Private class to check the argument names of functions (N803, N804, N805, N806).</td>
82 </tr>
83 <tr>
84 <td><a href="#NamingStyleChecker.__checkFunctionName">__checkFunctionName</a></td>
85 <td>Private class to check the given node for function name conventions (N802).</td>
86 </tr>
87 <tr>
88 <td><a href="#NamingStyleChecker.__checkImportAs">__checkImportAs</a></td>
89 <td>Private method to check that imports don't change the naming convention (N811, N812, N813, N814).</td>
90 </tr>
91 <tr>
92 <td><a href="#NamingStyleChecker.__checkModule">__checkModule</a></td>
93 <td>Private method to check module naming conventions (N807, N808).</td>
94 </tr>
95 <tr>
96 <td><a href="#NamingStyleChecker.__checkNameToBeAvoided">__checkNameToBeAvoided</a></td>
97 <td>Private class to check the given node for a name to be avoided (N831).</td>
98 </tr>
99 <tr>
100 <td><a href="#NamingStyleChecker.__checkVariablesInFunction">__checkVariablesInFunction</a></td>
101 <td>Private method to check local variables in functions (N821).</td>
102 </tr>
103 <tr>
104 <td><a href="#NamingStyleChecker.__error">__error</a></td>
105 <td>Private method to build the error information.</td>
106 </tr>
107 <tr>
108 <td><a href="#NamingStyleChecker.__findGlobalDefs">__findGlobalDefs</a></td>
109 <td>Private method amend a node with global definitions information.</td>
110 </tr>
111 <tr>
112 <td><a href="#NamingStyleChecker.__getArgNames">__getArgNames</a></td>
113 <td>Private method to get the argument names of a function node.</td>
114 </tr>
115 <tr>
116 <td><a href="#NamingStyleChecker.__isNameToBeAvoided">__isNameToBeAvoided</a></td>
117 <td>Private method to check, if the given name should be avoided.</td>
118 </tr>
119 <tr>
120 <td><a href="#NamingStyleChecker.__tagClassFunctions">__tagClassFunctions</a></td>
121 <td>Private method to tag functions if they are methods, class methods or static methods.</td>
122 </tr>
123 <tr>
124 <td><a href="#NamingStyleChecker.__visitNode">__visitNode</a></td>
125 <td>Private method to inspect the given AST node.</td>
126 </tr>
127 <tr>
128 <td><a href="#NamingStyleChecker.__visitTree">__visitTree</a></td>
129 <td>Private method to scan the given AST tree.</td>
130 </tr>
131 <tr>
132 <td><a href="#NamingStyleChecker.run">run</a></td>
133 <td>Public method run by the pycodestyle.py checker.</td>
134 </tr>
135 </table>
136 <h3>Static Methods</h3>
137
138 <table>
139 <tr><td>None</td></tr>
140 </table>
141
142 <a NAME="NamingStyleChecker.__init__" ID="NamingStyleChecker.__init__"></a>
143 <h4>NamingStyleChecker (Constructor)</h4>
144 <b>NamingStyleChecker</b>(<i>tree, filename, options</i>)
145
146 <p>
147 Constructor (according to 'extended' pycodestyle.py API)
148 </p>
149 <dl>
150
151 <dt><i>tree</i></dt>
152 <dd>
153 AST tree of the source file
154 </dd>
155 <dt><i>filename</i></dt>
156 <dd>
157 name of the source file (string)
158 </dd>
159 <dt><i>options</i></dt>
160 <dd>
161 options as parsed by pycodestyle.StyleGuide
162 </dd>
163 </dl>
164 <a NAME="NamingStyleChecker.__checkClassName" ID="NamingStyleChecker.__checkClassName"></a>
165 <h4>NamingStyleChecker.__checkClassName</h4>
166 <b>__checkClassName</b>(<i>node, parents</i>)
167
168 <p>
169 Private class to check the given node for class name
170 conventions (N801).
171 </p>
172 <p>
173 Almost without exception, class names use the CapWords convention.
174 Classes for internal use have a leading underscore in addition.
175 </p>
176 <dl>
177
178 <dt><i>node</i></dt>
179 <dd>
180 AST note to check
181 </dd>
182 <dt><i>parents</i></dt>
183 <dd>
184 list of parent nodes
185 </dd>
186 </dl>
187 <dl>
188 <dt>Returns:</dt>
189 <dd>
190 tuple giving line number, offset within line and error code
191 (integer, integer, string)
192 </dd>
193 </dl>
194 <a NAME="NamingStyleChecker.__checkFunctionArgumentNames" ID="NamingStyleChecker.__checkFunctionArgumentNames"></a>
195 <h4>NamingStyleChecker.__checkFunctionArgumentNames</h4>
196 <b>__checkFunctionArgumentNames</b>(<i>node, parents</i>)
197
198 <p>
199 Private class to check the argument names of functions
200 (N803, N804, N805, N806).
201 </p>
202 <p>
203 The argument names of a function should be lowercase, with words
204 separated by underscores. A class method should have 'cls' as the
205 first argument. A method should have 'self' as the first argument.
206 </p>
207 <dl>
208
209 <dt><i>node</i></dt>
210 <dd>
211 AST note to check
212 </dd>
213 <dt><i>parents</i></dt>
214 <dd>
215 list of parent nodes
216 </dd>
217 </dl>
218 <dl>
219 <dt>Returns:</dt>
220 <dd>
221 tuple giving line number, offset within line and error code
222 (integer, integer, string)
223 </dd>
224 </dl>
225 <a NAME="NamingStyleChecker.__checkFunctionName" ID="NamingStyleChecker.__checkFunctionName"></a>
226 <h4>NamingStyleChecker.__checkFunctionName</h4>
227 <b>__checkFunctionName</b>(<i>node, parents</i>)
228
229 <p>
230 Private class to check the given node for function name
231 conventions (N802).
232 </p>
233 <p>
234 Function names should be lowercase, with words separated by underscores
235 as necessary to improve readability. Functions <b>not</b> being
236 methods '__' in front and back are not allowed. Mixed case is allowed
237 only in contexts where that's already the prevailing style
238 (e.g. threading.py), to retain backwards compatibility.
239 </p>
240 <dl>
241
242 <dt><i>node</i></dt>
243 <dd>
244 AST note to check
245 </dd>
246 <dt><i>parents</i></dt>
247 <dd>
248 list of parent nodes
249 </dd>
250 </dl>
251 <dl>
252 <dt>Returns:</dt>
253 <dd>
254 tuple giving line number, offset within line and error code
255 (integer, integer, string)
256 </dd>
257 </dl>
258 <a NAME="NamingStyleChecker.__checkImportAs" ID="NamingStyleChecker.__checkImportAs"></a>
259 <h4>NamingStyleChecker.__checkImportAs</h4>
260 <b>__checkImportAs</b>(<i>node, parents</i>)
261
262 <p>
263 Private method to check that imports don't change the
264 naming convention (N811, N812, N813, N814).
265 </p>
266 <dl>
267
268 <dt><i>node</i></dt>
269 <dd>
270 AST note to check
271 </dd>
272 <dt><i>parents</i></dt>
273 <dd>
274 list of parent nodes
275 </dd>
276 </dl>
277 <dl>
278 <dt>Returns:</dt>
279 <dd>
280 tuple giving line number, offset within line and error code
281 (integer, integer, string)
282 </dd>
283 </dl>
284 <a NAME="NamingStyleChecker.__checkModule" ID="NamingStyleChecker.__checkModule"></a>
285 <h4>NamingStyleChecker.__checkModule</h4>
286 <b>__checkModule</b>(<i>node, parents</i>)
287
288 <p>
289 Private method to check module naming conventions (N807, N808).
290 </p>
291 <p>
292 Module and package names should be lowercase.
293 </p>
294 <dl>
295
296 <dt><i>node</i></dt>
297 <dd>
298 AST note to check
299 </dd>
300 <dt><i>parents</i></dt>
301 <dd>
302 list of parent nodes
303 </dd>
304 </dl>
305 <dl>
306 <dt>Returns:</dt>
307 <dd>
308 tuple giving line number, offset within line and error code
309 (integer, integer, string)
310 </dd>
311 </dl>
312 <a NAME="NamingStyleChecker.__checkNameToBeAvoided" ID="NamingStyleChecker.__checkNameToBeAvoided"></a>
313 <h4>NamingStyleChecker.__checkNameToBeAvoided</h4>
314 <b>__checkNameToBeAvoided</b>(<i>node, parents</i>)
315
316 <p>
317 Private class to check the given node for a name to be avoided (N831).
318 </p>
319 <dl>
320
321 <dt><i>node</i></dt>
322 <dd>
323 AST note to check
324 </dd>
325 <dt><i>parents</i></dt>
326 <dd>
327 list of parent nodes
328 </dd>
329 </dl>
330 <dl>
331 <dt>Returns:</dt>
332 <dd>
333 tuple giving line number, offset within line and error code
334 (integer, integer, string)
335 </dd>
336 </dl>
337 <a NAME="NamingStyleChecker.__checkVariablesInFunction" ID="NamingStyleChecker.__checkVariablesInFunction"></a>
338 <h4>NamingStyleChecker.__checkVariablesInFunction</h4>
339 <b>__checkVariablesInFunction</b>(<i>node, parents</i>)
340
341 <p>
342 Private method to check local variables in functions (N821).
343 </p>
344 <p>
345 Local variables in functions should be lowercase.
346 </p>
347 <dl>
348
349 <dt><i>node</i></dt>
350 <dd>
351 AST note to check
352 </dd>
353 <dt><i>parents</i></dt>
354 <dd>
355 list of parent nodes
356 </dd>
357 </dl>
358 <dl>
359 <dt>Returns:</dt>
360 <dd>
361 tuple giving line number, offset within line and error code
362 (integer, integer, string)
363 </dd>
364 </dl>
365 <a NAME="NamingStyleChecker.__error" ID="NamingStyleChecker.__error"></a>
366 <h4>NamingStyleChecker.__error</h4>
367 <b>__error</b>(<i>node, code</i>)
368
369 <p>
370 Private method to build the error information.
371 </p>
372 <dl>
373
374 <dt><i>node</i></dt>
375 <dd>
376 AST node to report an error for
377 </dd>
378 <dt><i>code</i></dt>
379 <dd>
380 error code to report (string)
381 </dd>
382 </dl>
383 <dl>
384 <dt>Returns:</dt>
385 <dd>
386 tuple giving line number, offset within line and error code
387 (integer, integer, string)
388 </dd>
389 </dl>
390 <a NAME="NamingStyleChecker.__findGlobalDefs" ID="NamingStyleChecker.__findGlobalDefs"></a>
391 <h4>NamingStyleChecker.__findGlobalDefs</h4>
392 <b>__findGlobalDefs</b>(<i>functionNode</i>)
393
394 <p>
395 Private method amend a node with global definitions information.
396 </p>
397 <dl>
398
399 <dt><i>functionNode</i></dt>
400 <dd>
401 AST tree node to amend
402 </dd>
403 </dl>
404 <a NAME="NamingStyleChecker.__getArgNames" ID="NamingStyleChecker.__getArgNames"></a>
405 <h4>NamingStyleChecker.__getArgNames</h4>
406 <b>__getArgNames</b>(<i>node</i>)
407
408 <p>
409 Private method to get the argument names of a function node.
410 </p>
411 <dl>
412
413 <dt><i>node</i></dt>
414 <dd>
415 AST node to extract arguments names from
416 </dd>
417 </dl>
418 <dl>
419 <dt>Returns:</dt>
420 <dd>
421 list of argument names (list of string)
422 </dd>
423 </dl>
424 <a NAME="NamingStyleChecker.__isNameToBeAvoided" ID="NamingStyleChecker.__isNameToBeAvoided"></a>
425 <h4>NamingStyleChecker.__isNameToBeAvoided</h4>
426 <b>__isNameToBeAvoided</b>(<i>name</i>)
427
428 <p>
429 Private method to check, if the given name should be avoided.
430 </p>
431 <dl>
432
433 <dt><i>name</i></dt>
434 <dd>
435 name to be checked (string)
436 </dd>
437 </dl>
438 <dl>
439 <dt>Returns:</dt>
440 <dd>
441 flag indicating to avoid it (boolen)
442 </dd>
443 </dl>
444 <a NAME="NamingStyleChecker.__tagClassFunctions" ID="NamingStyleChecker.__tagClassFunctions"></a>
445 <h4>NamingStyleChecker.__tagClassFunctions</h4>
446 <b>__tagClassFunctions</b>(<i>classNode</i>)
447
448 <p>
449 Private method to tag functions if they are methods, class methods or
450 static methods.
451 </p>
452 <dl>
453
454 <dt><i>classNode</i></dt>
455 <dd>
456 AST tree node to tag
457 </dd>
458 </dl>
459 <a NAME="NamingStyleChecker.__visitNode" ID="NamingStyleChecker.__visitNode"></a>
460 <h4>NamingStyleChecker.__visitNode</h4>
461 <b>__visitNode</b>(<i>node</i>)
462
463 <p>
464 Private method to inspect the given AST node.
465 </p>
466 <dl>
467
468 <dt><i>node</i></dt>
469 <dd>
470 AST tree node to inspect
471 </dd>
472 </dl>
473 <dl>
474 <dt>Returns:</dt>
475 <dd>
476 tuple giving line number, offset within line, code and
477 checker function
478 </dd>
479 </dl>
480 <a NAME="NamingStyleChecker.__visitTree" ID="NamingStyleChecker.__visitTree"></a>
481 <h4>NamingStyleChecker.__visitTree</h4>
482 <b>__visitTree</b>(<i>node</i>)
483
484 <p>
485 Private method to scan the given AST tree.
486 </p>
487 <dl>
488
489 <dt><i>node</i></dt>
490 <dd>
491 AST tree node to scan
492 </dd>
493 </dl>
494 <dl>
495 <dt>Returns:</dt>
496 <dd>
497 tuple giving line number, offset within line, code and
498 checker function
499 </dd>
500 </dl>
501 <a NAME="NamingStyleChecker.run" ID="NamingStyleChecker.run"></a>
502 <h4>NamingStyleChecker.run</h4>
503 <b>run</b>(<i></i>)
504
505 <p>
506 Public method run by the pycodestyle.py checker.
507 </p>
508 <dl>
509 <dt>Returns:</dt>
510 <dd>
511 tuple giving line number, offset within line, code and
512 checker function
513 </dd>
514 </dl>
515 <div align="right"><a href="#top">Up</a></div>
516 <hr />
517 </body></html>

eric ide

mercurial