--- a/eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.ComplexityChecker.html Wed Sep 25 19:40:31 2019 +0200 +++ b/eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.ComplexityChecker.html Wed Sep 25 19:42:44 2019 +0200 @@ -18,164 +18,216 @@ </style> </head> -<body><a NAME="top" ID="top"></a> +<body> +<a NAME="top" ID="top"></a> <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.ComplexityChecker</h1> + <p> Module implementing a checker for code complexity. </p> <h3>Global Attributes</h3> + <table> <tr><td>None</td></tr> </table> <h3>Classes</h3> + <table> + <tr> <td><a href="#ComplexityChecker">ComplexityChecker</a></td> <td>Class implementing a checker for code complexity.</td> -</tr><tr> +</tr> +<tr> <td><a href="#LineComplexityVisitor">LineComplexityVisitor</a></td> <td>Class calculating the number of AST nodes per line of code and the median nodes/line score.</td> </tr> </table> <h3>Functions</h3> + <table> <tr><td>None</td></tr> </table> -<hr /><hr /> +<hr /> +<hr /> <a NAME="ComplexityChecker" ID="ComplexityChecker"></a> <h2>ComplexityChecker</h2> + <p> Class implementing a checker for code complexity. </p> <h3>Derived from</h3> object <h3>Class Attributes</h3> + <table> <tr><td>Codes</td></tr> </table> <h3>Class Methods</h3> + <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> + <table> + <tr> <td><a href="#ComplexityChecker.__init__">ComplexityChecker</a></td> <td>Constructor</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.__checkLineComplexity">__checkLineComplexity</a></td> <td>Private method to check the complexity of a single line of code and the median line complexity of the source code.</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.__checkMcCabeComplexity">__checkMcCabeComplexity</a></td> <td>Private method to check the McCabe code complexity.</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.__error">__error</a></td> <td>Private method to record an issue.</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.__ignoreCode">__ignoreCode</a></td> <td>Private method to check if the message code should be ignored.</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.__reportInvalidSyntax">__reportInvalidSyntax</a></td> <td>Private method to report a syntax error.</td> -</tr><tr> +</tr> +<tr> <td><a href="#ComplexityChecker.run">run</a></td> <td>Public method to check the given source for code complexity.</td> </tr> </table> <h3>Static Methods</h3> + <table> <tr><td>None</td></tr> </table> + <a NAME="ComplexityChecker.__init__" ID="ComplexityChecker.__init__"></a> <h4>ComplexityChecker (Constructor)</h4> <b>ComplexityChecker</b>(<i>source, filename, select, ignore, args</i>) + <p> Constructor -</p><dl> +</p> +<dl> + <dt><i>source</i> (list of str)</dt> <dd> source code to be checked -</dd><dt><i>filename</i> (str)</dt> +</dd> +<dt><i>filename</i> (str)</dt> <dd> name of the source file -</dd><dt><i>select</i> (list of str)</dt> +</dd> +<dt><i>select</i> (list of str)</dt> <dd> list of selected codes -</dd><dt><i>ignore</i> (list of str)</dt> +</dd> +<dt><i>ignore</i> (list of str)</dt> <dd> list of codes to be ignored -</dd><dt><i>args</i> (dict)</dt> +</dd> +<dt><i>args</i> (dict)</dt> <dd> dictionary of arguments for the miscellaneous checks </dd> -</dl><a NAME="ComplexityChecker.__checkLineComplexity" ID="ComplexityChecker.__checkLineComplexity"></a> +</dl> +<a NAME="ComplexityChecker.__checkLineComplexity" ID="ComplexityChecker.__checkLineComplexity"></a> <h4>ComplexityChecker.__checkLineComplexity</h4> <b>__checkLineComplexity</b>(<i></i>) + <p> Private method to check the complexity of a single line of code and the median line complexity of the source code. -</p><p> +</p> +<p> Complexity is defined as the number of AST nodes produced by a line of code. -</p><a NAME="ComplexityChecker.__checkMcCabeComplexity" ID="ComplexityChecker.__checkMcCabeComplexity"></a> +</p> +<a NAME="ComplexityChecker.__checkMcCabeComplexity" ID="ComplexityChecker.__checkMcCabeComplexity"></a> <h4>ComplexityChecker.__checkMcCabeComplexity</h4> <b>__checkMcCabeComplexity</b>(<i></i>) + <p> Private method to check the McCabe code complexity. -</p><a NAME="ComplexityChecker.__error" ID="ComplexityChecker.__error"></a> +</p> +<a NAME="ComplexityChecker.__error" ID="ComplexityChecker.__error"></a> <h4>ComplexityChecker.__error</h4> <b>__error</b>(<i>lineNumber, offset, code, *args</i>) + <p> Private method to record an issue. -</p><dl> +</p> +<dl> + <dt><i>lineNumber</i> (int)</dt> <dd> line number of the issue -</dd><dt><i>offset</i> (int)</dt> +</dd> +<dt><i>offset</i> (int)</dt> <dd> position within line of the issue -</dd><dt><i>code</i> (str)</dt> +</dd> +<dt><i>code</i> (str)</dt> <dd> message code -</dd><dt><i>args</i> (list)</dt> +</dd> +<dt><i>args</i> (list)</dt> <dd> arguments for the message </dd> -</dl><a NAME="ComplexityChecker.__ignoreCode" ID="ComplexityChecker.__ignoreCode"></a> +</dl> +<a NAME="ComplexityChecker.__ignoreCode" ID="ComplexityChecker.__ignoreCode"></a> <h4>ComplexityChecker.__ignoreCode</h4> <b>__ignoreCode</b>(<i>code</i>) + <p> Private method to check if the message code should be ignored. -</p><dl> +</p> +<dl> + <dt><i>code</i> (str)</dt> <dd> message code to check for </dd> -</dl><dl> +</dl> +<dl> <dt>Returns:</dt> <dd> flag indicating to ignore the given code </dd> -</dl><dl> +</dl> +<dl> <dt>Return Type:</dt> <dd> bool </dd> -</dl><a NAME="ComplexityChecker.__reportInvalidSyntax" ID="ComplexityChecker.__reportInvalidSyntax"></a> +</dl> +<a NAME="ComplexityChecker.__reportInvalidSyntax" ID="ComplexityChecker.__reportInvalidSyntax"></a> <h4>ComplexityChecker.__reportInvalidSyntax</h4> <b>__reportInvalidSyntax</b>(<i></i>) + <p> Private method to report a syntax error. -</p><a NAME="ComplexityChecker.run" ID="ComplexityChecker.run"></a> +</p> +<a NAME="ComplexityChecker.run" ID="ComplexityChecker.run"></a> <h4>ComplexityChecker.run</h4> <b>run</b>(<i></i>) + <p> Public method to check the given source for code complexity. </p> <div align="right"><a href="#top">Up</a></div> -<hr /><hr /> +<hr /> +<hr /> <a NAME="LineComplexityVisitor" ID="LineComplexityVisitor"></a> <h2>LineComplexityVisitor</h2> + <p> Class calculating the number of AST nodes per line of code and the median nodes/line score. @@ -183,75 +235,97 @@ <h3>Derived from</h3> ast.NodeVisitor <h3>Class Attributes</h3> + <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> + <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> + <table> + <tr> <td><a href="#LineComplexityVisitor.__init__">LineComplexityVisitor</a></td> <td>Constructor</td> -</tr><tr> +</tr> +<tr> <td><a href="#LineComplexityVisitor.score">score</a></td> <td>Public method to calculate the median.</td> -</tr><tr> +</tr> +<tr> <td><a href="#LineComplexityVisitor.sortedList">sortedList</a></td> <td>Public method to get a sorted list of (line, nodes) tuples.</td> -</tr><tr> +</tr> +<tr> <td><a href="#LineComplexityVisitor.visit">visit</a></td> <td>Public method to recursively visit all the nodes and add up the instructions.</td> </tr> </table> <h3>Static Methods</h3> + <table> <tr><td>None</td></tr> </table> + <a NAME="LineComplexityVisitor.__init__" ID="LineComplexityVisitor.__init__"></a> <h4>LineComplexityVisitor (Constructor)</h4> <b>LineComplexityVisitor</b>(<i></i>) + <p> Constructor -</p><a NAME="LineComplexityVisitor.score" ID="LineComplexityVisitor.score"></a> +</p> +<a NAME="LineComplexityVisitor.score" ID="LineComplexityVisitor.score"></a> <h4>LineComplexityVisitor.score</h4> <b>score</b>(<i></i>) + <p> Public method to calculate the median. -</p><dl> +</p> +<dl> <dt>Returns:</dt> <dd> median line complexity value </dd> -</dl><dl> +</dl> +<dl> <dt>Return Type:</dt> <dd> float </dd> -</dl><a NAME="LineComplexityVisitor.sortedList" ID="LineComplexityVisitor.sortedList"></a> +</dl> +<a NAME="LineComplexityVisitor.sortedList" ID="LineComplexityVisitor.sortedList"></a> <h4>LineComplexityVisitor.sortedList</h4> <b>sortedList</b>(<i></i>) + <p> Public method to get a sorted list of (line, nodes) tuples. -</p><dl> +</p> +<dl> <dt>Returns:</dt> <dd> sorted list of (line, nodes) tuples </dd> -</dl><dl> +</dl> +<dl> <dt>Return Type:</dt> <dd> list of tuple of (int,int) </dd> -</dl><a NAME="LineComplexityVisitor.visit" ID="LineComplexityVisitor.visit"></a> +</dl> +<a NAME="LineComplexityVisitor.visit" ID="LineComplexityVisitor.visit"></a> <h4>LineComplexityVisitor.visit</h4> <b>visit</b>(<i>node</i>) + <p> Public method to recursively visit all the nodes and add up the instructions. -</p><dl> +</p> +<dl> + <dt><i>node</i> (ast.AST)</dt> <dd> reference to the node