1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Drupal\qa\Commands; |
6
|
|
|
|
7
|
|
|
use Drupal\qa\Controller\WorkflowsReportController; |
8
|
|
|
use Drupal\qa\Plugin\QaCheck\References\Integrity; |
9
|
|
|
use Drupal\qa\Plugin\QaCheck\References\TaxonomyIndex; |
10
|
|
|
use Drupal\qa\Plugin\QaCheck\System\UnusedExtensions; |
11
|
|
|
use Drupal\qa\Plugin\QaCheckManager; |
12
|
|
|
use Drupal\qa\Workflows\ContentModerationGraph; |
13
|
|
|
use Drupal\qa\Workflows\ContentModerationGrid; |
14
|
|
|
use Drush\Commands\DrushCommands; |
|
|
|
|
15
|
|
|
use OSInet\qa\ForceRemoved; |
16
|
|
|
use Symfony\Component\Yaml\Yaml; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* A Drush commandfile. |
20
|
|
|
* |
21
|
|
|
* In addition to this file, you need a drush.services.yml |
22
|
|
|
* in root of your module, and a composer.json file that provides the name |
23
|
|
|
* of the services file to use. |
24
|
|
|
* |
25
|
|
|
* See these files for an example of injecting Drupal services: |
26
|
|
|
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php |
27
|
|
|
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml |
28
|
|
|
*/ |
29
|
|
|
class QaCommands extends DrushCommands { |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The plugin.manager.qa_check service. |
33
|
|
|
* |
34
|
|
|
* @var \Drupal\qa\Plugin\QaCheckManager |
35
|
|
|
*/ |
36
|
|
|
protected $qam; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* QaCommands constructor. |
40
|
|
|
* |
41
|
|
|
* @param \Drupal\qa\Plugin\QaCheckManager $qam |
42
|
|
|
* The plugin.manager.qa_check service. |
43
|
|
|
*/ |
44
|
|
|
public function __construct(QaCheckManager $qam) { |
45
|
|
|
$this->qam = $qam; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Show the content moderation as a table. |
50
|
|
|
* |
51
|
|
|
* @command como:table |
52
|
|
|
* @aliases cmt,como-table |
53
|
|
|
*/ |
54
|
|
|
public function table() { |
55
|
|
|
$table = ContentModerationGrid::create(\Drupal::getContainer()); |
56
|
|
|
$table->report(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Show the content moderation as a Graphviz DOT file. |
61
|
|
|
* |
62
|
|
|
* @param string $workflow |
63
|
|
|
* The machine name of a workflow. |
64
|
|
|
* |
65
|
|
|
* @command como:graphviz |
66
|
|
|
* @aliases cmg,como-graphviz |
67
|
|
|
*/ |
68
|
|
|
public function graphviz(string $workflow = '') { |
69
|
|
|
$graph = ContentModerationGraph::create(\Drupal::getContainer()); |
70
|
|
|
echo $graph->report(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Show a summary of available workflows. |
75
|
|
|
* |
76
|
|
|
* @command qa:workflows-list |
77
|
|
|
* @aliases qawl,qa-workflows-list |
78
|
|
|
*/ |
79
|
|
|
public function workflowsList() { |
80
|
|
|
$listBuilder = WorkflowsReportController::create(\Drupal::getContainer()); |
81
|
|
|
$list = $listBuilder->getWorkflowSummary( |
82
|
|
|
$listBuilder->storage->loadMultiple() |
83
|
|
|
); |
84
|
|
|
$this->output->writeln(Yaml::dump($list)); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Build a Graphviz DOT file showing the module and theme dependencies. |
89
|
|
|
* |
90
|
|
|
* @command qa:dependencies |
91
|
|
|
* @aliases qadep,qa-dependencies |
92
|
|
|
*/ |
93
|
|
|
public function dependencies() { |
94
|
|
|
/** @var \Drupal\qa\Dependencies $qaDep */ |
95
|
|
|
$qaDep = \Drupal::service('qa.dependencies'); |
96
|
|
|
$g = $qaDep->build(); |
97
|
|
|
echo $g->build(); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Command helper: runs a QaCheck plugin and display its results. |
102
|
|
|
* |
103
|
|
|
* @param string $name |
104
|
|
|
* The plugin name. |
105
|
|
|
* |
106
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
107
|
|
|
*/ |
108
|
|
|
public function runPlugin(string $name): void { |
109
|
|
|
$check = $this->qam->createInstance($name); |
110
|
|
|
$pass = $check->run(); |
111
|
|
|
$res = [ |
112
|
|
|
'age' => $pass->life->age(), |
113
|
|
|
'ok' => $pass->ok, |
114
|
|
|
'result' => [], |
115
|
|
|
]; |
116
|
|
|
/** @var \Drupal\qa\Result $result */ |
117
|
|
|
foreach ($pass->result as $key => $result) { |
118
|
|
|
$res['result'][$key] = [ |
119
|
|
|
'ok' => $result->ok, |
120
|
|
|
'data' => $result->data, |
121
|
|
|
]; |
122
|
|
|
} |
123
|
|
|
$this->output->writeln(Yaml::dump($res, 5, 2)); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Show broken entity_reference fields. |
128
|
|
|
* |
129
|
|
|
* @command qa:references:integrity |
130
|
|
|
* |
131
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
132
|
|
|
*/ |
133
|
|
|
public function referencesIntegrity() { |
134
|
|
|
$this->runPlugin(Integrity::NAME); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Show broken taxonomy_index data. |
139
|
|
|
* |
140
|
|
|
* @command qa:references:taxonomy_index |
141
|
|
|
* |
142
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
143
|
|
|
*/ |
144
|
|
|
public function referencesTaxonomyIndex() { |
145
|
|
|
$this->runPlugin(TaxonomyIndex::NAME); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Show projects entirely unused and unused themes. |
150
|
|
|
* |
151
|
|
|
* @command qa:system:unused |
152
|
|
|
* |
153
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
154
|
|
|
*/ |
155
|
|
|
public function systemUnused() { |
156
|
|
|
$this->runPlugin(UnusedExtensions::NAME); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* List extensions removed without a clean uninstall. |
161
|
|
|
* |
162
|
|
|
* @command qa:force-removed |
163
|
|
|
* @aliases qafrm,qa-force-removed |
164
|
|
|
*/ |
165
|
|
|
public function forceRemoved() { |
166
|
|
|
$finder = ForceRemoved::create(); |
167
|
|
|
echo $finder->find(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
} |
171
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths