Skip to content

Commit 864efea

Browse files
committed
Update to GrumPHP 1.1 and add the shim version of various tools.
1 parent 8d4b35f commit 864efea

File tree

6 files changed

+47
-96
lines changed

6 files changed

+47
-96
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
"drupal/core": "^8.9 || ^9",
2525
"drupal/drupal-extension": "^4.1",
2626
"ergebnis/composer-normalize": "^2.8",
27+
"irstea/phpcpd-shim": "^6.0",
28+
"irstea/phpmd-shim": "^2.9",
2729
"mglaman/phpstan-drupal": "^0.12.6",
2830
"nette/neon": "^3.2",
29-
"phpmd/phpmd": "^2.9",
30-
"phpro/grumphp": "^0.18.1",
31+
"phpro/grumphp-shim": "^1.1",
3132
"phpspec/prophecy": "^1.10",
3233
"phpstan/phpstan-deprecation-rules": "^0.12.5",
3334
"phpunit/phpunit": "^7.5",
34-
"sebastian/phpcpd": "^4.0",
3535
"symfony/dotenv": "^3.4",
3636
"symfony/phpunit-bridge": "^3.4.3"
3737
},

configs/grumphp-extension.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
parameters:
2-
hooks_dir: ~
3-
hooks_preset: local
4-
stop_on_failure: true
1+
grumphp:
52
hide_circumvention_tip: true
6-
ascii: ~
3+
ascii:
4+
failed: ~
5+
succeeded: ~
76
fixer:
87
enabled: true
98
fix_by_default: true
10-
extensions:
11-
- Digipolisgent\QA\Drupal\GrumPHPExtension
9+
environment:
10+
paths:
11+
- .env
12+
- .env.local
1213
testsuites:
1314
git_commit_msg:
1415
tasks:
@@ -53,11 +54,8 @@ parameters:
5354
- "/^([A-Z][A-Z0-9]+-\\d+(, [A-Z]+-\\d+)*: )?(Add|Change|Fix|Update|Remove) /"
5455
case_insensitive: false
5556
phpcpd:
56-
names_exclude:
57-
- "*.api.php"
58-
- "*Test.php"
59-
- "*TestBase.php"
60-
- "*TestCase.php"
57+
exclude:
58+
- tests
6159
min_lines: 10
6260
triggered_by:
6361
- php
@@ -92,7 +90,6 @@ parameters:
9290
- profile
9391
phpstan:
9492
configuration: .phpstan.qa-drupal.neon
95-
level: 4
9693
ignore_patterns:
9794
- "#(^|/)tests/#"
9895
triggered_by:
@@ -107,3 +104,11 @@ parameters:
107104
yamllint:
108105
ignore_patterns:
109106
- node_modules/
107+
108+
services:
109+
listener.qa_drupal.task:
110+
class: Digipolisgent\QA\Drupal\GrumPHP\EventListener\TaskEventListener
111+
tags:
112+
- { name: grumphp.event_listener, event: grumphp.task.run, method: createTaskConfig, priority: 100 }
113+
- { name: grumphp.event_listener, event: grumphp.task.complete, method: removeTaskConfig }
114+
- { name: grumphp.event_listener, event: grumphp.task.failed, method: removeTaskConfig }

configs/grumphp-site.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
parameters:
2-
hooks_dir: ~
3-
hooks_preset: local
4-
stop_on_failure: false
1+
grumphp:
52
hide_circumvention_tip: true
6-
ascii: ~
3+
ascii:
4+
failed: ~
5+
succeeded: ~
76
fixer:
87
enabled: true
98
fix_by_default: true
10-
extensions:
11-
- Digipolisgent\QA\Drupal\GrumPHPExtension
9+
environment:
10+
paths:
11+
- .env
12+
- .env.local
1213
testsuites:
1314
git_commit_msg:
1415
tasks:
@@ -62,17 +63,11 @@ parameters:
6263
directory:
6364
- web
6465
exclude:
65-
- core
66-
- libraries
67-
- modules/contrib
68-
- themes/contrib
69-
- profiles/contrib
70-
- sites
71-
names_exclude:
72-
- "*.api.php"
73-
- "*Test.php"
74-
- "*TestBase.php"
75-
- "*TestCase.php"
66+
- web/core
67+
- web/libraries
68+
- web/*/contrib
69+
- web/modules/custom/*/tests
70+
- web/sites
7671
min_lines: 10
7772
triggered_by:
7873
- php
@@ -132,3 +127,11 @@ parameters:
132127
- "#^web/(modules|themes|profiles)/custom/#"
133128
ignore_patterns:
134129
- node_modules/
130+
131+
services:
132+
listener.qa_drupal.task:
133+
class: Digipolisgent\QA\Drupal\GrumPHP\EventListener\TaskEventListener
134+
tags:
135+
- { name: grumphp.event_listener, event: grumphp.task.run, method: createTaskConfig, priority: 100 }
136+
- { name: grumphp.event_listener, event: grumphp.task.complete, method: removeTaskConfig }
137+
- { name: grumphp.event_listener, event: grumphp.task.failed, method: removeTaskConfig }

