Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker.html

changeset 6884
2a34f22cdbc1
parent 6184
789e88d94899
equal deleted inserted replaced
6883:57a2dc333cea 6884:2a34f22cdbc1
40 <td>Class implementing a checker for miscellaneous checks.</td> 40 <td>Class implementing a checker for miscellaneous checks.</td>
41 </tr><tr> 41 </tr><tr>
42 <td><a href="#NameFinder">NameFinder</a></td> 42 <td><a href="#NameFinder">NameFinder</a></td>
43 <td>Class to extract a name out of a tree of nodes.</td> 43 <td>Class to extract a name out of a tree of nodes.</td>
44 </tr><tr> 44 </tr><tr>
45 <td><a href="#ReturnVisitor">ReturnVisitor</a></td>
46 <td>Class implementing a node visitor to check return statements.</td>
47 </tr><tr>
45 <td><a href="#TextVisitor">TextVisitor</a></td> 48 <td><a href="#TextVisitor">TextVisitor</a></td>
46 <td>Class implementing a node visitor for bytes and str instances.</td> 49 <td>Class implementing a node visitor for bytes and str instances.</td>
47 </tr> 50 </tr>
48 </table> 51 </table>
49 <h3>Functions</h3> 52 <h3>Functions</h3>
432 <td>Private method to check for old style string formatting.</td> 435 <td>Private method to check for old style string formatting.</td>
433 </tr><tr> 436 </tr><tr>
434 <td><a href="#MiscellaneousChecker.__checkPrintStatements">__checkPrintStatements</a></td> 437 <td><a href="#MiscellaneousChecker.__checkPrintStatements">__checkPrintStatements</a></td>
435 <td>Private method to check for print statements.</td> 438 <td>Private method to check for print statements.</td>
436 </tr><tr> 439 </tr><tr>
440 <td><a href="#MiscellaneousChecker.__checkReturn">__checkReturn</a></td>
441 <td>Private method to check return statements.</td>
442 </tr><tr>
437 <td><a href="#MiscellaneousChecker.__checkTuple">__checkTuple</a></td> 443 <td><a href="#MiscellaneousChecker.__checkTuple">__checkTuple</a></td>
438 <td>Private method to check for one element tuples.</td> 444 <td>Private method to check for one element tuples.</td>
439 </tr><tr> 445 </tr><tr>
440 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> 446 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td>
441 <td>Private function to test, if the node should be checked.</td> 447 <td>Private function to test, if the node should be checked.</td>
555 </p><a NAME="MiscellaneousChecker.__checkPrintStatements" ID="MiscellaneousChecker.__checkPrintStatements"></a> 561 </p><a NAME="MiscellaneousChecker.__checkPrintStatements" ID="MiscellaneousChecker.__checkPrintStatements"></a>
556 <h4>MiscellaneousChecker.__checkPrintStatements</h4> 562 <h4>MiscellaneousChecker.__checkPrintStatements</h4>
557 <b>__checkPrintStatements</b>(<i></i>) 563 <b>__checkPrintStatements</b>(<i></i>)
558 <p> 564 <p>
559 Private method to check for print statements. 565 Private method to check for print statements.
566 </p><a NAME="MiscellaneousChecker.__checkReturn" ID="MiscellaneousChecker.__checkReturn"></a>
567 <h4>MiscellaneousChecker.__checkReturn</h4>
568 <b>__checkReturn</b>(<i></i>)
569 <p>
570 Private method to check return statements.
560 </p><a NAME="MiscellaneousChecker.__checkTuple" ID="MiscellaneousChecker.__checkTuple"></a> 571 </p><a NAME="MiscellaneousChecker.__checkTuple" ID="MiscellaneousChecker.__checkTuple"></a>
561 <h4>MiscellaneousChecker.__checkTuple</h4> 572 <h4>MiscellaneousChecker.__checkTuple</h4>
562 <b>__checkTuple</b>(<i></i>) 573 <b>__checkTuple</b>(<i></i>)
563 <p> 574 <p>
564 Private method to check for one element tuples. 575 Private method to check for one element tuples.
743 Public method to handle 'Name' nodes. 754 Public method to handle 'Name' nodes.
744 </p><dl> 755 </p><dl>
745 <dt><i>node</i> (ast.Name)</dt> 756 <dt><i>node</i> (ast.Name)</dt>
746 <dd> 757 <dd>
747 reference to the node to be processed 758 reference to the node to be processed
759 </dd>
760 </dl>
761 <div align="right"><a href="#top">Up</a></div>
762 <hr /><hr />
763 <a NAME="ReturnVisitor" ID="ReturnVisitor"></a>
764 <h2>ReturnVisitor</h2>
765 <p>
766 Class implementing a node visitor to check return statements.
767 </p>
768 <h3>Derived from</h3>
769 ast.NodeVisitor
770 <h3>Class Attributes</h3>
771 <table>
772 <tr><td>Assigns</td></tr><tr><td>Refs</td></tr><tr><td>Returns</td></tr>
773 </table>
774 <h3>Class Methods</h3>
775 <table>
776 <tr><td>None</td></tr>
777 </table>
778 <h3>Methods</h3>
779 <table>
780 <tr>
781 <td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td>
782 <td>Constructor</td>
783 </tr><tr>
784 <td><a href="#ReturnVisitor.__checkFunction">__checkFunction</a></td>
785 <td>Private method to check a function definition node.</td>
786 </tr><tr>
787 <td><a href="#ReturnVisitor.__checkImplicitReturn">__checkImplicitReturn</a></td>
788 <td>Private method to check for an implicit return statement.</td>
789 </tr><tr>
790 <td><a href="#ReturnVisitor.__checkImplicitReturnValue">__checkImplicitReturnValue</a></td>
791 <td>Private method to check for implicit return values.</td>
792 </tr><tr>
793 <td><a href="#ReturnVisitor.__checkUnnecessaryAssign">__checkUnnecessaryAssign</a></td>
794 <td>Private method to check for an unnecessary assign statement.</td>
795 </tr><tr>
796 <td><a href="#ReturnVisitor.__checkUnnecessaryReturnNone">__checkUnnecessaryReturnNone</a></td>
797 <td>Private method to check for an unnecessary 'return None' statement.</td>
798 </tr><tr>
799 <td><a href="#ReturnVisitor.__hasRefsBeforeNextAssign">__hasRefsBeforeNextAssign</a></td>
800 <td>Private method to check for references before a following assign statement.</td>
801 </tr><tr>
802 <td><a href="#ReturnVisitor.__isNone">__isNone</a></td>
803 <td>Private method to check, if a node value is None.</td>
804 </tr><tr>
805 <td><a href="#ReturnVisitor.__resultExists">__resultExists</a></td>
806 <td>Private method to check the existance of a return result.</td>
807 </tr><tr>
808 <td><a href="#ReturnVisitor.__visitAssignTarget">__visitAssignTarget</a></td>
809 <td>Private method to handle an assign target node.</td>
810 </tr><tr>
811 <td><a href="#ReturnVisitor.__visitWithStack">__visitWithStack</a></td>
812 <td>Private method to traverse a given function node using a stack.</td>
813 </tr><tr>
814 <td><a href="#ReturnVisitor.assigns">assigns</a></td>
815 <td>Public method to get the Assign nodes.</td>
816 </tr><tr>
817 <td><a href="#ReturnVisitor.refs">refs</a></td>
818 <td>Public method to get the References nodes.</td>
819 </tr><tr>
820 <td><a href="#ReturnVisitor.returns">returns</a></td>
821 <td>Public method to get the Return nodes.</td>
822 </tr><tr>
823 <td><a href="#ReturnVisitor.visit_Assign">visit_Assign</a></td>
824 <td>Public method to handle an assign node.</td>
825 </tr><tr>
826 <td><a href="#ReturnVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
827 <td>Public method to handle a function definition.</td>
828 </tr><tr>
829 <td><a href="#ReturnVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
830 <td>Public method to handle a function definition.</td>
831 </tr><tr>
832 <td><a href="#ReturnVisitor.visit_Name">visit_Name</a></td>
833 <td>Public method to handle a name node.</td>
834 </tr><tr>
835 <td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td>
836 <td>Public method to handle a return node.</td>
837 </tr>
838 </table>
839 <h3>Static Methods</h3>
840 <table>
841 <tr><td>None</td></tr>
842 </table>
843 <a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a>
844 <h4>ReturnVisitor (Constructor)</h4>
845 <b>ReturnVisitor</b>(<i></i>)
846 <p>
847 Constructor
848 </p><a NAME="ReturnVisitor.__checkFunction" ID="ReturnVisitor.__checkFunction"></a>
849 <h4>ReturnVisitor.__checkFunction</h4>
850 <b>__checkFunction</b>(<i>node</i>)
851 <p>
852 Private method to check a function definition node.
853 </p><dl>
854 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
855 <dd>
856 reference to the node to check
857 </dd>
858 </dl><a NAME="ReturnVisitor.__checkImplicitReturn" ID="ReturnVisitor.__checkImplicitReturn"></a>
859 <h4>ReturnVisitor.__checkImplicitReturn</h4>
860 <b>__checkImplicitReturn</b>(<i>node</i>)
861 <p>
862 Private method to check for an implicit return statement.
863 </p><dl>
864 <dt><i>node</i> (ast.AST)</dt>
865 <dd>
866 reference to the node to check
867 </dd>
868 </dl><a NAME="ReturnVisitor.__checkImplicitReturnValue" ID="ReturnVisitor.__checkImplicitReturnValue"></a>
869 <h4>ReturnVisitor.__checkImplicitReturnValue</h4>
870 <b>__checkImplicitReturnValue</b>(<i></i>)
871 <p>
872 Private method to check for implicit return values.
873 </p><a NAME="ReturnVisitor.__checkUnnecessaryAssign" ID="ReturnVisitor.__checkUnnecessaryAssign"></a>
874 <h4>ReturnVisitor.__checkUnnecessaryAssign</h4>
875 <b>__checkUnnecessaryAssign</b>(<i>node</i>)
876 <p>
877 Private method to check for an unnecessary assign statement.
878 </p><dl>
879 <dt><i>node</i> (ast.AST)</dt>
880 <dd>
881 reference to the node to check
882 </dd>
883 </dl><a NAME="ReturnVisitor.__checkUnnecessaryReturnNone" ID="ReturnVisitor.__checkUnnecessaryReturnNone"></a>
884 <h4>ReturnVisitor.__checkUnnecessaryReturnNone</h4>
885 <b>__checkUnnecessaryReturnNone</b>(<i></i>)
886 <p>
887 Private method to check for an unnecessary 'return None' statement.
888 </p><a NAME="ReturnVisitor.__hasRefsBeforeNextAssign" ID="ReturnVisitor.__hasRefsBeforeNextAssign"></a>
889 <h4>ReturnVisitor.__hasRefsBeforeNextAssign</h4>
890 <b>__hasRefsBeforeNextAssign</b>(<i>varname, returnLineno</i>)
891 <p>
892 Private method to check for references before a following assign
893 statement.
894 </p><dl>
895 <dt><i>varname</i> (str)</dt>
896 <dd>
897 variable name to check for
898 </dd><dt><i>returnLineno</i> (int)</dt>
899 <dd>
900 line number of the return statement
901 </dd>
902 </dl><dl>
903 <dt>Returns:</dt>
904 <dd>
905 flag indicating the existence of references
906 </dd>
907 </dl><dl>
908 <dt>Return Type:</dt>
909 <dd>
910 bool
911 </dd>
912 </dl><a NAME="ReturnVisitor.__isNone" ID="ReturnVisitor.__isNone"></a>
913 <h4>ReturnVisitor.__isNone</h4>
914 <b>__isNone</b>(<i>node</i>)
915 <p>
916 Private method to check, if a node value is None.
917 </p><dl>
918 <dt><i>node</i> (ast.AST)</dt>
919 <dd>
920 reference to the node to check
921 </dd>
922 </dl><dl>
923 <dt>Returns:</dt>
924 <dd>
925 flag indicating the node contains a None value
926 </dd>
927 </dl><a NAME="ReturnVisitor.__resultExists" ID="ReturnVisitor.__resultExists"></a>
928 <h4>ReturnVisitor.__resultExists</h4>
929 <b>__resultExists</b>(<i></i>)
930 <p>
931 Private method to check the existance of a return result.
932 </p><dl>
933 <dt>Returns:</dt>
934 <dd>
935 flag indicating the existence of a return result
936 </dd>
937 </dl><dl>
938 <dt>Return Type:</dt>
939 <dd>
940 bool
941 </dd>
942 </dl><a NAME="ReturnVisitor.__visitAssignTarget" ID="ReturnVisitor.__visitAssignTarget"></a>
943 <h4>ReturnVisitor.__visitAssignTarget</h4>
944 <b>__visitAssignTarget</b>(<i>node</i>)
945 <p>
946 Private method to handle an assign target node.
947 </p><dl>
948 <dt><i>node</i> (ast.AST)</dt>
949 <dd>
950 reference to the node to handle
951 </dd>
952 </dl><a NAME="ReturnVisitor.__visitWithStack" ID="ReturnVisitor.__visitWithStack"></a>
953 <h4>ReturnVisitor.__visitWithStack</h4>
954 <b>__visitWithStack</b>(<i>node</i>)
955 <p>
956 Private method to traverse a given function node using a stack.
957 </p><dl>
958 <dt><i>node</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt>
959 <dd>
960 AST node to be traversed
961 </dd>
962 </dl><a NAME="ReturnVisitor.assigns" ID="ReturnVisitor.assigns"></a>
963 <h4>ReturnVisitor.assigns</h4>
964 <b>assigns</b>(<i></i>)
965 <p>
966 Public method to get the Assign nodes.
967 </p><dl>
968 <dt>Returns:</dt>
969 <dd>
970 dictionary containing the node name as key and line number
971 as value
972 </dd>
973 </dl><dl>
974 <dt>Return Type:</dt>
975 <dd>
976 dict
977 </dd>
978 </dl><a NAME="ReturnVisitor.refs" ID="ReturnVisitor.refs"></a>
979 <h4>ReturnVisitor.refs</h4>
980 <b>refs</b>(<i></i>)
981 <p>
982 Public method to get the References nodes.
983 </p><dl>
984 <dt>Returns:</dt>
985 <dd>
986 dictionary containing the node name as key and line number
987 as value
988 </dd>
989 </dl><dl>
990 <dt>Return Type:</dt>
991 <dd>
992 dict
993 </dd>
994 </dl><a NAME="ReturnVisitor.returns" ID="ReturnVisitor.returns"></a>
995 <h4>ReturnVisitor.returns</h4>
996 <b>returns</b>(<i></i>)
997 <p>
998 Public method to get the Return nodes.
999 </p><dl>
1000 <dt>Returns:</dt>
1001 <dd>
1002 dictionary containing the node name as key and line number
1003 as value
1004 </dd>
1005 </dl><dl>
1006 <dt>Return Type:</dt>
1007 <dd>
1008 dict
1009 </dd>
1010 </dl><a NAME="ReturnVisitor.visit_Assign" ID="ReturnVisitor.visit_Assign"></a>
1011 <h4>ReturnVisitor.visit_Assign</h4>
1012 <b>visit_Assign</b>(<i>node</i>)
1013 <p>
1014 Public method to handle an assign node.
1015 </p><dl>
1016 <dt><i>node</i> (ast.Assign)</dt>
1017 <dd>
1018 reference to the node to handle
1019 </dd>
1020 </dl><a NAME="ReturnVisitor.visit_AsyncFunctionDef" ID="ReturnVisitor.visit_AsyncFunctionDef"></a>
1021 <h4>ReturnVisitor.visit_AsyncFunctionDef</h4>
1022 <b>visit_AsyncFunctionDef</b>(<i>node</i>)
1023 <p>
1024 Public method to handle a function definition.
1025 </p><dl>
1026 <dt><i>node</i> (ast.AsyncFunctionDef)</dt>
1027 <dd>
1028 reference to the node to handle
1029 </dd>
1030 </dl><a NAME="ReturnVisitor.visit_FunctionDef" ID="ReturnVisitor.visit_FunctionDef"></a>
1031 <h4>ReturnVisitor.visit_FunctionDef</h4>
1032 <b>visit_FunctionDef</b>(<i>node</i>)
1033 <p>
1034 Public method to handle a function definition.
1035 </p><dl>
1036 <dt><i>node</i> (ast.FunctionDef)</dt>
1037 <dd>
1038 reference to the node to handle
1039 </dd>
1040 </dl><a NAME="ReturnVisitor.visit_Name" ID="ReturnVisitor.visit_Name"></a>
1041 <h4>ReturnVisitor.visit_Name</h4>
1042 <b>visit_Name</b>(<i>node</i>)
1043 <p>
1044 Public method to handle a name node.
1045 </p><dl>
1046 <dt><i>node</i> (ast.Name)</dt>
1047 <dd>
1048 reference to the node to handle
1049 </dd>
1050 </dl><a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a>
1051 <h4>ReturnVisitor.visit_Return</h4>
1052 <b>visit_Return</b>(<i>node</i>)
1053 <p>
1054 Public method to handle a return node.
1055 </p><dl>
1056 <dt><i>node</i> (ast.Return)</dt>
1057 <dd>
1058 reference to the node to handle
748 </dd> 1059 </dd>
749 </dl> 1060 </dl>
750 <div align="right"><a href="#top">Up</a></div> 1061 <div align="right"><a href="#top">Up</a></div>
751 <hr /><hr /> 1062 <hr /><hr />
752 <a NAME="TextVisitor" ID="TextVisitor"></a> 1063 <a NAME="TextVisitor" ID="TextVisitor"></a>

eric ide

mercurial