Skip to content

Commit

Permalink
fix phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
karliuka committed Sep 14, 2021
1 parent e14c543 commit 91107e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
```
Expand All @@ -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`
Expand Down
7 changes: 2 additions & 5 deletions pre_commit_hooks/magento_phpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 91107e9

Please sign in to comment.