Skip to Content

Contributors

Re: New repository oca/odoo-pre-commit-hooks and pylint-odoo deep refactoring

Thank you for taking care of this Moises.

Question: how does this coordinate with the OCA repo template? Pre commit hooks are currently maintained there, right?

--dr 

No dia 28/06/2022, às 07:46, Mignon, Laurent <laurent.mignon@acsone.eu> escreveu:


Good Idea!

Regards.

On Tue, Jun 28, 2022 at 8:17 AM Pedro M. Baeza (Tecnativa) <pedro.baeza@tecnativa.com> wrote:
Yes, I agree.

Regards.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe


by Daniel Reis - 09:51 - 28 Jun 2022

Reference

  • New repository oca/odoo-pre-commit-hooks and pylint-odoo deep refactoring
    Currently, we are using pylint-odoo project as pre-commit hooks for other kind of files

    Now, we are using pre-commit for new projects.

    So we can remove all the checks unrelated with python from pylint-odoo
    e.g. eslint (javascript lints), XML checks, PO (translations) checks and so on

    Then they could be replaced in the pre-commit configuration file with the id of the related check


    There are other custom checks in pylint-odoo as unnecessary-utf8-coding-comment
    But it is duplicated with the following hook id fix-encoding-pragma from:

    It even has the option to auto-fix it

    Similar case for pylint-odoo check incoherent-interpreter-exec-perm:

    Similar case for pylint-odoo check wrong-tabs-instead-of-spaces

    They are duplicated from pylint-odoo and they are better since they have the option to auto-fix if you want.

    But there are other kinds of custom checks in pylint-odoo unrelated with python files that could be good to create a new pre-commit-hook custom for Odoo modules

    In order to check XMLs, PO, CSS, CSV, and so on in the context of Odoo modules.

    Currently, pylint-odoo is overloaded trying to do checks for non-python code since the core is not supporting check non-python files
    And pylint-odoo doesn't have the auto-fix option

    e.g. for XML files: 
     - dangerous-filter-wo-user
     - duplicate-xml-record-id
     - deprecated-openerp-xml-node
     - create-user-wo-reset-password
     - duplicate-xml-fields
     - redundant-modulename-xml
     - deprecated-data-xml-node

    e.g. for CSV files:
     - duplicate-id-csv

    e.g. for PO files (Maybe, If we look for if exists hooks related to PO files they could be already developed from another hook project, so use it instead):
     - duplicate-po-message-definition
     - po-msgstr-variables

    So, IMHO in OCA we need to create a new project to push all these custom pre-commit hooks and add documentation of the useful projects replacing pylint-odoo checks.

    The name proposal is oca/odoo-pre-commit-hooks similar to main hooks repository:

    And we can (or not) enable the option to auto fix (we can even push checks without auto fix)

    Check the following discussion about creating custom repository to detect and autofix:

    Check the following discussion about deprecating duplicated checks if pre-commit supports:

    Check the following plan to create a freeze branch in pylint-odoo with the current behavior in pro to create a new version with new focus and clean code, delete old unused checks, deprecate py2 and so on:

    If you agree, Could you help us to create the repository in OCA, please?

    --
    Moisés López Calderón
    Mobile: (+521) 477-752-22-30
    Twitter: @moylop260
    hangout: moylop260@vauxoo.com
    http://www.vauxoo.com - Odoo Gold Partner
    Twitter: @vauxoo

    by Moisés López Calderón - 10:11 - 27 Jun 2022