|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleChecker</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>eric7.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleChecker</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing the code style checker. |
|
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="#CodeStyleCheckerReport">CodeStyleCheckerReport</a></td> |
|
39 <td>Class implementing a special report to be used with our dialog.</td> |
|
40 </tr> |
|
41 </table> |
|
42 <h3>Functions</h3> |
|
43 |
|
44 <table> |
|
45 |
|
46 <tr> |
|
47 <td><a href="#__checkCodeStyle">__checkCodeStyle</a></td> |
|
48 <td>Private module function to perform the code style check and/or fix found errors.</td> |
|
49 </tr> |
|
50 <tr> |
|
51 <td><a href="#__checkSyntax">__checkSyntax</a></td> |
|
52 <td>Private module function to perform a syntax check.</td> |
|
53 </tr> |
|
54 <tr> |
|
55 <td><a href="#codeStyleBatchCheck">codeStyleBatchCheck</a></td> |
|
56 <td>Module function to check code style for a batch of files.</td> |
|
57 </tr> |
|
58 <tr> |
|
59 <td><a href="#codeStyleCheck">codeStyleCheck</a></td> |
|
60 <td>Do the code style check and/or fix found errors.</td> |
|
61 </tr> |
|
62 <tr> |
|
63 <td><a href="#extractLineFlags">extractLineFlags</a></td> |
|
64 <td>Function to extract flags starting and ending with '__' from a line comment.</td> |
|
65 </tr> |
|
66 <tr> |
|
67 <td><a href="#ignoreCode">ignoreCode</a></td> |
|
68 <td>Function to check, if the given code should be ignored as per line flags.</td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td><a href="#initBatchService">initBatchService</a></td> |
|
72 <td>Initialize the batch service and return the entry point.</td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td><a href="#initService">initService</a></td> |
|
76 <td>Initialize the service and return the entry point.</td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td><a href="#securityOk">securityOk</a></td> |
|
80 <td>Function to check, if the given code is an acknowledged security report.</td> |
|
81 </tr> |
|
82 <tr> |
|
83 <td><a href="#worker">worker</a></td> |
|
84 <td>Module function acting as the parallel worker for the style check.</td> |
|
85 </tr> |
|
86 </table> |
|
87 <hr /> |
|
88 <hr /> |
|
89 <a NAME="CodeStyleCheckerReport" ID="CodeStyleCheckerReport"></a> |
|
90 <h2>CodeStyleCheckerReport</h2> |
|
91 |
|
92 <p> |
|
93 Class implementing a special report to be used with our dialog. |
|
94 </p> |
|
95 <h3>Derived from</h3> |
|
96 pycodestyle.BaseReport |
|
97 <h3>Class Attributes</h3> |
|
98 |
|
99 <table> |
|
100 <tr><td>None</td></tr> |
|
101 </table> |
|
102 <h3>Class Methods</h3> |
|
103 |
|
104 <table> |
|
105 <tr><td>None</td></tr> |
|
106 </table> |
|
107 <h3>Methods</h3> |
|
108 |
|
109 <table> |
|
110 |
|
111 <tr> |
|
112 <td><a href="#CodeStyleCheckerReport.__init__">CodeStyleCheckerReport</a></td> |
|
113 <td>Constructor</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#CodeStyleCheckerReport.error_args">error_args</a></td> |
|
117 <td>Public method to collect the error messages.</td> |
|
118 </tr> |
|
119 </table> |
|
120 <h3>Static Methods</h3> |
|
121 |
|
122 <table> |
|
123 <tr><td>None</td></tr> |
|
124 </table> |
|
125 |
|
126 <a NAME="CodeStyleCheckerReport.__init__" ID="CodeStyleCheckerReport.__init__"></a> |
|
127 <h4>CodeStyleCheckerReport (Constructor)</h4> |
|
128 <b>CodeStyleCheckerReport</b>(<i>options</i>) |
|
129 |
|
130 <p> |
|
131 Constructor |
|
132 </p> |
|
133 <dl> |
|
134 |
|
135 <dt><i>options</i></dt> |
|
136 <dd> |
|
137 options for the report (optparse.Values) |
|
138 </dd> |
|
139 </dl> |
|
140 <a NAME="CodeStyleCheckerReport.error_args" ID="CodeStyleCheckerReport.error_args"></a> |
|
141 <h4>CodeStyleCheckerReport.error_args</h4> |
|
142 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>) |
|
143 |
|
144 <p> |
|
145 Public method to collect the error messages. |
|
146 </p> |
|
147 <dl> |
|
148 |
|
149 <dt><i>line_number</i></dt> |
|
150 <dd> |
|
151 line number of the issue (integer) |
|
152 </dd> |
|
153 <dt><i>offset</i></dt> |
|
154 <dd> |
|
155 position within line of the issue (integer) |
|
156 </dd> |
|
157 <dt><i>code</i></dt> |
|
158 <dd> |
|
159 message code (string) |
|
160 </dd> |
|
161 <dt><i>check</i></dt> |
|
162 <dd> |
|
163 reference to the checker function (function) |
|
164 </dd> |
|
165 <dt><i>args</i></dt> |
|
166 <dd> |
|
167 arguments for the message (list) |
|
168 </dd> |
|
169 </dl> |
|
170 <dl> |
|
171 <dt>Return:</dt> |
|
172 <dd> |
|
173 error code (string) |
|
174 </dd> |
|
175 </dl> |
|
176 <div align="right"><a href="#top">Up</a></div> |
|
177 <hr /> |
|
178 <hr /> |
|
179 <a NAME="__checkCodeStyle" ID="__checkCodeStyle"></a> |
|
180 <h2>__checkCodeStyle</h2> |
|
181 <b>__checkCodeStyle</b>(<i>filename, source, args</i>) |
|
182 |
|
183 <p> |
|
184 Private module function to perform the code style check and/or fix |
|
185 found errors. |
|
186 </p> |
|
187 <dl> |
|
188 |
|
189 <dt><i>filename</i> (str)</dt> |
|
190 <dd> |
|
191 source filename |
|
192 </dd> |
|
193 <dt><i>source</i> (str)</dt> |
|
194 <dd> |
|
195 string containing the code to check |
|
196 </dd> |
|
197 <dt><i>args</i> (list of (str, str, bool, str, str, bool, int, list of (int, int),)</dt> |
|
198 <dd> |
|
199 arguments used by the codeStyleCheck function (list of |
|
200 excludeMessages, includeMessages, repeatMessages, fixCodes, |
|
201 noFixCodes, fixIssues, maxLineLength, maxDocLineLength, blankLines, |
|
202 hangClosing, docType, codeComplexityArgs, miscellaneousArgs, |
|
203 annotationArgs, securityArgs, errors, eol, encoding, backup) |
|
204 bool, str, dict, dict, dict, list of str, str, str, bool) |
|
205 </dd> |
|
206 </dl> |
|
207 <dl> |
|
208 <dt>Return:</dt> |
|
209 <dd> |
|
210 tuple of statistics data and list of result dictionaries with |
|
211 keys: |
|
212 <ul> |
|
213 <li>file: file name</li> |
|
214 <li>line: line_number</li> |
|
215 <li>offset: offset within line</li> |
|
216 <li>code: message code</li> |
|
217 <li>args: list of arguments to format the message</li> |
|
218 <li>ignored: flag indicating this issue was ignored</li> |
|
219 <li>fixed: flag indicating this issue was fixed</li> |
|
220 <li>autofixing: flag indicating that a fix can be done</li> |
|
221 <li>fixcode: message code for the fix</li> |
|
222 <li>fixargs: list of arguments to format the fix message</li> |
|
223 </ul> |
|
224 </dd> |
|
225 </dl> |
|
226 <dl> |
|
227 <dt>Return Type:</dt> |
|
228 <dd> |
|
229 tuple of (dict, list of dict) |
|
230 </dd> |
|
231 </dl> |
|
232 <div align="right"><a href="#top">Up</a></div> |
|
233 <hr /> |
|
234 <hr /> |
|
235 <a NAME="__checkSyntax" ID="__checkSyntax"></a> |
|
236 <h2>__checkSyntax</h2> |
|
237 <b>__checkSyntax</b>(<i>filename, source</i>) |
|
238 |
|
239 <p> |
|
240 Private module function to perform a syntax check. |
|
241 </p> |
|
242 <dl> |
|
243 |
|
244 <dt><i>filename</i> (str)</dt> |
|
245 <dd> |
|
246 source filename |
|
247 </dd> |
|
248 <dt><i>source</i> (str)</dt> |
|
249 <dd> |
|
250 string containing the code to check |
|
251 </dd> |
|
252 </dl> |
|
253 <dl> |
|
254 <dt>Return:</dt> |
|
255 <dd> |
|
256 tuple containing the error dictionary with syntax error details, |
|
257 a statistics dictionary and None or a tuple containing two None and |
|
258 the generated AST tree |
|
259 </dd> |
|
260 </dl> |
|
261 <dl> |
|
262 <dt>Return Type:</dt> |
|
263 <dd> |
|
264 tuple of (dict, dict, None) or tuple of (None, None, ast.Module) |
|
265 </dd> |
|
266 </dl> |
|
267 <div align="right"><a href="#top">Up</a></div> |
|
268 <hr /> |
|
269 <hr /> |
|
270 <a NAME="codeStyleBatchCheck" ID="codeStyleBatchCheck"></a> |
|
271 <h2>codeStyleBatchCheck</h2> |
|
272 <b>codeStyleBatchCheck</b>(<i>argumentsList, send, fx, cancelled, maxProcesses=0</i>) |
|
273 |
|
274 <p> |
|
275 Module function to check code style for a batch of files. |
|
276 </p> |
|
277 <dl> |
|
278 |
|
279 <dt><i>argumentsList</i> (list)</dt> |
|
280 <dd> |
|
281 list of arguments tuples as given for codeStyleCheck |
|
282 </dd> |
|
283 <dt><i>send</i> (func)</dt> |
|
284 <dd> |
|
285 reference to send function |
|
286 </dd> |
|
287 <dt><i>fx</i> (str)</dt> |
|
288 <dd> |
|
289 registered service name |
|
290 </dd> |
|
291 <dt><i>cancelled</i> (func)</dt> |
|
292 <dd> |
|
293 reference to function checking for a cancellation |
|
294 </dd> |
|
295 <dt><i>maxProcesses</i> (int)</dt> |
|
296 <dd> |
|
297 number of processes to be used |
|
298 </dd> |
|
299 </dl> |
|
300 <div align="right"><a href="#top">Up</a></div> |
|
301 <hr /> |
|
302 <hr /> |
|
303 <a NAME="codeStyleCheck" ID="codeStyleCheck"></a> |
|
304 <h2>codeStyleCheck</h2> |
|
305 <b>codeStyleCheck</b>(<i>filename, source, args</i>) |
|
306 |
|
307 <p> |
|
308 Do the code style check and/or fix found errors. |
|
309 </p> |
|
310 <dl> |
|
311 |
|
312 <dt><i>filename</i> (str)</dt> |
|
313 <dd> |
|
314 source filename |
|
315 </dd> |
|
316 <dt><i>source</i> (str)</dt> |
|
317 <dd> |
|
318 string containing the code to check |
|
319 </dd> |
|
320 <dt><i>args</i> (list of (str, str, bool, str, str, bool, int, list of (int, int),)</dt> |
|
321 <dd> |
|
322 arguments used by the codeStyleCheck function (list of |
|
323 excludeMessages, includeMessages, repeatMessages, fixCodes, |
|
324 noFixCodes, fixIssues, maxLineLength, maxDocLineLength, blankLines, |
|
325 hangClosing, docType, codeComplexityArgs, miscellaneousArgs, errors, |
|
326 eol, encoding, backup) |
|
327 bool, str, dict, dict, list of str, str, str, bool) |
|
328 </dd> |
|
329 </dl> |
|
330 <dl> |
|
331 <dt>Return:</dt> |
|
332 <dd> |
|
333 tuple of statistics (dict) and list of results (tuple for each |
|
334 found violation of style (lineno, position, text, ignored, fixed, |
|
335 autofixing, fixedMsg)) |
|
336 </dd> |
|
337 </dl> |
|
338 <dl> |
|
339 <dt>Return Type:</dt> |
|
340 <dd> |
|
341 tuple of (dict, list of tuples of (int, int, str, bool, bool, bool, |
|
342 str)) |
|
343 </dd> |
|
344 </dl> |
|
345 <div align="right"><a href="#top">Up</a></div> |
|
346 <hr /> |
|
347 <hr /> |
|
348 <a NAME="extractLineFlags" ID="extractLineFlags"></a> |
|
349 <h2>extractLineFlags</h2> |
|
350 <b>extractLineFlags</b>(<i>line, startComment="</i>) |
|
351 |
|
352 <p> |
|
353 Function to extract flags starting and ending with '__' from a line |
|
354 comment. |
|
355 </p> |
|
356 <dl> |
|
357 |
|
358 <dt><i>line</i></dt> |
|
359 <dd> |
|
360 line to extract flags from (string) |
|
361 </dd> |
|
362 <dt><i>startComment</i></dt> |
|
363 <dd> |
|
364 string identifying the start of the comment (string) |
|
365 </dd> |
|
366 <dt><i>endComment</i></dt> |
|
367 <dd> |
|
368 string identifying the end of a comment (string) |
|
369 </dd> |
|
370 <dt><i>flagsLine</i></dt> |
|
371 <dd> |
|
372 flag indicating to check for a flags only line (bool) |
|
373 </dd> |
|
374 </dl> |
|
375 <dl> |
|
376 <dt>Return:</dt> |
|
377 <dd> |
|
378 list containing the extracted flags (list of strings) |
|
379 </dd> |
|
380 </dl> |
|
381 <div align="right"><a href="#top">Up</a></div> |
|
382 <hr /> |
|
383 <hr /> |
|
384 <a NAME="ignoreCode" ID="ignoreCode"></a> |
|
385 <h2>ignoreCode</h2> |
|
386 <b>ignoreCode</b>(<i>code, lineFlags</i>) |
|
387 |
|
388 <p> |
|
389 Function to check, if the given code should be ignored as per line flags. |
|
390 </p> |
|
391 <dl> |
|
392 |
|
393 <dt><i>code</i> (str)</dt> |
|
394 <dd> |
|
395 error code to be checked |
|
396 </dd> |
|
397 <dt><i>lineFlags</i> (list of str)</dt> |
|
398 <dd> |
|
399 list of line flags to check against |
|
400 </dd> |
|
401 </dl> |
|
402 <dl> |
|
403 <dt>Return:</dt> |
|
404 <dd> |
|
405 flag indicating to ignore the code |
|
406 </dd> |
|
407 </dl> |
|
408 <dl> |
|
409 <dt>Return Type:</dt> |
|
410 <dd> |
|
411 bool |
|
412 </dd> |
|
413 </dl> |
|
414 <div align="right"><a href="#top">Up</a></div> |
|
415 <hr /> |
|
416 <hr /> |
|
417 <a NAME="initBatchService" ID="initBatchService"></a> |
|
418 <h2>initBatchService</h2> |
|
419 <b>initBatchService</b>(<i></i>) |
|
420 |
|
421 <p> |
|
422 Initialize the batch service and return the entry point. |
|
423 </p> |
|
424 <dl> |
|
425 <dt>Return:</dt> |
|
426 <dd> |
|
427 the entry point for the background client (function) |
|
428 </dd> |
|
429 </dl> |
|
430 <div align="right"><a href="#top">Up</a></div> |
|
431 <hr /> |
|
432 <hr /> |
|
433 <a NAME="initService" ID="initService"></a> |
|
434 <h2>initService</h2> |
|
435 <b>initService</b>(<i></i>) |
|
436 |
|
437 <p> |
|
438 Initialize the service and return the entry point. |
|
439 </p> |
|
440 <dl> |
|
441 <dt>Return:</dt> |
|
442 <dd> |
|
443 the entry point for the background client (function) |
|
444 </dd> |
|
445 </dl> |
|
446 <div align="right"><a href="#top">Up</a></div> |
|
447 <hr /> |
|
448 <hr /> |
|
449 <a NAME="securityOk" ID="securityOk"></a> |
|
450 <h2>securityOk</h2> |
|
451 <b>securityOk</b>(<i>code, lineFlags</i>) |
|
452 |
|
453 <p> |
|
454 Function to check, if the given code is an acknowledged security report. |
|
455 </p> |
|
456 <dl> |
|
457 |
|
458 <dt><i>code</i> (str)</dt> |
|
459 <dd> |
|
460 error code to be checked |
|
461 </dd> |
|
462 <dt><i>lineFlags</i> (list of str)</dt> |
|
463 <dd> |
|
464 list of line flags to check against |
|
465 </dd> |
|
466 </dl> |
|
467 <dl> |
|
468 <dt>Return:</dt> |
|
469 <dd> |
|
470 flag indicating an acknowledged security report |
|
471 </dd> |
|
472 </dl> |
|
473 <dl> |
|
474 <dt>Return Type:</dt> |
|
475 <dd> |
|
476 bool |
|
477 </dd> |
|
478 </dl> |
|
479 <div align="right"><a href="#top">Up</a></div> |
|
480 <hr /> |
|
481 <hr /> |
|
482 <a NAME="worker" ID="worker"></a> |
|
483 <h2>worker</h2> |
|
484 <b>worker</b>(<i>inputQueue, outputQueue</i>) |
|
485 |
|
486 <p> |
|
487 Module function acting as the parallel worker for the style check. |
|
488 </p> |
|
489 <dl> |
|
490 |
|
491 <dt><i>inputQueue</i></dt> |
|
492 <dd> |
|
493 input queue (multiprocessing.Queue) |
|
494 </dd> |
|
495 <dt><i>outputQueue</i></dt> |
|
496 <dd> |
|
497 output queue (multiprocessing.Queue) |
|
498 </dd> |
|
499 </dl> |
|
500 <div align="right"><a href="#top">Up</a></div> |
|
501 <hr /> |
|
502 </body></html> |