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

changeset 6884
2a34f22cdbc1
parent 6184
789e88d94899
diff -r 57a2dc333cea -r 2a34f22cdbc1 Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker.html
--- a/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker.html	Tue Mar 19 19:36:13 2019 +0100
+++ b/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker.html	Tue Mar 19 19:37:19 2019 +0100
@@ -42,6 +42,9 @@
 <td><a href="#NameFinder">NameFinder</a></td>
 <td>Class to extract a name out of a tree of nodes.</td>
 </tr><tr>
+<td><a href="#ReturnVisitor">ReturnVisitor</a></td>
+<td>Class implementing a node visitor to check return statements.</td>
+</tr><tr>
 <td><a href="#TextVisitor">TextVisitor</a></td>
 <td>Class implementing a node visitor for bytes and str instances.</td>
 </tr>
@@ -434,6 +437,9 @@
 <td><a href="#MiscellaneousChecker.__checkPrintStatements">__checkPrintStatements</a></td>
 <td>Private method to check for print statements.</td>
 </tr><tr>
+<td><a href="#MiscellaneousChecker.__checkReturn">__checkReturn</a></td>
+<td>Private method to check return statements.</td>
+</tr><tr>
 <td><a href="#MiscellaneousChecker.__checkTuple">__checkTuple</a></td>
 <td>Private method to check for one element tuples.</td>
 </tr><tr>
@@ -557,6 +563,11 @@
 <b>__checkPrintStatements</b>(<i></i>)
 <p>
         Private method to check for print statements.
+</p><a NAME="MiscellaneousChecker.__checkReturn" ID="MiscellaneousChecker.__checkReturn"></a>
+<h4>MiscellaneousChecker.__checkReturn</h4>
+<b>__checkReturn</b>(<i></i>)
+<p>
+        Private method to check return statements.
 </p><a NAME="MiscellaneousChecker.__checkTuple" ID="MiscellaneousChecker.__checkTuple"></a>
 <h4>MiscellaneousChecker.__checkTuple</h4>
 <b>__checkTuple</b>(<i></i>)
@@ -749,6 +760,306 @@
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
+<a NAME="ReturnVisitor" ID="ReturnVisitor"></a>
+<h2>ReturnVisitor</h2>
+<p>
+    Class implementing a node visitor to check return statements.
+</p>
+<h3>Derived from</h3>
+ast.NodeVisitor
+<h3>Class Attributes</h3>
+<table>
+<tr><td>Assigns</td></tr><tr><td>Refs</td></tr><tr><td>Returns</td></tr>
+</table>
+<h3>Class Methods</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<h3>Methods</h3>
+<table>
+<tr>
+<td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td>
+<td>Constructor</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__checkFunction">__checkFunction</a></td>
+<td>Private method to check a function definition node.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__checkImplicitReturn">__checkImplicitReturn</a></td>
+<td>Private method to check for an implicit return statement.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__checkImplicitReturnValue">__checkImplicitReturnValue</a></td>
+<td>Private method to check for implicit return values.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__checkUnnecessaryAssign">__checkUnnecessaryAssign</a></td>
+<td>Private method to check for an unnecessary assign statement.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__checkUnnecessaryReturnNone">__checkUnnecessaryReturnNone</a></td>
+<td>Private method to check for an unnecessary 'return None' statement.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__hasRefsBeforeNextAssign">__hasRefsBeforeNextAssign</a></td>
+<td>Private method to check for references before a following assign statement.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__isNone">__isNone</a></td>
+<td>Private method to check, if a node value is None.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__resultExists">__resultExists</a></td>
+<td>Private method to check the existance of a return result.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__visitAssignTarget">__visitAssignTarget</a></td>
+<td>Private method to handle an assign target node.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.__visitWithStack">__visitWithStack</a></td>
+<td>Private method to traverse a given function node using a stack.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.assigns">assigns</a></td>
+<td>Public method to get the Assign nodes.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.refs">refs</a></td>
+<td>Public method to get the References nodes.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.returns">returns</a></td>
+<td>Public method to get the Return nodes.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.visit_Assign">visit_Assign</a></td>
+<td>Public method to handle an assign node.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
+<td>Public method to handle a function definition.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
+<td>Public method to handle a function definition.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.visit_Name">visit_Name</a></td>
+<td>Public method to handle a name node.</td>
+</tr><tr>
+<td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td>
+<td>Public method to handle a return node.</td>
+</tr>
+</table>
+<h3>Static Methods</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a>
+<h4>ReturnVisitor (Constructor)</h4>
+<b>ReturnVisitor</b>(<i></i>)
+<p>
+        Constructor
+</p><a NAME="ReturnVisitor.__checkFunction" ID="ReturnVisitor.__checkFunction"></a>
+<h4>ReturnVisitor.__checkFunction</h4>
+<b>__checkFunction</b>(<i>node</i>)
+<p>
+        Private method to check a function definition node.
+</p><dl>
+<dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
+<dd>
+reference to the node to check
+</dd>
+</dl><a NAME="ReturnVisitor.__checkImplicitReturn" ID="ReturnVisitor.__checkImplicitReturn"></a>
+<h4>ReturnVisitor.__checkImplicitReturn</h4>
+<b>__checkImplicitReturn</b>(<i>node</i>)
+<p>
+        Private method to check for an implicit return statement.
+</p><dl>
+<dt><i>node</i> (ast.AST)</dt>
+<dd>
+reference to the node to check
+</dd>
+</dl><a NAME="ReturnVisitor.__checkImplicitReturnValue" ID="ReturnVisitor.__checkImplicitReturnValue"></a>
+<h4>ReturnVisitor.__checkImplicitReturnValue</h4>
+<b>__checkImplicitReturnValue</b>(<i></i>)
+<p>
+        Private method to check for implicit return values.
+</p><a NAME="ReturnVisitor.__checkUnnecessaryAssign" ID="ReturnVisitor.__checkUnnecessaryAssign"></a>
+<h4>ReturnVisitor.__checkUnnecessaryAssign</h4>
+<b>__checkUnnecessaryAssign</b>(<i>node</i>)
+<p>
+        Private method to check for an unnecessary assign statement.
+</p><dl>
+<dt><i>node</i> (ast.AST)</dt>
+<dd>
+reference to the node to check
+</dd>
+</dl><a NAME="ReturnVisitor.__checkUnnecessaryReturnNone" ID="ReturnVisitor.__checkUnnecessaryReturnNone"></a>
+<h4>ReturnVisitor.__checkUnnecessaryReturnNone</h4>
+<b>__checkUnnecessaryReturnNone</b>(<i></i>)
+<p>
+        Private method to check for an unnecessary 'return None' statement.
+</p><a NAME="ReturnVisitor.__hasRefsBeforeNextAssign" ID="ReturnVisitor.__hasRefsBeforeNextAssign"></a>
+<h4>ReturnVisitor.__hasRefsBeforeNextAssign</h4>
+<b>__hasRefsBeforeNextAssign</b>(<i>varname, returnLineno</i>)
+<p>
+        Private method to check for references before a following assign
+        statement.
+</p><dl>
+<dt><i>varname</i> (str)</dt>
+<dd>
+variable name to check for
+</dd><dt><i>returnLineno</i> (int)</dt>
+<dd>
+line number of the return statement
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating the existence of references
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl><a NAME="ReturnVisitor.__isNone" ID="ReturnVisitor.__isNone"></a>
+<h4>ReturnVisitor.__isNone</h4>
+<b>__isNone</b>(<i>node</i>)
+<p>
+        Private method to check, if a node value is None.
+</p><dl>
+<dt><i>node</i> (ast.AST)</dt>
+<dd>
+reference to the node to check
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating the node contains a None value
+</dd>
+</dl><a NAME="ReturnVisitor.__resultExists" ID="ReturnVisitor.__resultExists"></a>
+<h4>ReturnVisitor.__resultExists</h4>
+<b>__resultExists</b>(<i></i>)
+<p>
+        Private method to check the existance of a return result.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating the existence of a return result
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl><a NAME="ReturnVisitor.__visitAssignTarget" ID="ReturnVisitor.__visitAssignTarget"></a>
+<h4>ReturnVisitor.__visitAssignTarget</h4>
+<b>__visitAssignTarget</b>(<i>node</i>)
+<p>
+        Private method to handle an assign target node.
+</p><dl>
+<dt><i>node</i> (ast.AST)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl><a NAME="ReturnVisitor.__visitWithStack" ID="ReturnVisitor.__visitWithStack"></a>
+<h4>ReturnVisitor.__visitWithStack</h4>
+<b>__visitWithStack</b>(<i>node</i>)
+<p>
+        Private method to traverse a given function node using a stack.
+</p><dl>
+<dt><i>node</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt>
+<dd>
+AST node to be traversed
+</dd>
+</dl><a NAME="ReturnVisitor.assigns" ID="ReturnVisitor.assigns"></a>
+<h4>ReturnVisitor.assigns</h4>
+<b>assigns</b>(<i></i>)
+<p>
+        Public method to get the Assign nodes.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+dictionary containing the node name as key and line number
+            as value
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+dict
+</dd>
+</dl><a NAME="ReturnVisitor.refs" ID="ReturnVisitor.refs"></a>
+<h4>ReturnVisitor.refs</h4>
+<b>refs</b>(<i></i>)
+<p>
+        Public method to get the References nodes.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+dictionary containing the node name as key and line number
+            as value
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+dict
+</dd>
+</dl><a NAME="ReturnVisitor.returns" ID="ReturnVisitor.returns"></a>
+<h4>ReturnVisitor.returns</h4>
+<b>returns</b>(<i></i>)
+<p>
+        Public method to get the Return nodes.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+dictionary containing the node name as key and line number
+            as value
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+dict
+</dd>
+</dl><a NAME="ReturnVisitor.visit_Assign" ID="ReturnVisitor.visit_Assign"></a>
+<h4>ReturnVisitor.visit_Assign</h4>
+<b>visit_Assign</b>(<i>node</i>)
+<p>
+        Public method to handle an assign node.
+</p><dl>
+<dt><i>node</i> (ast.Assign)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl><a NAME="ReturnVisitor.visit_AsyncFunctionDef" ID="ReturnVisitor.visit_AsyncFunctionDef"></a>
+<h4>ReturnVisitor.visit_AsyncFunctionDef</h4>
+<b>visit_AsyncFunctionDef</b>(<i>node</i>)
+<p>
+        Public method to handle a function definition.
+</p><dl>
+<dt><i>node</i> (ast.AsyncFunctionDef)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl><a NAME="ReturnVisitor.visit_FunctionDef" ID="ReturnVisitor.visit_FunctionDef"></a>
+<h4>ReturnVisitor.visit_FunctionDef</h4>
+<b>visit_FunctionDef</b>(<i>node</i>)
+<p>
+        Public method to handle a function definition.
+</p><dl>
+<dt><i>node</i> (ast.FunctionDef)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl><a NAME="ReturnVisitor.visit_Name" ID="ReturnVisitor.visit_Name"></a>
+<h4>ReturnVisitor.visit_Name</h4>
+<b>visit_Name</b>(<i>node</i>)
+<p>
+        Public method to handle a name node.
+</p><dl>
+<dt><i>node</i> (ast.Name)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl><a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a>
+<h4>ReturnVisitor.visit_Return</h4>
+<b>visit_Return</b>(<i>node</i>)
+<p>
+        Public method to handle a return node.
+</p><dl>
+<dt><i>node</i> (ast.Return)</dt>
+<dd>
+reference to the node to handle
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
 <a NAME="TextVisitor" ID="TextVisitor"></a>
 <h2>TextVisitor</h2>
 <p>

eric ide

mercurial