From 91107e9728a2160efcad0f4d19bbba8a5e747a17 Mon Sep 17 00:00:00 2001 From: karliuka Date: Tue, 14 Sep 2021 22:32:39 +0300 Subject: [PATCH] fix phpcs --- README.md | 6 +++--- pre_commit_hooks/magento_phpcs.py | 7 ++----- setup.cfg | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b433ac5..1d1e5df 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ Add this to your `.pre-commit-config.yaml` ```yaml - repo: https://github.com/eriocnemis/git.MagentoPreCommitHooks - rev: 1.0.6 # Use the ref you want to point at + rev: 1.0.8 # Use the ref you want to point at hooks: - id: magento-phpcs - args: ["php=php7.4", "--autofix=true"] + args: ["php=php7.4", "--autofix"] - id: magento-phpmd # - id: ... ``` @@ -21,7 +21,7 @@ Add this to your `.pre-commit-config.yaml` PHP Code Sniffer provides the mechanism of checking code compliance with specific coding standard. You can configure this with the following commandline options: - `--php=php7.4` - Alias or full path to the executable file of PHP. Defaults php. - - `--autofix=true` - Automatically fixes encountered violations as possible. Defaults false. + - `--autofix` - Automatically fixes encountered violations as possible. - `--standard=Magento2` - The name or path of the coding standard to use. Defaults Magento2. #### `magento-phpmd` diff --git a/pre_commit_hooks/magento_phpcs.py b/pre_commit_hooks/magento_phpcs.py index f709a33..3391adf 100755 --- a/pre_commit_hooks/magento_phpcs.py +++ b/pre_commit_hooks/magento_phpcs.py @@ -7,9 +7,6 @@ from typing import Sequence from pathlib import Path -# magento module relative path patern -PATHPATERN = '**/app/code/*/*' - def main(argv: Optional[Sequence[str]] = None) -> int: # return flag retval = 0 @@ -26,7 +23,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: help = 'the name or path of the coding standard to use' ) parser.add_argument( - '--autofix', default = False, dest='autofix', + '--autofix', action='store_true', dest='autofix', help='automatically fixes encountered violations as possible', ) parser.add_argument( @@ -35,7 +32,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: ) args = parser.parse_args(argv) - if module.match(PATHPATERN): + if module.match('**/app/code/*/*'): # path to the root of magento magento = module.parent.parent.parent.parent # path to the phpcs diff --git a/setup.cfg b/setup.cfg index 51654ca..04009e6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pre_commit_hooks -version = 1.0.7 +version = 1.0.8 description = Some magento hooks for pre-commit. long_description = file: README.md long_description_content_type = text/markdown