Skip to main content

Pylint plugin for Odoo

Project description

|Build Status| |Coverage Status| |Pypi Package|


Pylint Odoo plugin
==================

Enable custom checks for Odoo modules.

+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| Code | Description | Short name |
+=======+====================================================================================================================================================================================================================================================================================================+====================================+
| C7902 | Missing ./README.rst file. Template here: %s | missing-readme |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| C8101 | Missing author required "%s" in manifest file | 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 of raise "%s" requires translation. Use _(%s) | translation-required |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| C8108 | Name of compute method should starts with "_compute_" | method-compute |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| C8109 | Name of search method should starts with "_search_" | method-search |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| C8110 | Name of inverse method should starts with "_inverse_" | method-inverse |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| C8201 | No UTF-8 coding comment found: Use ``# coding: utf-8`` or ``# -*- coding: utf-8 -*-`` | no-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/maintainer-tools/blob/master/CONTRIBUTING.md#never-commit-the-transaction | invalid-commit |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| E8103 | Use of "%" operator in execute database method. Better use parameters instead. - More info https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#no-sql-injection | sql-injection |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| 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/maintainer-tools/blob/master/CONTRIBUTING.md#external-dependencies | missing-import-error |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| W7936 | Missing external dependency "%s" from manifest. More info: https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#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 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| W7940 | %s Dangerous use of "replace" from view with priority %s < %s | dangerous-view-replace-wo-priority |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| 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 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| W8201 | You have a python file with execution permissions but you don't have a interpreter magic comment. 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


.. |Build Status| image:: https://travis-ci.org/OCA/pylint-odoo.svg?branch=master
:target: https://travis-ci.org/OCA/pylint-odoo
.. |Coverage Status| image:: https://coveralls.io/repos/OCA/pylint-odoo/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/OCA/pylint-odoo?branch=master
.. |Pypi Package| image:: https://img.shields.io/pypi/v/pylint-odoo.svg
:target: https://pypi.python.org/pypi/pylint-odoo

CHANGES
=======

1.6.0
-----

* [REF] README: Auto-update Using the following script: 'PYTHONPATH=~/odoo/pylint-odoo python -c "import pylint_odoo;print pylint_odoo.messages2rst()"'
* [REF] .travis.yml: Renamed flake8 error from F999 to F601 (#115)
* [FIX] Check file-not-used: Skip tests folders (#114)
* [FIX] incoherent-interpreter-exec-perm: Skip check for windows (#113)
* [ADD] except-pass: Emit message If a except:pass is used (#107)
* [FIX] attribute-string-redundant: Add "isinstance" validation for nodes
* [ADD] attribute-string-redundant: Check if "string" parameter is equal to variable name (#100)
* [ADD] renamed-field-parameter: Detect deprecated field values (digits_compute, select) (#99)
* [REF] javascript-lint: Use eslint instead of jshint (#97)
* [ADD] xml-attribute-translatable: Check XML attribute without translation parameter (#105)
* [REF] incoherent-interpreter-exec-perm: Better message (#106)
* [IMP] pylint-odoo: Adding support for parameters --ignore and --ignore-patterns (#103)
* [ADD] eval-referenced: Detects if a "eval" is referenced (without call it) (#101)
* [FIX] duplicate-xml-fields: False red using 2 tree sub-views *2M fields (#96)
* [FIX] method-NAME: Fix if value is not a string
* [REF] misc: Remove deprecated method
* [FIX] test: Never use global into test

1.5.0
-----

* [REF] duplicate-xml-record-id: Get xml section from manifest to skip different origin (#89)
* [FIX] method-NAME: Fix case compute=None Fix OCA/pylint-odoo#88

1.4.0
-----

* [REF] attribute-deprecated: Deprecate length class attribute (#86)
* [ADD] missing-return If you use call a `super` method then you will need return the original value. If you want overwrite a original method then you need add documentation of why and add a `pylint: disable=missing-return`
* [FIX] Whitelist `anybox.testing.openerp` * Add `anybox.testing.openerp` - Fixes #81
* [FIX] manifest-version-format: Fix regex to use explicit dot instead of any char
* [FIX] manifest-version-format: Support -e manifest-version-format only
* [FIX] missing-import-error: Updating libraries used from requirements.txt but not imported or nested imported from odoo
* [IMP] manifest-version-format: Add valid_odoo_versions parameter to force a valid version of odoo in the manifest version
* [REF] missing-import-error: Skip test file since these files are loaded only when running tests and in such a case your module and their external dependencies are installed
* [ADD] Support for 10.0 manifest name
* [REF] requirements: Update developer version of pylint and astroid

1.3.5
-----

* Adding isort dependency (#70)

1.3.4
-----

* [REF] README: Update messages list

1.3.3
-----

* [ADD] missing-import-error, missing-manifest-dependency
* [FIX] rst-syntax-error: Skip unknown roles
* [FIX] rst-syntax-error: Skip unknown directives
* [REF] global refactoring: better message output and use real file and line number in non-py files (#62)
* [REF] README: Add examples special folder
* [REF] checkers: Skip example folder to check lints

1.3.2
-----

* [REF] README: Update messages list

1.3.1
-----

* [ADD] file-not-used: Emit message if there are xml, yml, sql or csv files but It isn't referenced from manifest (#53)
* [ADD] dangerous-view-replace-wo-priority: Check dangerous view with replace but defined with low priority (#55)
* [ADD] old-api7-method-defined: Emit message if the method defined have (self, cr, uid) (#52)
* [ADD] odoo-addons-relative-import (#56)
* [REF] tox: Freeze stable sha pylint20
* [FIX] consider-merging-classes-inherited: Skip check if has '_name' and fix when you use '_inherit' name out of class attribute . Add more tests
* [REF] missing-newline-extrafiles: Skip lib folder
* [FIX] consider-merging-classes-inherited: Fix leaving module isn't a good idea. Better close method
* [IMP] consider-merging-classes-inherited: Support disable comment
* [REF] consider-merging-classes-inherited: Use assign node and better message
* [ADD] consider-merging-classes-inherited
* [REF] Increase performance
* [IMP] pylint_odoo: Enable cProfile print stats
* [IMP] deprecated-module: Add exception for the case of valid openerp.osv.expression (#40)
* [IMP] sql-injection: Add compatibility with .format (#44)
* [REF] translation-required: 100% coverage
* [IMP] translation-required: Support % strings
* [IMP] translation-required: Support .format
* [FIX] translation-required: Fix AttributeError 'Getattr' object has no attribute 'name'
* [IMP] translation-required: Just check odoo exceptions
* [FIX] odoolint: Remove unsafe eval and reduce mccabe rate

1.3.0
-----

* [REF] README: Add new checks (#36)
* [FIX] duplicate-xml-fields: Support security xml style (#35)
* [ADD] sql-injection: Add new check to avoid sql injection (#29)
* [FIX] missing-newline-extrafiles: Fix 'IOError: [Errno 22] Invalid argument' by files of size 2 (#37)
* [REF] README: Add new checks
* [ADD] method-param: Check param method starts with "_param_" (#33)

Project details


Release history Release notifications | RSS feed

This version

1.6.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylint-odoo-1.6.0.tar.gz (47.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page