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

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

eric ide

mercurial