Pylint plugin for Odoo
Project description
Pylint Odoo plugin
Enable custom checks for Odoo modules.
Code |
Description |
Short name |
---|---|---|
C7902 |
Missing ./README.rst file. Template here: %s |
missing-readme |
C8101 |
One of the following authors must be present in manifest: %s |
manifest-required-author |
C8102 |
Missing required key “%s” in manifest file |
manifest-required-key |
C8103 |
Deprecated key “%s” in manifest file |
manifest-deprecated-key |
C8104 |
Use CamelCase “%s” in class name “%s”. You can use oca-autopep8 of https://github.com/OCA/maintainer-tools to auto fix it. |
class-camelcase |
C8105 |
License “%s” not allowed in manifest file. |
license-allowed |
C8106 |
Wrong Version Format “%s” in manifest file. Regex to match: “%s” |
manifest-version-format |
C8107 |
String parameter on “%s” requires translation. Use %s_(%s) |
translation-required |
C8108 |
Name of compute method should start with “_compute_” |
method-compute |
C8109 |
Name of search method should start with “_search_” |
method-search |
C8110 |
Name of inverse method should start with “_inverse_” |
method-inverse |
C8111 |
Manifest key development_status “%s” not allowed |
development-status-allowed |
C8201 |
No UTF-8 coding comment found: Use # coding: utf-8 or # -*- coding: utf-8 -*- |
no-utf8-coding-comment |
C8202 |
UTF-8 coding is not necessary |
unnecessary-utf8-coding-comment |
E7901 |
%s %s |
rst-syntax-error |
E7902 |
%s error: %s |
xml-syntax-error |
E8101 |
The author key in the manifest file must be a string (with comma separated values) |
manifest-author-string |
E8102 |
Use of cr.commit() directly - More info https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#never-commit-the-transaction |
invalid-commit |
E8103 |
SQL injection risk. Use parameters if you can. - More info https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#no-sql-injection |
sql-injection |
F8101 |
File “%s”: “%s” not found. |
resource-not-exist |
R7980 |
Consider merging classes inherited to “%s” from %s. |
consider-merging-classes-inherited |
R8101 |
Import Warning should be renamed as UserError from openerp.exceptions import Warning as UserError |
openerp-exception-warning |
R8110 |
Method defined with old api version 7 |
old-api7-method-defined |
W7901 |
%s Dangerous filter without explicit user_id in xml_id %s |
dangerous-filter-wo-user |
W7902 |
%s Duplicate xml record id “%s” in %s |
duplicate-xml-record-id |
W7903 |
%s |
javascript-lint |
W7904 |
%s Deprecated <openerp> xml node |
deprecated-openerp-xml-node |
W7905 |
%s record res.users without context=”{‘no_reset_password’: True}” |
create-user-wo-reset-password |
W7906 |
%s Duplicate id “%s” |
duplicate-id-csv |
W7907 |
%s Duplicate xml field “%s” in lines %s |
duplicate-xml-fields |
W7908 |
%s Missing newline |
missing-newline-extrafiles |
W7909 |
%s Redundant name module reference in xml_ids “%s”. |
redundant-modulename-xml |
W7910 |
%s Use wrong tabs indentation instead of four spaces |
wrong-tabs-instead-of-spaces |
W7930 |
%s not used from manifest |
file-not-used |
W7935 |
External dependency “%s” without ImportError. More info: https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#external-dependencies |
missing-import-error |
W7936 |
Missing external dependency “%s” from manifest. More info: https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#external-dependencies |
missing-manifest-dependency |
W7937 |
%s The xml attribute is missing the translation=”off” tag %s |
xml-attribute-translatable |
W7938 |
pass into block except. If you really need to use the pass consider logging that exception |
except-pass |
W7939 |
%s Use <odoo> instead of <odoo><data> or use <odoo noupdate=”1”>instead of <odoo><data noupdate=”1”> |
deprecated-data-xml-node |
W7940 |
%s Dangerous use of “replace” from view with priority %s < %s |
dangerous-view-replace-wo-priority |
W7942 |
%s Deprecated <tree> xml attribute “%s” |
xml-deprecated-tree-attribute |
W7943 |
%s Deprecated QWeb directive “%s”. Use “t-options” instead |
xml-deprecated-qweb-directive |
W7944 |
%s The resource in in src/href contains a not valid chararter |
character-not-valid-in-resource-link |
W7950 |
Same Odoo module absolute import. You should use relative import with “.” instead of “openerp.addons.%s” |
odoo-addons-relative-import |
W8101 |
Detected api.one and api.multi decorators together. |
api-one-multi-together |
W8102 |
Missing api.one or api.multi in copy function. |
copy-wo-api-one |
W8103 |
Translation method _(“string”) in fields is not necessary. |
translation-field |
W8104 |
api.one deprecated |
api-one-deprecated |
W8105 |
attribute “%s” deprecated |
attribute-deprecated |
W8106 |
Missing super call in “%s” method. |
method-required-super |
W8110 |
Missing return (super is used) in method %s. |
missing-return |
W8111 |
Field parameter “%s” is no longer supported. Use “%s” instead. |
renamed-field-parameter |
W8112 |
“eval” referenced detected. |
eval-referenced |
W8113 |
The attribute string is redundant. String parameter equal to name of variable |
attribute-string-redundant |
W8114 |
Website “%s” in manifest key is not a valid URI |
website-manifest-key-not-valid-uri |
W8115 |
Translatable term in “%s” contains variables. Use %s instead |
translation-contains-variable |
W8116 |
Print used. Use logger instead. |
print-used |
W8201 |
You have a python file with execution permissions but you don’t have an interpreter magic comment, or a magic comment but no execution permission. If you really needs a execution permission then add a magic comment ( https://en.wikipedia.org/wiki/Shebang_(Unix) ). If you don’t needs a execution permission then remove it with: chmod -x %s |
incoherent-interpreter-exec-perm |
W8202 |
Use of vim comment |
use-vim-comment |
Install
# pip install --upgrade git+https://github.com/oca/pylint-odoo.git
Or
# pip install --upgrade --pre pylint-odoo
Usage
pylint --load-plugins=pylint_odoo -e odoolint ...
Example to test just odoo-lint case:
touch {ADDONS-PATH}/__init__.py
pylint --load-plugins=pylint_odoo -d all -e odoolint {ADDONS-PATH}
If you have external files you can add them in examples folder to skip.
For rst-syntax-error skip unknown directives
Skip one check based on the Odoo version
If you need to restrict a check to specific version(s) of Odoo, use the new variable odoo_check_versions
For example, if you have one new check your-new-check and you need to run it only if the Odoo version is between 9.0 and 11.0, inside the class you should declare the following :
...
class FormatChecker(PylintOdooTokenChecker):
...
odoo_check_versions = {
'your-new-check': {
'min_odoo_version': '9.0',
'max_odoo_version': '10.0',
}
}
...
Skip one xml check
If you need to skip one check in one xml file you can use the follow way
<?xml version="1.0" encoding="utf-8"?>
<!-- pylint:disable=name-of-check-to-skip -->
<odoo>
...
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<!-- pylint:disable=name-of-check-to-skip, second-name-check-to-skip -->
<odoo>
...
</odoo>
This skip only work with the name of the check, not work with the name of check
The position of the comment it is not relative to the line that throw the check
CHANGES
3.1.0
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[FIX] rst_lint: Using UTF-8 encoding by default (#272)
[REF] .travis.yml: Using py3.7 stable instead of dev (#271)
Improve incoherent-interpreter-exec-perm message
Fix incompatibility with isort configuration file
[FIX] rst-syntax-error: Using a 0 by default if line None is returned
3.0.3
[REF] README: Auto-update Using pylint_odoo.messages2rst()
Revert “[ADD] method-default prefix” (#254)
3.0.2
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[REF] CI: Fixing flake8, tests and clean requirements
[REF] pylint_odoo: Supports odoo 13.0
[ADD] method-default prefix
[FIX] .travis.yml: Upgrade nvm version supported for eslint
Allow console statements
[ADD] print-used: Use _logger instead of print (#241)
3.0.1
[FIX] AttributeError: ‘MessagesStore’ object has no attribute ‘_messages’ related to https://github.com/PyCQA/pylint/commit/75cecdb1b88cc759223e83fd325aeafd09fec37e
[IMP] added support Pylint 2.3.0 and Astroid 2.2.0
3.0.0
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[REF] sql-injection: Test private attributes (#226)
[REF] tox: Upgrade new pylint for py3 (#215)
2.0.2
[REF] manifest-required-authors: Support old deprecated parameter
2.0.1
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[DEL] require-jsdoc, keep require-valid-jsdoc
[FIX]change the location of Guidelines URL
[ADD] development-status-allowed: New check to verity valid development status Fix https://github.com/OCA/pylint-odoo/issues/199
[REF] missing-import-error: Check enabled just for odoo <= 11.0
Add fuzzy to ES globals
Allow usage of `undefined` (#214)
Jslint jsdoc relax (#209)
[REF] pylint-odoo: Compatibility with python3.7 (#205)
[IMP] file-not-used: Ignore unused files into the migrations directory (#213)
[IMP] manifest-required-author: Allow multiple possible required authors
[FIX] missing-manifest-dependency: Exclude tests directory
[FIX] manifest-version-format: Don’t ignore valid Odoo versions
[FIX] requirements: Include “six” package (#207)
2.0.0
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[DOC] README.rst: Adding documentation to the way to skip one check based on the Odoo Version
[REF] requirements: Bump requirements version
Add _register_hook in “no missing return” methods (#201)
[ADD] Add new lint to detect variables within translatable strings (#198)
[FIX] translation-required: Fix some false positives (#196)
[REF] .travis.yml: Allow both W503 and W504 formats (#197)
1.9.5
[REF] .travis.yml: Just deploy a env and avoid cleanup before to deploy
1.9.4
[REF] pylint_odoo: Increase coverage test
[FIX] README.rst: Fix syntax and run check
[FIX] don’t complain about string attribute nodes in translation check
[REF] javascript-lint: Allow to use moment (#189)
Allow short ternary expressions
[IMP] ESLint usability boost (#185)
[REF] javascript-lint: Emit a message if there is internal error
[REF] jslintrc: Use of property style for dot-location
[REF] The method message_post need the subject and body be translatable
[FIX] duplicate-xml-fields: Now consider as duplicated using domain and context values (#172)
1.9.3
[REF] pylint_odoo: Use check-name instead of check-code for add_message method (#174)
[FIX] pylint_odoo: Change the number of the appearances of the check (#173)
[REF] README: Auto-update Using pylint_odoo.messages2rst()
[ADD] unnecessary-utf8-coding-comment: The utf8 comment is unnecessary if the version of odoo is 11.0 because use py3 (#168)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.