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

branch
eric7
changeset 8372
e0227a7c850e
child 8596
d64760b2da50
equal deleted inserted replaced
8371:d6062691d424 8372:e0227a7c850e
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.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>eric7.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 None
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>Yield:</dt>
189 <dd>
190 tuple giving line number, offset within line and error code
191 </dd>
192 </dl>
193 <dl>
194 <dt>Yield Type:</dt>
195 <dd>
196 tuple of (int, int, str)
197 </dd>
198 </dl>
199 <a NAME="NamingStyleChecker.__checkFunctionArgumentNames" ID="NamingStyleChecker.__checkFunctionArgumentNames"></a>
200 <h4>NamingStyleChecker.__checkFunctionArgumentNames</h4>
201 <b>__checkFunctionArgumentNames</b>(<i>node, parents</i>)
202
203 <p>
204 Private class to check the argument names of functions
205 (N803, N804, N805, N806).
206 </p>
207 <p>
208 The argument names of a function should be lowercase, with words
209 separated by underscores. A class method should have 'cls' as the
210 first argument. A method should have 'self' as the first argument.
211 </p>
212 <dl>
213
214 <dt><i>node</i></dt>
215 <dd>
216 AST note to check
217 </dd>
218 <dt><i>parents</i></dt>
219 <dd>
220 list of parent nodes
221 </dd>
222 </dl>
223 <dl>
224 <dt>Yield:</dt>
225 <dd>
226 tuple giving line number, offset within line and error code
227 </dd>
228 </dl>
229 <dl>
230 <dt>Yield Type:</dt>
231 <dd>
232 tuple of (int, int, str)
233 </dd>
234 </dl>
235 <a NAME="NamingStyleChecker.__checkFunctionName" ID="NamingStyleChecker.__checkFunctionName"></a>
236 <h4>NamingStyleChecker.__checkFunctionName</h4>
237 <b>__checkFunctionName</b>(<i>node, parents</i>)
238
239 <p>
240 Private class to check the given node for function name
241 conventions (N802).
242 </p>
243 <p>
244 Function names should be lowercase, with words separated by underscores
245 as necessary to improve readability. Functions <b>not</b> being
246 methods '__' in front and back are not allowed. Mixed case is allowed
247 only in contexts where that's already the prevailing style
248 (e.g. threading.py), to retain backwards compatibility.
249 </p>
250 <dl>
251
252 <dt><i>node</i></dt>
253 <dd>
254 AST note to check
255 </dd>
256 <dt><i>parents</i></dt>
257 <dd>
258 list of parent nodes
259 </dd>
260 </dl>
261 <dl>
262 <dt>Yield:</dt>
263 <dd>
264 tuple giving line number, offset within line and error code
265 </dd>
266 </dl>
267 <dl>
268 <dt>Yield Type:</dt>
269 <dd>
270 tuple of (int, int, str)
271 </dd>
272 </dl>
273 <a NAME="NamingStyleChecker.__checkImportAs" ID="NamingStyleChecker.__checkImportAs"></a>
274 <h4>NamingStyleChecker.__checkImportAs</h4>
275 <b>__checkImportAs</b>(<i>node, parents</i>)
276
277 <p>
278 Private method to check that imports don't change the
279 naming convention (N811, N812, N813, N814).
280 </p>
281 <dl>
282
283 <dt><i>node</i></dt>
284 <dd>
285 AST note to check
286 </dd>
287 <dt><i>parents</i></dt>
288 <dd>
289 list of parent nodes
290 </dd>
291 </dl>
292 <dl>
293 <dt>Yield:</dt>
294 <dd>
295 tuple giving line number, offset within line and error code
296 </dd>
297 </dl>
298 <dl>
299 <dt>Yield Type:</dt>
300 <dd>
301 tuple of (int, int, str)
302 </dd>
303 </dl>
304 <a NAME="NamingStyleChecker.__checkModule" ID="NamingStyleChecker.__checkModule"></a>
305 <h4>NamingStyleChecker.__checkModule</h4>
306 <b>__checkModule</b>(<i>node, parents</i>)
307
308 <p>
309 Private method to check module naming conventions (N807, N808).
310 </p>
311 <p>
312 Module and package names should be lowercase.
313 </p>
314 <dl>
315
316 <dt><i>node</i></dt>
317 <dd>
318 AST note to check
319 </dd>
320 <dt><i>parents</i></dt>
321 <dd>
322 list of parent nodes
323 </dd>
324 </dl>
325 <dl>
326 <dt>Yield:</dt>
327 <dd>
328 tuple giving line number, offset within line and error code
329 </dd>
330 </dl>
331 <dl>
332 <dt>Yield Type:</dt>
333 <dd>
334 tuple of (int, int, str)
335 </dd>
336 </dl>
337 <a NAME="NamingStyleChecker.__checkNameToBeAvoided" ID="NamingStyleChecker.__checkNameToBeAvoided"></a>
338 <h4>NamingStyleChecker.__checkNameToBeAvoided</h4>
339 <b>__checkNameToBeAvoided</b>(<i>node, parents</i>)
340
341 <p>
342 Private class to check the given node for a name to be avoided (N831).
343 </p>
344 <dl>
345
346 <dt><i>node</i></dt>
347 <dd>
348 AST note to check
349 </dd>
350 <dt><i>parents</i></dt>
351 <dd>
352 list of parent nodes
353 </dd>
354 </dl>
355 <dl>
356 <dt>Yield:</dt>
357 <dd>
358 tuple giving line number, offset within line and error code
359 </dd>
360 </dl>
361 <dl>
362 <dt>Yield Type:</dt>
363 <dd>
364 tuple of (int, int, str)
365 </dd>
366 </dl>
367 <a NAME="NamingStyleChecker.__checkVariablesInFunction" ID="NamingStyleChecker.__checkVariablesInFunction"></a>
368 <h4>NamingStyleChecker.__checkVariablesInFunction</h4>
369 <b>__checkVariablesInFunction</b>(<i>node, parents</i>)
370
371 <p>
372 Private method to check local variables in functions (N821).
373 </p>
374 <p>
375 Local variables in functions should be lowercase.
376 </p>
377 <dl>
378
379 <dt><i>node</i></dt>
380 <dd>
381 AST note to check
382 </dd>
383 <dt><i>parents</i></dt>
384 <dd>
385 list of parent nodes
386 </dd>
387 </dl>
388 <dl>
389 <dt>Yield:</dt>
390 <dd>
391 tuple giving line number, offset within line and error code
392 </dd>
393 </dl>
394 <dl>
395 <dt>Yield Type:</dt>
396 <dd>
397 tuple of (int, int, str)
398 </dd>
399 </dl>
400 <a NAME="NamingStyleChecker.__error" ID="NamingStyleChecker.__error"></a>
401 <h4>NamingStyleChecker.__error</h4>
402 <b>__error</b>(<i>node, code</i>)
403
404 <p>
405 Private method to build the error information.
406 </p>
407 <dl>
408
409 <dt><i>node</i></dt>
410 <dd>
411 AST node to report an error for
412 </dd>
413 <dt><i>code</i></dt>
414 <dd>
415 error code to report (string)
416 </dd>
417 </dl>
418 <dl>
419 <dt>Return:</dt>
420 <dd>
421 tuple giving line number, offset within line and error code
422 (integer, integer, string)
423 </dd>
424 </dl>
425 <a NAME="NamingStyleChecker.__findGlobalDefs" ID="NamingStyleChecker.__findGlobalDefs"></a>
426 <h4>NamingStyleChecker.__findGlobalDefs</h4>
427 <b>__findGlobalDefs</b>(<i>functionNode</i>)
428
429 <p>
430 Private method amend a node with global definitions information.
431 </p>
432 <dl>
433
434 <dt><i>functionNode</i></dt>
435 <dd>
436 AST tree node to amend
437 </dd>
438 </dl>
439 <a NAME="NamingStyleChecker.__getArgNames" ID="NamingStyleChecker.__getArgNames"></a>
440 <h4>NamingStyleChecker.__getArgNames</h4>
441 <b>__getArgNames</b>(<i>node</i>)
442
443 <p>
444 Private method to get the argument names of a function node.
445 </p>
446 <dl>
447
448 <dt><i>node</i></dt>
449 <dd>
450 AST node to extract arguments names from
451 </dd>
452 </dl>
453 <dl>
454 <dt>Return:</dt>
455 <dd>
456 list of argument names (list of string)
457 </dd>
458 </dl>
459 <a NAME="NamingStyleChecker.__isNameToBeAvoided" ID="NamingStyleChecker.__isNameToBeAvoided"></a>
460 <h4>NamingStyleChecker.__isNameToBeAvoided</h4>
461 <b>__isNameToBeAvoided</b>(<i>name</i>)
462
463 <p>
464 Private method to check, if the given name should be avoided.
465 </p>
466 <dl>
467
468 <dt><i>name</i></dt>
469 <dd>
470 name to be checked (string)
471 </dd>
472 </dl>
473 <dl>
474 <dt>Return:</dt>
475 <dd>
476 flag indicating to avoid it (boolen)
477 </dd>
478 </dl>
479 <a NAME="NamingStyleChecker.__tagClassFunctions" ID="NamingStyleChecker.__tagClassFunctions"></a>
480 <h4>NamingStyleChecker.__tagClassFunctions</h4>
481 <b>__tagClassFunctions</b>(<i>classNode</i>)
482
483 <p>
484 Private method to tag functions if they are methods, class methods or
485 static methods.
486 </p>
487 <dl>
488
489 <dt><i>classNode</i></dt>
490 <dd>
491 AST tree node to tag
492 </dd>
493 </dl>
494 <a NAME="NamingStyleChecker.__visitNode" ID="NamingStyleChecker.__visitNode"></a>
495 <h4>NamingStyleChecker.__visitNode</h4>
496 <b>__visitNode</b>(<i>node</i>)
497
498 <p>
499 Private method to inspect the given AST node.
500 </p>
501 <dl>
502
503 <dt><i>node</i></dt>
504 <dd>
505 AST tree node to inspect
506 </dd>
507 </dl>
508 <dl>
509 <dt>Yield:</dt>
510 <dd>
511 tuple giving line number, offset within line and error code
512 </dd>
513 </dl>
514 <dl>
515 <dt>Yield Type:</dt>
516 <dd>
517 tuple of (int, int, str)
518 </dd>
519 </dl>
520 <a NAME="NamingStyleChecker.__visitTree" ID="NamingStyleChecker.__visitTree"></a>
521 <h4>NamingStyleChecker.__visitTree</h4>
522 <b>__visitTree</b>(<i>node</i>)
523
524 <p>
525 Private method to scan the given AST tree.
526 </p>
527 <dl>
528
529 <dt><i>node</i></dt>
530 <dd>
531 AST tree node to scan
532 </dd>
533 </dl>
534 <dl>
535 <dt>Yield:</dt>
536 <dd>
537 tuple giving line number, offset within line and error code
538 </dd>
539 </dl>
540 <dl>
541 <dt>Yield Type:</dt>
542 <dd>
543 tuple of (int, int, str)
544 </dd>
545 </dl>
546 <a NAME="NamingStyleChecker.run" ID="NamingStyleChecker.run"></a>
547 <h4>NamingStyleChecker.run</h4>
548 <b>run</b>(<i></i>)
549
550 <p>
551 Public method run by the pycodestyle.py checker.
552 </p>
553 <dl>
554 <dt>Return:</dt>
555 <dd>
556 tuple giving line number, offset within line, code and
557 checker function
558 </dd>
559 </dl>
560 <div align="right"><a href="#top">Up</a></div>
561 <hr />
562 </body></html>

eric ide

mercurial