src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Naming.NamingStyleChecker.html

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

eric ide

mercurial