src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker.html

branch
eric7
changeset 10479
856476537696
parent 9209
b99e7fd55fd3
child 11150
73d80859079c
equal deleted inserted replaced
10478:de9106c55c3d 10479:856476537696
5 <link rel="stylesheet" href="styles.css"> 5 <link rel="stylesheet" href="styles.css">
6 </head> 6 </head>
7 <body> 7 <body>
8 <a NAME="top" ID="top"></a> 8 <a NAME="top" ID="top"></a>
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker</h1> 9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker</h1>
10
11 <p> 10 <p>
12 Module implementing a checker for code complexity. 11 Module implementing a checker for code complexity.
13 </p> 12 </p>
13
14 <h3>Global Attributes</h3> 14 <h3>Global Attributes</h3>
15 15 <table>
16 <table> 16 <tr><td>None</td></tr>
17 <tr><td>None</td></tr> 17 </table>
18 </table> 18
19 <h3>Classes</h3> 19 <h3>Classes</h3>
20 20 <table>
21 <table>
22
23 <tr> 21 <tr>
24 <td><a href="#ComplexityChecker">ComplexityChecker</a></td> 22 <td><a href="#ComplexityChecker">ComplexityChecker</a></td>
25 <td>Class implementing a checker for code complexity.</td> 23 <td>Class implementing a checker for code complexity.</td>
26 </tr> 24 </tr>
27 <tr> 25 <tr>
28 <td><a href="#LineComplexityVisitor">LineComplexityVisitor</a></td> 26 <td><a href="#LineComplexityVisitor">LineComplexityVisitor</a></td>
29 <td>Class calculating the number of AST nodes per line of code and the median nodes/line score.</td> 27 <td>Class calculating the number of AST nodes per line of code and the median nodes/line score.</td>
30 </tr> 28 </tr>
31 </table> 29 </table>
30
32 <h3>Functions</h3> 31 <h3>Functions</h3>
33 32 <table>
34 <table> 33 <tr><td>None</td></tr>
35 <tr><td>None</td></tr> 34 </table>
36 </table> 35
37 <hr /> 36 <hr />
38 <hr /> 37 <hr />
39 <a NAME="ComplexityChecker" ID="ComplexityChecker"></a> 38 <a NAME="ComplexityChecker" ID="ComplexityChecker"></a>
40 <h2>ComplexityChecker</h2> 39 <h2>ComplexityChecker</h2>
41
42 <p> 40 <p>
43 Class implementing a checker for code complexity. 41 Class implementing a checker for code complexity.
44 </p> 42 </p>
43
45 <h3>Derived from</h3> 44 <h3>Derived from</h3>
46 None 45 None
47 <h3>Class Attributes</h3> 46 <h3>Class Attributes</h3>
48
49 <table> 47 <table>
50 <tr><td>Codes</td></tr> 48 <tr><td>Codes</td></tr>
51 </table> 49 </table>
50
52 <h3>Class Methods</h3> 51 <h3>Class Methods</h3>
53 52 <table>
54 <table> 53 <tr><td>None</td></tr>
55 <tr><td>None</td></tr> 54 </table>
56 </table> 55
57 <h3>Methods</h3> 56 <h3>Methods</h3>
58 57 <table>
59 <table>
60
61 <tr> 58 <tr>
62 <td><a href="#ComplexityChecker.__init__">ComplexityChecker</a></td> 59 <td><a href="#ComplexityChecker.__init__">ComplexityChecker</a></td>
63 <td>Constructor</td> 60 <td>Constructor</td>
64 </tr> 61 </tr>
65 <tr> 62 <tr>
81 <tr> 78 <tr>
82 <td><a href="#ComplexityChecker.run">run</a></td> 79 <td><a href="#ComplexityChecker.run">run</a></td>
83 <td>Public method to check the given source for code complexity.</td> 80 <td>Public method to check the given source for code complexity.</td>
84 </tr> 81 </tr>
85 </table> 82 </table>
83
86 <h3>Static Methods</h3> 84 <h3>Static Methods</h3>
87 85 <table>
88 <table> 86 <tr><td>None</td></tr>
89 <tr><td>None</td></tr> 87 </table>
90 </table> 88
91 89
92 <a NAME="ComplexityChecker.__init__" ID="ComplexityChecker.__init__"></a> 90 <a NAME="ComplexityChecker.__init__" ID="ComplexityChecker.__init__"></a>
93 <h4>ComplexityChecker (Constructor)</h4> 91 <h4>ComplexityChecker (Constructor)</h4>
94 <b>ComplexityChecker</b>(<i>source, filename, tree, select, ignore, args</i>) 92 <b>ComplexityChecker</b>(<i>source, filename, tree, select, ignore, args</i>)
95
96 <p> 93 <p>
97 Constructor 94 Constructor
98 </p> 95 </p>
96
99 <dl> 97 <dl>
100 98
101 <dt><i>source</i> (list of str)</dt> 99 <dt><i>source</i> (list of str)</dt>
102 <dd> 100 <dd>
103 source code to be checked 101 source code to be checked
124 </dd> 122 </dd>
125 </dl> 123 </dl>
126 <a NAME="ComplexityChecker.__checkLineComplexity" ID="ComplexityChecker.__checkLineComplexity"></a> 124 <a NAME="ComplexityChecker.__checkLineComplexity" ID="ComplexityChecker.__checkLineComplexity"></a>
127 <h4>ComplexityChecker.__checkLineComplexity</h4> 125 <h4>ComplexityChecker.__checkLineComplexity</h4>
128 <b>__checkLineComplexity</b>(<i></i>) 126 <b>__checkLineComplexity</b>(<i></i>)
129
130 <p> 127 <p>
131 Private method to check the complexity of a single line of code and 128 Private method to check the complexity of a single line of code and
132 the median line complexity of the source code. 129 the median line complexity of the source code.
133 </p> 130 </p>
134 <p> 131 <p>
135 Complexity is defined as the number of AST nodes produced by a line 132 Complexity is defined as the number of AST nodes produced by a line
136 of code. 133 of code.
137 </p> 134 </p>
135
138 <a NAME="ComplexityChecker.__checkMcCabeComplexity" ID="ComplexityChecker.__checkMcCabeComplexity"></a> 136 <a NAME="ComplexityChecker.__checkMcCabeComplexity" ID="ComplexityChecker.__checkMcCabeComplexity"></a>
139 <h4>ComplexityChecker.__checkMcCabeComplexity</h4> 137 <h4>ComplexityChecker.__checkMcCabeComplexity</h4>
140 <b>__checkMcCabeComplexity</b>(<i></i>) 138 <b>__checkMcCabeComplexity</b>(<i></i>)
141
142 <p> 139 <p>
143 Private method to check the McCabe code complexity. 140 Private method to check the McCabe code complexity.
144 </p> 141 </p>
142
145 <a NAME="ComplexityChecker.__error" ID="ComplexityChecker.__error"></a> 143 <a NAME="ComplexityChecker.__error" ID="ComplexityChecker.__error"></a>
146 <h4>ComplexityChecker.__error</h4> 144 <h4>ComplexityChecker.__error</h4>
147 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) 145 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
148
149 <p> 146 <p>
150 Private method to record an issue. 147 Private method to record an issue.
151 </p> 148 </p>
149
152 <dl> 150 <dl>
153 151
154 <dt><i>lineNumber</i> (int)</dt> 152 <dt><i>lineNumber</i> (int)</dt>
155 <dd> 153 <dd>
156 line number of the issue 154 line number of the issue
169 </dd> 167 </dd>
170 </dl> 168 </dl>
171 <a NAME="ComplexityChecker.__ignoreCode" ID="ComplexityChecker.__ignoreCode"></a> 169 <a NAME="ComplexityChecker.__ignoreCode" ID="ComplexityChecker.__ignoreCode"></a>
172 <h4>ComplexityChecker.__ignoreCode</h4> 170 <h4>ComplexityChecker.__ignoreCode</h4>
173 <b>__ignoreCode</b>(<i>code</i>) 171 <b>__ignoreCode</b>(<i>code</i>)
174
175 <p> 172 <p>
176 Private method to check if the message code should be ignored. 173 Private method to check if the message code should be ignored.
177 </p> 174 </p>
175
178 <dl> 176 <dl>
179 177
180 <dt><i>code</i> (str)</dt> 178 <dt><i>code</i> (str)</dt>
181 <dd> 179 <dd>
182 message code to check for 180 message code to check for
195 </dd> 193 </dd>
196 </dl> 194 </dl>
197 <a NAME="ComplexityChecker.run" ID="ComplexityChecker.run"></a> 195 <a NAME="ComplexityChecker.run" ID="ComplexityChecker.run"></a>
198 <h4>ComplexityChecker.run</h4> 196 <h4>ComplexityChecker.run</h4>
199 <b>run</b>(<i></i>) 197 <b>run</b>(<i></i>)
200
201 <p> 198 <p>
202 Public method to check the given source for code complexity. 199 Public method to check the given source for code complexity.
203 </p> 200 </p>
201
204 <div align="right"><a href="#top">Up</a></div> 202 <div align="right"><a href="#top">Up</a></div>
205 <hr /> 203 <hr />
206 <hr /> 204 <hr />
207 <a NAME="LineComplexityVisitor" ID="LineComplexityVisitor"></a> 205 <a NAME="LineComplexityVisitor" ID="LineComplexityVisitor"></a>
208 <h2>LineComplexityVisitor</h2> 206 <h2>LineComplexityVisitor</h2>
209
210 <p> 207 <p>
211 Class calculating the number of AST nodes per line of code 208 Class calculating the number of AST nodes per line of code
212 and the median nodes/line score. 209 and the median nodes/line score.
213 </p> 210 </p>
211
214 <h3>Derived from</h3> 212 <h3>Derived from</h3>
215 ast.NodeVisitor 213 ast.NodeVisitor
216 <h3>Class Attributes</h3> 214 <h3>Class Attributes</h3>
217 215 <table>
218 <table> 216 <tr><td>None</td></tr>
219 <tr><td>None</td></tr> 217 </table>
220 </table> 218
221 <h3>Class Methods</h3> 219 <h3>Class Methods</h3>
222 220 <table>
223 <table> 221 <tr><td>None</td></tr>
224 <tr><td>None</td></tr> 222 </table>
225 </table> 223
226 <h3>Methods</h3> 224 <h3>Methods</h3>
227 225 <table>
228 <table>
229
230 <tr> 226 <tr>
231 <td><a href="#LineComplexityVisitor.__init__">LineComplexityVisitor</a></td> 227 <td><a href="#LineComplexityVisitor.__init__">LineComplexityVisitor</a></td>
232 <td>Constructor</td> 228 <td>Constructor</td>
233 </tr> 229 </tr>
234 <tr> 230 <tr>
242 <tr> 238 <tr>
243 <td><a href="#LineComplexityVisitor.visit">visit</a></td> 239 <td><a href="#LineComplexityVisitor.visit">visit</a></td>
244 <td>Public method to recursively visit all the nodes and add up the instructions.</td> 240 <td>Public method to recursively visit all the nodes and add up the instructions.</td>
245 </tr> 241 </tr>
246 </table> 242 </table>
243
247 <h3>Static Methods</h3> 244 <h3>Static Methods</h3>
248 245 <table>
249 <table> 246 <tr><td>None</td></tr>
250 <tr><td>None</td></tr> 247 </table>
251 </table> 248
252 249
253 <a NAME="LineComplexityVisitor.__init__" ID="LineComplexityVisitor.__init__"></a> 250 <a NAME="LineComplexityVisitor.__init__" ID="LineComplexityVisitor.__init__"></a>
254 <h4>LineComplexityVisitor (Constructor)</h4> 251 <h4>LineComplexityVisitor (Constructor)</h4>
255 <b>LineComplexityVisitor</b>(<i></i>) 252 <b>LineComplexityVisitor</b>(<i></i>)
256
257 <p> 253 <p>
258 Constructor 254 Constructor
259 </p> 255 </p>
256
260 <a NAME="LineComplexityVisitor.score" ID="LineComplexityVisitor.score"></a> 257 <a NAME="LineComplexityVisitor.score" ID="LineComplexityVisitor.score"></a>
261 <h4>LineComplexityVisitor.score</h4> 258 <h4>LineComplexityVisitor.score</h4>
262 <b>score</b>(<i></i>) 259 <b>score</b>(<i></i>)
263
264 <p> 260 <p>
265 Public method to calculate the median. 261 Public method to calculate the median.
266 </p> 262 </p>
263
267 <dl> 264 <dl>
268 <dt>Return:</dt> 265 <dt>Return:</dt>
269 <dd> 266 <dd>
270 median line complexity value 267 median line complexity value
271 </dd> 268 </dd>
277 </dd> 274 </dd>
278 </dl> 275 </dl>
279 <a NAME="LineComplexityVisitor.sortedList" ID="LineComplexityVisitor.sortedList"></a> 276 <a NAME="LineComplexityVisitor.sortedList" ID="LineComplexityVisitor.sortedList"></a>
280 <h4>LineComplexityVisitor.sortedList</h4> 277 <h4>LineComplexityVisitor.sortedList</h4>
281 <b>sortedList</b>(<i></i>) 278 <b>sortedList</b>(<i></i>)
282
283 <p> 279 <p>
284 Public method to get a sorted list of (line, nodes) tuples. 280 Public method to get a sorted list of (line, nodes) tuples.
285 </p> 281 </p>
282
286 <dl> 283 <dl>
287 <dt>Return:</dt> 284 <dt>Return:</dt>
288 <dd> 285 <dd>
289 sorted list of (line, nodes) tuples 286 sorted list of (line, nodes) tuples
290 </dd> 287 </dd>
296 </dd> 293 </dd>
297 </dl> 294 </dl>
298 <a NAME="LineComplexityVisitor.visit" ID="LineComplexityVisitor.visit"></a> 295 <a NAME="LineComplexityVisitor.visit" ID="LineComplexityVisitor.visit"></a>
299 <h4>LineComplexityVisitor.visit</h4> 296 <h4>LineComplexityVisitor.visit</h4>
300 <b>visit</b>(<i>node</i>) 297 <b>visit</b>(<i>node</i>)
301
302 <p> 298 <p>
303 Public method to recursively visit all the nodes and add up the 299 Public method to recursively visit all the nodes and add up the
304 instructions. 300 instructions.
305 </p> 301 </p>
302
306 <dl> 303 <dl>
307 304
308 <dt><i>node</i> (ast.AST)</dt> 305 <dt><i>node</i> (ast.AST)</dt>
309 <dd> 306 <dd>
310 reference to the node 307 reference to the node

eric ide

mercurial