A 'Python code analyzer' error checking pass should be a must before each commit
A 'Python code analyzer' error checking pass should be *a must* before each commit.
There are several of such code analyzers for Python:
* PyLint - http://
* PyChecker - http://
* PyFlakes - https:/
They let "a dynamic language such as Python where not even a compiler checks the code" (https:/
For example with PyLint (wich we use) you can get reports like this one on any module (audittrail module in the example):
Command (report errors only):
''
$ cd openerp-
$ pylint -e --include-ids=y --max-line-
''
Output:
''
************* Module addons.
E1101: 92:audittrail_
''
Command (report errors, warnings, conventions...):
''
$ cd openerp-
$ pylint --include-ids=y --max-line-
''
Output (just a bit of it as an example):
''
************* Module addons.audittrail
C0111: 1: Missing docstring
W0406: 22: Module import itself
************* Module addons.
W0311:133: Bad indentation. Found 12 spaces, expected 4
W0311:134: Bad indentation. Found 12 spaces, expected 4
...
W0311:145: Bad indentation. Found 24 spaces, expected 16
W0311:146: Bad indentation. Found 28 spaces, expected 20
...
W0631: 90:audittrail_
E1101: 92:audittrail_
W0612: 92:audittrail_
...
W0621:134:
W0622:132:
W0622:153:
...
W0212:164:
W0212:167:
R0912:132:
W0612:137:
W0621:173:
W0621:180:
W0622:171:
W0622:171:
...
W0612:315:
C0103:345: Invalid name "obj" (should match (([A-Z_
W0611: 28: Unused import string
W0611: 29: Unused import copy
...
Report
======
254 statements analysed.
Raw metrics
-----------
+------
|type |number |% |previous |difference |
+======
|code |281 |62.17 |281 |= |
+------
|docstring |64 |14.16 |64 |= |
+------
|comment |85 |18.81 |85 |= |
+------
|empty |22 |4.87 |22 |= |
+------
Duplication
-----------
+------
| |now |previous |difference |
+======
|nb duplicated lines |0 |0 |= |
+------
|percent duplicated lines |0.000 |0.000 |= |
+------
External dependencies
-------
::
ir (addons.
wizard (addons.
osv
\-fields (addons.
\-osv (addons.
pooler (addons.
addons
\-wizard (addons.audittrail)
\-audittrail
netsvc (addons.
Statistics by type
------------------
+------
|type |number |old number |difference |%documented |%badname |
+======
|module |4 |4 |= |0.00 |0.00 |
+------
|class |4 |4 |= |0.00 |0.00 |
+------
|method |3 |3 |= |0.00 |0.00 |
+------
|function |6 |6 |= |0.00 |0.00 |
+------
Messages by category
-------
+------
|type |number |previous |difference |
+======
|convention |110 |110 |= |
+------
|refactor |6 |6 |= |
+------
|warning |185 |185 |= |
+------
|error |1 |1 |= |
+------
% errors / warnings by module
-------
+------
|module |error |warning |refactor |convention |
+======
|addons.
+------
|addons.
+------
|addons.audittrail |0.00 |0.54 |0.00 |0.91 |
+------
Messages
--------
+------
|message id |occurences |
+======
|W0311 |140 |
+------
|C0322 |73 |
+------
|C0111 |17 |
+------
|C0324 |14 |
+------
...
+------
|C0301 |1 |
+------
Global evaluation
-----------------
Your code has been rated at -2.05/10 (previous run: -2.05/10)
''
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- New
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by