eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker.html

changeset 7784
3257703e10c5
child 7989
a21d673a8f99
equal deleted inserted replaced
7783:36f66ce496bd 7784:3257703e10c5
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body>
22 <a NAME="top" ID="top"></a>
23 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Complexity.ComplexityChecker</h1>
24
25 <p>
26 Module implementing a checker for code complexity.
27 </p>
28 <h3>Global Attributes</h3>
29
30 <table>
31 <tr><td>None</td></tr>
32 </table>
33 <h3>Classes</h3>
34
35 <table>
36
37 <tr>
38 <td><a href="#ComplexityChecker">ComplexityChecker</a></td>
39 <td>Class implementing a checker for code complexity.</td>
40 </tr>
41 <tr>
42 <td><a href="#LineComplexityVisitor">LineComplexityVisitor</a></td>
43 <td>Class calculating the number of AST nodes per line of code and the median nodes/line score.</td>
44 </tr>
45 </table>
46 <h3>Functions</h3>
47
48 <table>
49 <tr><td>None</td></tr>
50 </table>
51 <hr />
52 <hr />
53 <a NAME="ComplexityChecker" ID="ComplexityChecker"></a>
54 <h2>ComplexityChecker</h2>
55
56 <p>
57 Class implementing a checker for code complexity.
58 </p>
59 <h3>Derived from</h3>
60 object
61 <h3>Class Attributes</h3>
62
63 <table>
64 <tr><td>Codes</td></tr>
65 </table>
66 <h3>Class Methods</h3>
67
68 <table>
69 <tr><td>None</td></tr>
70 </table>
71 <h3>Methods</h3>
72
73 <table>
74
75 <tr>
76 <td><a href="#ComplexityChecker.__init__">ComplexityChecker</a></td>
77 <td>Constructor</td>
78 </tr>
79 <tr>
80 <td><a href="#ComplexityChecker.__checkLineComplexity">__checkLineComplexity</a></td>
81 <td>Private method to check the complexity of a single line of code and the median line complexity of the source code.</td>
82 </tr>
83 <tr>
84 <td><a href="#ComplexityChecker.__checkMcCabeComplexity">__checkMcCabeComplexity</a></td>
85 <td>Private method to check the McCabe code complexity.</td>
86 </tr>
87 <tr>
88 <td><a href="#ComplexityChecker.__error">__error</a></td>
89 <td>Private method to record an issue.</td>
90 </tr>
91 <tr>
92 <td><a href="#ComplexityChecker.__ignoreCode">__ignoreCode</a></td>
93 <td>Private method to check if the message code should be ignored.</td>
94 </tr>
95 <tr>
96 <td><a href="#ComplexityChecker.__reportInvalidSyntax">__reportInvalidSyntax</a></td>
97 <td>Private method to report a syntax error.</td>
98 </tr>
99 <tr>
100 <td><a href="#ComplexityChecker.run">run</a></td>
101 <td>Public method to check the given source for code complexity.</td>
102 </tr>
103 </table>
104 <h3>Static Methods</h3>
105
106 <table>
107 <tr><td>None</td></tr>
108 </table>
109
110 <a NAME="ComplexityChecker.__init__" ID="ComplexityChecker.__init__"></a>
111 <h4>ComplexityChecker (Constructor)</h4>
112 <b>ComplexityChecker</b>(<i>source, filename, select, ignore, args</i>)
113
114 <p>
115 Constructor
116 </p>
117 <dl>
118
119 <dt><i>source</i> (list of str)</dt>
120 <dd>
121 source code to be checked
122 </dd>
123 <dt><i>filename</i> (str)</dt>
124 <dd>
125 name of the source file
126 </dd>
127 <dt><i>select</i> (list of str)</dt>
128 <dd>
129 list of selected codes
130 </dd>
131 <dt><i>ignore</i> (list of str)</dt>
132 <dd>
133 list of codes to be ignored
134 </dd>
135 <dt><i>args</i> (dict)</dt>
136 <dd>
137 dictionary of arguments for the miscellaneous checks
138 </dd>
139 </dl>
140 <a NAME="ComplexityChecker.__checkLineComplexity" ID="ComplexityChecker.__checkLineComplexity"></a>
141 <h4>ComplexityChecker.__checkLineComplexity</h4>
142 <b>__checkLineComplexity</b>(<i></i>)
143
144 <p>
145 Private method to check the complexity of a single line of code and
146 the median line complexity of the source code.
147 </p>
148 <p>
149 Complexity is defined as the number of AST nodes produced by a line
150 of code.
151 </p>
152 <a NAME="ComplexityChecker.__checkMcCabeComplexity" ID="ComplexityChecker.__checkMcCabeComplexity"></a>
153 <h4>ComplexityChecker.__checkMcCabeComplexity</h4>
154 <b>__checkMcCabeComplexity</b>(<i></i>)
155
156 <p>
157 Private method to check the McCabe code complexity.
158 </p>
159 <a NAME="ComplexityChecker.__error" ID="ComplexityChecker.__error"></a>
160 <h4>ComplexityChecker.__error</h4>
161 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
162
163 <p>
164 Private method to record an issue.
165 </p>
166 <dl>
167
168 <dt><i>lineNumber</i> (int)</dt>
169 <dd>
170 line number of the issue
171 </dd>
172 <dt><i>offset</i> (int)</dt>
173 <dd>
174 position within line of the issue
175 </dd>
176 <dt><i>code</i> (str)</dt>
177 <dd>
178 message code
179 </dd>
180 <dt><i>args</i> (list)</dt>
181 <dd>
182 arguments for the message
183 </dd>
184 </dl>
185 <a NAME="ComplexityChecker.__ignoreCode" ID="ComplexityChecker.__ignoreCode"></a>
186 <h4>ComplexityChecker.__ignoreCode</h4>
187 <b>__ignoreCode</b>(<i>code</i>)
188
189 <p>
190 Private method to check if the message code should be ignored.
191 </p>
192 <dl>
193
194 <dt><i>code</i> (str)</dt>
195 <dd>
196 message code to check for
197 </dd>
198 </dl>
199 <dl>
200 <dt>Returns:</dt>
201 <dd>
202 flag indicating to ignore the given code
203 </dd>
204 </dl>
205 <dl>
206 <dt>Return Type:</dt>
207 <dd>
208 bool
209 </dd>
210 </dl>
211 <a NAME="ComplexityChecker.__reportInvalidSyntax" ID="ComplexityChecker.__reportInvalidSyntax"></a>
212 <h4>ComplexityChecker.__reportInvalidSyntax</h4>
213 <b>__reportInvalidSyntax</b>(<i></i>)
214
215 <p>
216 Private method to report a syntax error.
217 </p>
218 <a NAME="ComplexityChecker.run" ID="ComplexityChecker.run"></a>
219 <h4>ComplexityChecker.run</h4>
220 <b>run</b>(<i></i>)
221
222 <p>
223 Public method to check the given source for code complexity.
224 </p>
225 <div align="right"><a href="#top">Up</a></div>
226 <hr />
227 <hr />
228 <a NAME="LineComplexityVisitor" ID="LineComplexityVisitor"></a>
229 <h2>LineComplexityVisitor</h2>
230
231 <p>
232 Class calculating the number of AST nodes per line of code
233 and the median nodes/line score.
234 </p>
235 <h3>Derived from</h3>
236 ast.NodeVisitor
237 <h3>Class Attributes</h3>
238
239 <table>
240 <tr><td>None</td></tr>
241 </table>
242 <h3>Class Methods</h3>
243
244 <table>
245 <tr><td>None</td></tr>
246 </table>
247 <h3>Methods</h3>
248
249 <table>
250
251 <tr>
252 <td><a href="#LineComplexityVisitor.__init__">LineComplexityVisitor</a></td>
253 <td>Constructor</td>
254 </tr>
255 <tr>
256 <td><a href="#LineComplexityVisitor.score">score</a></td>
257 <td>Public method to calculate the median.</td>
258 </tr>
259 <tr>
260 <td><a href="#LineComplexityVisitor.sortedList">sortedList</a></td>
261 <td>Public method to get a sorted list of (line, nodes) tuples.</td>
262 </tr>
263 <tr>
264 <td><a href="#LineComplexityVisitor.visit">visit</a></td>
265 <td>Public method to recursively visit all the nodes and add up the instructions.</td>
266 </tr>
267 </table>
268 <h3>Static Methods</h3>
269
270 <table>
271 <tr><td>None</td></tr>
272 </table>
273
274 <a NAME="LineComplexityVisitor.__init__" ID="LineComplexityVisitor.__init__"></a>
275 <h4>LineComplexityVisitor (Constructor)</h4>
276 <b>LineComplexityVisitor</b>(<i></i>)
277
278 <p>
279 Constructor
280 </p>
281 <a NAME="LineComplexityVisitor.score" ID="LineComplexityVisitor.score"></a>
282 <h4>LineComplexityVisitor.score</h4>
283 <b>score</b>(<i></i>)
284
285 <p>
286 Public method to calculate the median.
287 </p>
288 <dl>
289 <dt>Returns:</dt>
290 <dd>
291 median line complexity value
292 </dd>
293 </dl>
294 <dl>
295 <dt>Return Type:</dt>
296 <dd>
297 float
298 </dd>
299 </dl>
300 <a NAME="LineComplexityVisitor.sortedList" ID="LineComplexityVisitor.sortedList"></a>
301 <h4>LineComplexityVisitor.sortedList</h4>
302 <b>sortedList</b>(<i></i>)
303
304 <p>
305 Public method to get a sorted list of (line, nodes) tuples.
306 </p>
307 <dl>
308 <dt>Returns:</dt>
309 <dd>
310 sorted list of (line, nodes) tuples
311 </dd>
312 </dl>
313 <dl>
314 <dt>Return Type:</dt>
315 <dd>
316 list of tuple of (int,int)
317 </dd>
318 </dl>
319 <a NAME="LineComplexityVisitor.visit" ID="LineComplexityVisitor.visit"></a>
320 <h4>LineComplexityVisitor.visit</h4>
321 <b>visit</b>(<i>node</i>)
322
323 <p>
324 Public method to recursively visit all the nodes and add up the
325 instructions.
326 </p>
327 <dl>
328
329 <dt><i>node</i> (ast.AST)</dt>
330 <dd>
331 reference to the node
332 </dd>
333 </dl>
334 <div align="right"><a href="#top">Up</a></div>
335 <hr />
336 </body></html>

eric ide

mercurial