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

branch
eric7
changeset 9271
f655c20ff500
parent 9209
b99e7fd55fd3
child 10070
9f5758c0fec1
equal deleted inserted replaced
9270:2f60384fe01f 9271:f655c20ff500
41 <h3>Derived from</h3> 41 <h3>Derived from</h3>
42 None 42 None
43 <h3>Class Attributes</h3> 43 <h3>Class Attributes</h3>
44 44
45 <table> 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> 46 <tr><td>Codes</td></tr>
47 </table> 47 </table>
48 <h3>Class Methods</h3> 48 <h3>Class Methods</h3>
49 49
50 <table> 50 <table>
51 <tr><td>None</td></tr> 51 <tr><td>None</td></tr>
58 <td><a href="#NamingStyleChecker.__init__">NamingStyleChecker</a></td> 58 <td><a href="#NamingStyleChecker.__init__">NamingStyleChecker</a></td>
59 <td>Constructor (according to 'extended' pycodestyle.py API)</td> 59 <td>Constructor (according to 'extended' pycodestyle.py API)</td>
60 </tr> 60 </tr>
61 <tr> 61 <tr>
62 <td><a href="#NamingStyleChecker.__checkClassName">__checkClassName</a></td> 62 <td><a href="#NamingStyleChecker.__checkClassName">__checkClassName</a></td>
63 <td>Private class to check the given node for class name conventions (N801).</td> 63 <td>Private class to check the given node for class name conventions (N801, N818).</td>
64 </tr> 64 </tr>
65 <tr> 65 <tr>
66 <td><a href="#NamingStyleChecker.__checkFunctionArgumentNames">__checkFunctionArgumentNames</a></td> 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> 67 <td>Private class to check the argument names of functions (N803, N804, N805, N806).</td>
68 </tr> 68 </tr>
69 <tr> 69 <tr>
70 <td><a href="#NamingStyleChecker.__checkFunctionName">__checkFunctionName</a></td> 70 <td><a href="#NamingStyleChecker.__checkFunctionName">__checkFunctionName</a></td>
71 <td>Private class to check the given node for function name conventions (N802).</td> 71 <td>Private class to check the given node for function name conventions (N802, N809).</td>
72 </tr> 72 </tr>
73 <tr> 73 <tr>
74 <td><a href="#NamingStyleChecker.__checkImportAs">__checkImportAs</a></td> 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> 75 <td>Private method to check that imports don't change the naming convention (N811, N812, N813, N814, N815).</td>
76 </tr> 76 </tr>
77 <tr> 77 <tr>
78 <td><a href="#NamingStyleChecker.__checkModule">__checkModule</a></td> 78 <td><a href="#NamingStyleChecker.__checkModule">__checkModule</a></td>
79 <td>Private method to check module naming conventions (N807, N808).</td> 79 <td>Private method to check module naming conventions (N807, N808).</td>
80 </tr> 80 </tr>
81 <tr> 81 <tr>
82 <td><a href="#NamingStyleChecker.__checkNameToBeAvoided">__checkNameToBeAvoided</a></td> 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> 83 <td>Private class to check the given node for a name to be avoided (N831).</td>
84 </tr> 84 </tr>
85 <tr> 85 <tr>
86 <td><a href="#NamingStyleChecker.__checkVariablesInFunction">__checkVariablesInFunction</a></td> 86 <td><a href="#NamingStyleChecker.__checkVariableNames">__checkVariableNames</a></td>
87 <td>Private method to check local variables in functions (N821).</td> 87 <td>Private method to check variable names in function, class and global scope (N821, N822, N823).</td>
88 </tr>
89 <tr>
90 <td><a href="#NamingStyleChecker.__classVariableCheck">__classVariableCheck</a></td>
91 <td>Private method to determine the error code for a variable in class scope.</td>
88 </tr> 92 </tr>
89 <tr> 93 <tr>
90 <td><a href="#NamingStyleChecker.__error">__error</a></td> 94 <td><a href="#NamingStyleChecker.__error">__error</a></td>
91 <td>Private method to build the error information.</td> 95 <td>Private method to build the error information.</td>
92 </tr> 96 </tr>
93 <tr> 97 <tr>
98 <td><a href="#NamingStyleChecker.__extractNames">__extractNames</a></td>
99 <td>Private method to extract the names from the target node.</td>
100 </tr>
101 <tr>
94 <td><a href="#NamingStyleChecker.__findGlobalDefs">__findGlobalDefs</a></td> 102 <td><a href="#NamingStyleChecker.__findGlobalDefs">__findGlobalDefs</a></td>
95 <td>Private method amend a node with global definitions information.</td> 103 <td>Private method amend a node with global definitions information.</td>
96 </tr> 104 </tr>
97 <tr> 105 <tr>
106 <td><a href="#NamingStyleChecker.__findVariableNameErrors">__findVariableNameErrors</a></td>
107 <td>Private method to check, if there is a variable name error.</td>
108 </tr>
109 <tr>
110 <td><a href="#NamingStyleChecker.__functionVariableCheck">__functionVariableCheck</a></td>
111 <td>Private method to determine the error code for a variable in class scope.</td>
112 </tr>
113 <tr>
98 <td><a href="#NamingStyleChecker.__getArgNames">__getArgNames</a></td> 114 <td><a href="#NamingStyleChecker.__getArgNames">__getArgNames</a></td>
99 <td>Private method to get the argument names of a function node.</td> 115 <td>Private method to get the argument names of a function node.</td>
100 </tr> 116 </tr>
101 <tr> 117 <tr>
118 <td><a href="#NamingStyleChecker.__getClassdef">__getClassdef</a></td>
119 <td>Private method to extract the class definition.</td>
120 </tr>
121 <tr>
122 <td><a href="#NamingStyleChecker.__globalVariableCheck">__globalVariableCheck</a></td>
123 <td>Private method to determine the error code for a variable in global scope.</td>
124 </tr>
125 <tr>
126 <td><a href="#NamingStyleChecker.__isMixedCase">__isMixedCase</a></td>
127 <td>Private method to check, if the given name is mixed case.</td>
128 </tr>
129 <tr>
102 <td><a href="#NamingStyleChecker.__isNameToBeAvoided">__isNameToBeAvoided</a></td> 130 <td><a href="#NamingStyleChecker.__isNameToBeAvoided">__isNameToBeAvoided</a></td>
103 <td>Private method to check, if the given name should be avoided.</td> 131 <td>Private method to check, if the given name should be avoided.</td>
132 </tr>
133 <tr>
134 <td><a href="#NamingStyleChecker.__isNamedTupel">__isNamedTupel</a></td>
135 <td>Private method to check, if a node is a named tuple.</td>
136 </tr>
137 <tr>
138 <td><a href="#NamingStyleChecker.__superClassNames">__superClassNames</a></td>
139 <td>Private method to extract the names of all super classes.</td>
104 </tr> 140 </tr>
105 <tr> 141 <tr>
106 <td><a href="#NamingStyleChecker.__tagClassFunctions">__tagClassFunctions</a></td> 142 <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> 143 <td>Private method to tag functions if they are methods, class methods or static methods.</td>
108 </tr> 144 </tr>
151 <h4>NamingStyleChecker.__checkClassName</h4> 187 <h4>NamingStyleChecker.__checkClassName</h4>
152 <b>__checkClassName</b>(<i>node, parents</i>) 188 <b>__checkClassName</b>(<i>node, parents</i>)
153 189
154 <p> 190 <p>
155 Private class to check the given node for class name 191 Private class to check the given node for class name
156 conventions (N801). 192 conventions (N801, N818).
157 </p> 193 </p>
158 <p> 194 <p>
159 Almost without exception, class names use the CapWords convention. 195 Almost without exception, class names use the CapWords convention.
160 Classes for internal use have a leading underscore in addition. 196 Classes for internal use have a leading underscore in addition.
161 </p> 197 </p>
222 <h4>NamingStyleChecker.__checkFunctionName</h4> 258 <h4>NamingStyleChecker.__checkFunctionName</h4>
223 <b>__checkFunctionName</b>(<i>node, parents</i>) 259 <b>__checkFunctionName</b>(<i>node, parents</i>)
224 260
225 <p> 261 <p>
226 Private class to check the given node for function name 262 Private class to check the given node for function name
227 conventions (N802). 263 conventions (N802, N809).
228 </p> 264 </p>
229 <p> 265 <p>
230 Function names should be lowercase, with words separated by underscores 266 Function names should be lowercase, with words separated by underscores
231 as necessary to improve readability. Functions <b>not</b> being 267 as necessary to improve readability. Functions <b>not</b> being
232 methods '__' in front and back are not allowed. Mixed case is allowed 268 methods '__' in front and back are not allowed. Mixed case is allowed
260 <h4>NamingStyleChecker.__checkImportAs</h4> 296 <h4>NamingStyleChecker.__checkImportAs</h4>
261 <b>__checkImportAs</b>(<i>node, parents</i>) 297 <b>__checkImportAs</b>(<i>node, parents</i>)
262 298
263 <p> 299 <p>
264 Private method to check that imports don't change the 300 Private method to check that imports don't change the
265 naming convention (N811, N812, N813, N814). 301 naming convention (N811, N812, N813, N814, N815).
266 </p> 302 </p>
267 <dl> 303 <dl>
268 304
269 <dt><i>node</i></dt> 305 <dt><i>node</i></dt>
270 <dd> 306 <dd>
348 <dt>Yield Type:</dt> 384 <dt>Yield Type:</dt>
349 <dd> 385 <dd>
350 tuple of (int, int, str) 386 tuple of (int, int, str)
351 </dd> 387 </dd>
352 </dl> 388 </dl>
353 <a NAME="NamingStyleChecker.__checkVariablesInFunction" ID="NamingStyleChecker.__checkVariablesInFunction"></a> 389 <a NAME="NamingStyleChecker.__checkVariableNames" ID="NamingStyleChecker.__checkVariableNames"></a>
354 <h4>NamingStyleChecker.__checkVariablesInFunction</h4> 390 <h4>NamingStyleChecker.__checkVariableNames</h4>
355 <b>__checkVariablesInFunction</b>(<i>node, parents</i>) 391 <b>__checkVariableNames</b>(<i>node, parents</i>)
356 392
357 <p> 393 <p>
358 Private method to check local variables in functions (N821). 394 Private method to check variable names in function, class and global scope
395 (N821, N822, N823).
359 </p> 396 </p>
360 <p> 397 <p>
361 Local variables in functions should be lowercase. 398 Local variables in functions should be lowercase.
362 </p> 399 </p>
363 <dl> 400 <dl>
379 </dl> 416 </dl>
380 <dl> 417 <dl>
381 <dt>Yield Type:</dt> 418 <dt>Yield Type:</dt>
382 <dd> 419 <dd>
383 tuple of (int, int, str) 420 tuple of (int, int, str)
421 </dd>
422 </dl>
423 <a NAME="NamingStyleChecker.__classVariableCheck" ID="NamingStyleChecker.__classVariableCheck"></a>
424 <h4>NamingStyleChecker.__classVariableCheck</h4>
425 <b>__classVariableCheck</b>(<i>name</i>)
426
427 <p>
428 Private method to determine the error code for a variable in class scope.
429 </p>
430 <dl>
431
432 <dt><i>name</i> (str)</dt>
433 <dd>
434 variable name to be checked
435 </dd>
436 </dl>
437 <dl>
438 <dt>Return:</dt>
439 <dd>
440 error code or None
441 </dd>
442 </dl>
443 <dl>
444 <dt>Return Type:</dt>
445 <dd>
446 str or None
384 </dd> 447 </dd>
385 </dl> 448 </dl>
386 <a NAME="NamingStyleChecker.__error" ID="NamingStyleChecker.__error"></a> 449 <a NAME="NamingStyleChecker.__error" ID="NamingStyleChecker.__error"></a>
387 <h4>NamingStyleChecker.__error</h4> 450 <h4>NamingStyleChecker.__error</h4>
388 <b>__error</b>(<i>node, code</i>) 451 <b>__error</b>(<i>node, code</i>)
406 <dd> 469 <dd>
407 tuple giving line number, offset within line and error code 470 tuple giving line number, offset within line and error code
408 (integer, integer, string) 471 (integer, integer, string)
409 </dd> 472 </dd>
410 </dl> 473 </dl>
474 <a NAME="NamingStyleChecker.__extractNames" ID="NamingStyleChecker.__extractNames"></a>
475 <h4>NamingStyleChecker.__extractNames</h4>
476 <b>__extractNames</b>(<i>assignmentTarget</i>)
477
478 <p>
479 Private method to extract the names from the target node.
480 </p>
481 <dl>
482
483 <dt><i>assignmentTarget</i> (ast.Name, ast.Tuple, ast.List or ast.ExceptHandler)</dt>
484 <dd>
485 target node of the assignment
486 </dd>
487 </dl>
488 <dl>
489 <dt>Yield:</dt>
490 <dd>
491 name of the variable
492 </dd>
493 </dl>
494 <dl>
495 <dt>Yield Type:</dt>
496 <dd>
497 str
498 </dd>
499 </dl>
411 <a NAME="NamingStyleChecker.__findGlobalDefs" ID="NamingStyleChecker.__findGlobalDefs"></a> 500 <a NAME="NamingStyleChecker.__findGlobalDefs" ID="NamingStyleChecker.__findGlobalDefs"></a>
412 <h4>NamingStyleChecker.__findGlobalDefs</h4> 501 <h4>NamingStyleChecker.__findGlobalDefs</h4>
413 <b>__findGlobalDefs</b>(<i>functionNode</i>) 502 <b>__findGlobalDefs</b>(<i>functionNode</i>)
414 503
415 <p> 504 <p>
420 <dt><i>functionNode</i></dt> 509 <dt><i>functionNode</i></dt>
421 <dd> 510 <dd>
422 AST tree node to amend 511 AST tree node to amend
423 </dd> 512 </dd>
424 </dl> 513 </dl>
514 <a NAME="NamingStyleChecker.__findVariableNameErrors" ID="NamingStyleChecker.__findVariableNameErrors"></a>
515 <h4>NamingStyleChecker.__findVariableNameErrors</h4>
516 <b>__findVariableNameErrors</b>(<i>assignmentTarget, parents</i>)
517
518 <p>
519 Private method to check, if there is a variable name error.
520 </p>
521 <dl>
522
523 <dt><i>assignmentTarget</i> (ast.Name, ast.Tuple, ast.List or ast.ExceptHandler)</dt>
524 <dd>
525 target node of the assignment
526 </dd>
527 <dt><i>parents</i> (ast.AST)</dt>
528 <dd>
529 list of parent nodes
530 </dd>
531 </dl>
532 <dl>
533 <dt>Yield:</dt>
534 <dd>
535 tuple giving line number, offset within line and error code
536 </dd>
537 </dl>
538 <dl>
539 <dt>Yield Type:</dt>
540 <dd>
541 tuple of (int, int, str)
542 </dd>
543 </dl>
544 <a NAME="NamingStyleChecker.__functionVariableCheck" ID="NamingStyleChecker.__functionVariableCheck"></a>
545 <h4>NamingStyleChecker.__functionVariableCheck</h4>
546 <b>__functionVariableCheck</b>(<i>func, varName</i>)
547
548 <p>
549 Private method to determine the error code for a variable in class scope.
550 </p>
551 <dl>
552
553 <dt><i>func</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt>
554 <dd>
555 reference to the function definition node
556 </dd>
557 <dt><i>varName</i> (str)</dt>
558 <dd>
559 variable name to be checked
560 </dd>
561 </dl>
562 <dl>
563 <dt>Return:</dt>
564 <dd>
565 error code or None
566 </dd>
567 </dl>
568 <dl>
569 <dt>Return Type:</dt>
570 <dd>
571 str or None
572 </dd>
573 </dl>
425 <a NAME="NamingStyleChecker.__getArgNames" ID="NamingStyleChecker.__getArgNames"></a> 574 <a NAME="NamingStyleChecker.__getArgNames" ID="NamingStyleChecker.__getArgNames"></a>
426 <h4>NamingStyleChecker.__getArgNames</h4> 575 <h4>NamingStyleChecker.__getArgNames</h4>
427 <b>__getArgNames</b>(<i>node</i>) 576 <b>__getArgNames</b>(<i>node</i>)
428 577
429 <p> 578 <p>
440 <dt>Return:</dt> 589 <dt>Return:</dt>
441 <dd> 590 <dd>
442 list of argument names (list of string) 591 list of argument names (list of string)
443 </dd> 592 </dd>
444 </dl> 593 </dl>
594 <a NAME="NamingStyleChecker.__getClassdef" ID="NamingStyleChecker.__getClassdef"></a>
595 <h4>NamingStyleChecker.__getClassdef</h4>
596 <b>__getClassdef</b>(<i>name, parents</i>)
597
598 <p>
599 Private method to extract the class definition.
600 </p>
601 <dl>
602
603 <dt><i>name</i> (str)</dt>
604 <dd>
605 name of the class
606 </dd>
607 <dt><i>parents</i> (ast.AST)</dt>
608 <dd>
609 list of parent nodes
610 </dd>
611 </dl>
612 <dl>
613 <dt>Return:</dt>
614 <dd>
615 node containing the class definition
616 </dd>
617 </dl>
618 <dl>
619 <dt>Return Type:</dt>
620 <dd>
621 ast.ClassDef
622 </dd>
623 </dl>
624 <a NAME="NamingStyleChecker.__globalVariableCheck" ID="NamingStyleChecker.__globalVariableCheck"></a>
625 <h4>NamingStyleChecker.__globalVariableCheck</h4>
626 <b>__globalVariableCheck</b>(<i>name</i>)
627
628 <p>
629 Private method to determine the error code for a variable in global scope.
630 </p>
631 <dl>
632
633 <dt><i>name</i> (str)</dt>
634 <dd>
635 variable name to be checked
636 </dd>
637 </dl>
638 <dl>
639 <dt>Return:</dt>
640 <dd>
641 error code or None
642 </dd>
643 </dl>
644 <dl>
645 <dt>Return Type:</dt>
646 <dd>
647 str or None
648 </dd>
649 </dl>
650 <a NAME="NamingStyleChecker.__isMixedCase" ID="NamingStyleChecker.__isMixedCase"></a>
651 <h4>NamingStyleChecker.__isMixedCase</h4>
652 <b>__isMixedCase</b>(<i>name</i>)
653
654 <p>
655 Private method to check, if the given name is mixed case.
656 </p>
657 <dl>
658
659 <dt><i>name</i> (str)</dt>
660 <dd>
661 variable name to be checked
662 </dd>
663 </dl>
664 <dl>
665 <dt>Return:</dt>
666 <dd>
667 flag indicating mixed case
668 </dd>
669 </dl>
670 <dl>
671 <dt>Return Type:</dt>
672 <dd>
673 bool
674 </dd>
675 </dl>
445 <a NAME="NamingStyleChecker.__isNameToBeAvoided" ID="NamingStyleChecker.__isNameToBeAvoided"></a> 676 <a NAME="NamingStyleChecker.__isNameToBeAvoided" ID="NamingStyleChecker.__isNameToBeAvoided"></a>
446 <h4>NamingStyleChecker.__isNameToBeAvoided</h4> 677 <h4>NamingStyleChecker.__isNameToBeAvoided</h4>
447 <b>__isNameToBeAvoided</b>(<i>name</i>) 678 <b>__isNameToBeAvoided</b>(<i>name</i>)
448 679
449 <p> 680 <p>
460 <dt>Return:</dt> 691 <dt>Return:</dt>
461 <dd> 692 <dd>
462 flag indicating to avoid it (boolen) 693 flag indicating to avoid it (boolen)
463 </dd> 694 </dd>
464 </dl> 695 </dl>
696 <a NAME="NamingStyleChecker.__isNamedTupel" ID="NamingStyleChecker.__isNamedTupel"></a>
697 <h4>NamingStyleChecker.__isNamedTupel</h4>
698 <b>__isNamedTupel</b>(<i>nodeValue</i>)
699
700 <p>
701 Private method to check, if a node is a named tuple.
702 </p>
703 <dl>
704
705 <dt><i>nodeValue</i> (ast.AST)</dt>
706 <dd>
707 node to be checked
708 </dd>
709 </dl>
710 <dl>
711 <dt>Return:</dt>
712 <dd>
713 flag indicating a nemd tuple
714 </dd>
715 </dl>
716 <dl>
717 <dt>Return Type:</dt>
718 <dd>
719 bool
720 </dd>
721 </dl>
722 <a NAME="NamingStyleChecker.__superClassNames" ID="NamingStyleChecker.__superClassNames"></a>
723 <h4>NamingStyleChecker.__superClassNames</h4>
724 <b>__superClassNames</b>(<i>name, parents, names=None</i>)
725
726 <p>
727 Private method to extract the names of all super classes.
728 </p>
729 <dl>
730
731 <dt><i>name</i> (str)</dt>
732 <dd>
733 name of the class
734 </dd>
735 <dt><i>parents</i> (ast.AST)</dt>
736 <dd>
737 list of parent nodes
738 </dd>
739 <dt><i>names</i> (set of str (optional))</dt>
740 <dd>
741 set of collected class names (defaults to None)
742 </dd>
743 </dl>
744 <dl>
745 <dt>Return:</dt>
746 <dd>
747 set of class names
748 </dd>
749 </dl>
750 <dl>
751 <dt>Return Type:</dt>
752 <dd>
753 set of str
754 </dd>
755 </dl>
465 <a NAME="NamingStyleChecker.__tagClassFunctions" ID="NamingStyleChecker.__tagClassFunctions"></a> 756 <a NAME="NamingStyleChecker.__tagClassFunctions" ID="NamingStyleChecker.__tagClassFunctions"></a>
466 <h4>NamingStyleChecker.__tagClassFunctions</h4> 757 <h4>NamingStyleChecker.__tagClassFunctions</h4>
467 <b>__tagClassFunctions</b>(<i>classNode</i>) 758 <b>__tagClassFunctions</b>(<i>classNode</i>)
468 759
469 <p> 760 <p>

eric ide

mercurial