configs/phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes:
33
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
44

55
parameters:
6+
level: 4
67
tipsOfTheDay: false
78
reportUnmatchedIgnoredErrors: false
89
ignoreErrors:

src/EventSubscriber/GrumphpEventSubscriber.php renamed to src/GrumPHP/EventListener/TaskEventListener.php

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
<?php
22

3-
namespace Digipolisgent\QA\Drupal\EventSubscriber;
3+
namespace Digipolisgent\QA\Drupal\GrumPHP\EventListener;
44

5-
use GrumPHP\Event\RunnerEvent;
6-
use GrumPHP\Event\RunnerEvents;
75
use GrumPHP\Event\TaskEvent;
8-
use GrumPHP\Event\TaskEvents;
96
use GrumPHP\Task\Behat;
107
use GrumPHP\Task\Phpcs;
118
use GrumPHP\Task\PhpMd;
129
use GrumPHP\Task\PhpStan;
1310
use GrumPHP\Task\Phpunit;
1411
use GrumPHP\Task\TaskInterface;
1512
use Nette\Neon\Neon;
16-
use Symfony\Component\Dotenv\Dotenv;
17-
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1813
use Symfony\Component\Filesystem\Filesystem;
1914
use Symfony\Component\Yaml\Yaml;
2015

2116
/**
22-
* Event subscriber for GrumPHP events.
17+
* Listener for GrumPHP task events.
2318
*/
24-
class GrumphpEventSubscriber implements EventSubscriberInterface
19+
class TaskEventListener
2520
{
2621
/**
2722
* Configuration file types.
@@ -37,39 +32,6 @@ class GrumphpEventSubscriber implements EventSubscriberInterface
3732
*/
3833
protected $isExtension;
3934

40-
/**
41-
* @inheritDoc
42-
*/
43-
public static function getSubscribedEvents()
44-
{
45-
return [
46-
RunnerEvents::RUNNER_RUN => 'loadEnvironmentFiles',
47-
TaskEvents::TASK_RUN => 'createTaskConfig',
48-
TaskEvents::TASK_SKIPPED => 'removeTaskConfig',
49-
TaskEvents::TASK_FAILED => 'removeTaskConfig',
50-
TaskEvents::TASK_COMPLETE => 'removeTaskConfig',
51-
];
52-
}
53-
54-
/**
55-
* Load the environment files.
56-
*
57-
* @param RunnerEvent $eventThe GrumPHP runner event.
58-
*/
59-
public function loadEnvironmentFiles(RunnerEvent $event)
60-
{
61-
$fs = new Filesystem();
62-
$env = new Dotenv();
63-
64-
if ($fs->exists('.env')) {
65-
$env->load('.env');
66-
}
67-
68-
if ($fs->exists('.env.local')) {
69-
$env->load('.env.local');
70-
}
71-
}
72-
7335
/**
7436
* Create the task configuration file.
7537
*
@@ -84,7 +46,7 @@ public function createTaskConfig(TaskEvent $event)
8446
// Candidate configuration files.
8547
$key_prefix = strtoupper($info['filename']) . '_SKIP_';
8648
$type_suffix = ($this->isExtension() ? 'extension' : 'site');
87-
$package_path = __DIR__ . '/../../configs/';
49+
$package_path = __DIR__ . '/../../../configs/';
8850

8951
$candidates = [
9052
$key_prefix . 'LOCAL' => $info['filename'] . '.local.' . $info['extension'],

src/GrumPHPExtension.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)