@@ -37,38 +37,51 @@ On Magento versions **earlier than 2.4** add following to 'require' section of p
37
37
```
38
38
39
39
#### 1. Run following commands from project root:
40
+ Add the module
41
+ ``` shell
42
+ warden env exec php-fpm composer require --dev space48/magento2-code-quality
40
43
```
41
- warden env exec php-fpm composer config repositories.space48-code-quality vcs [email protected] :Space48/code-quality.git
42
- warden env exec php-fpm composer require --dev space48/code-quality:@dev
43
- warden env exec php-fpm chmod +x ./vendor/space48/code-quality/script/install.sh
44
- warden env exec ./vendor/space48/code-quality/script/install.sh
44
+
45
+ When it will ask for 'grumphp.yml' creation - answer ` no ` :
46
+ ``` shell
47
+ Do you want to create a grumphp.yml file? [Yes]: no
48
+ ```
49
+
50
+ Copy files and install npm packages:
51
+ ``` shell
52
+ warden env exec php-fpm chmod +x vendor/space48/magento2-code-quality/script/install.sh
53
+ warden env exec ./vendor/space48/magento2-code-quality/script/install.sh
45
54
vendor/bin/grumphp git:init
55
+ ```
56
+
57
+ Add configuration files to git:
58
+ ``` shell
46
59
git add ruleset.xml phpmd.xml .eslintrc grumphp.yml
47
60
```
48
61
49
62
#### 2. Add following to project`s 'Makefile':
50
63
``` makefile
51
64
linters-init : # init linters on local machine
52
- warden env exec php-fpm chmod +x ./ vendor/space48/code-quality/script/install.sh
53
- warden env exec php-fpm ./vendor/space48/code-quality/script/install.sh
65
+ warden env exec php-fpm chmod +x vendor/space48/magento2- code-quality/script/install.sh
66
+ warden env exec php-fpm ./vendor/space48/magento2- code-quality/script/install.sh
54
67
vendor/bin/grumphp git:init
55
68
56
69
analyse : # analyses all code from starting commit hash to HEAD
57
- git diff e111c999 ..HEAD | warden env run --rm php-fpm ' vendor/phpro/grumphp/bin/grumphp' run
70
+ git diff a000z999 ..HEAD | warden env run --rm php-fpm ' vendor/phpro/grumphp/bin/grumphp' run
58
71
59
72
precommit : # analyses code staged for commit
60
73
git diff --staged | warden env run --rm php-fpm ' vendor/phpro/grumphp/bin/grumphp' run
61
74
```
62
75
63
- Replace the sample `e111c999 ` commit hash with the hash from the project where you want to start linting from.
76
+ Replace the sample `a000z999 ` commit hash with the hash from the project where you want to start linting from.
64
77
Files modified after the starting commit hash will be linted during project build and will fail the build on linter violations.
65
78
66
79
# ### 3. Commit to project`s repo.
67
80
Commit updated composer files, vendor folder, code-quality config files from the root and 'makefile' changes
68
81
69
82
# ## Installation on any other Magento 2 project:
70
83
1. add module `space48/code-quality` via Composer
71
- 2. run `vendor/space48/code-quality/script/install.sh` script to copy necessary files
84
+ 2. run `vendor/space48/code-quality/script/install.sh` script to copy necessary files and install npm packages
72
85
3. run `vendor/bin/grumphp git :init` to update precommit hooks
73
86
74
87
# # Configuration
@@ -94,5 +107,7 @@ To turn off whole linter type (for example 'eslint') - remove or comment out cor
94
107
Linter rules can be finetuned on a project level by editing `ruleset.xml, phpmd.xml, .eslintrc` files.
95
108
See `Space48/code-quality/rulesets/` for examples.
96
109
110
+ Some rules can be overwritten on a class level. See `rulesets/PhpMd/extra.xml` for examples.
111
+
97
112
# # More info
98
113
For more info and for Configuration help refer to [grumphp repo](https ://github.com/phpro/grumphp) docs.
0 commit comments