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\Cache\Sizes; |
9
|
|
|
use Drupal\qa\Plugin\QaCheck\Dependencies\Undeclared; |
10
|
|
|
use Drupal\qa\Plugin\QaCheck\References\Integrity; |
11
|
|
|
use Drupal\qa\Plugin\QaCheck\References\TaxonomyIndex; |
12
|
|
|
use Drupal\qa\Plugin\QaCheck\System\ExternalCode; |
13
|
|
|
use Drupal\qa\Plugin\QaCheck\System\UnusedExtensions; |
14
|
|
|
use Drupal\qa\Plugin\QaCheckManager; |
15
|
|
|
use Drupal\qa\Workflows\ContentModerationGraph; |
16
|
|
|
use Drupal\qa\Workflows\ContentModerationGrid; |
17
|
|
|
use Drush\Commands\DrushCommands; |
|
|
|
|
18
|
|
|
use OSInet\qa\ForceRemoved; |
19
|
|
|
use Symfony\Component\Yaml\Yaml; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* A Drush commandfile. |
23
|
|
|
* |
24
|
|
|
* In addition to this file, you need a drush.services.yml |
25
|
|
|
* in root of your module, and a composer.json file that provides the name |
26
|
|
|
* of the services file to use. |
27
|
|
|
* |
28
|
|
|
* See these files for an example of injecting Drupal services: |
29
|
|
|
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php |
30
|
|
|
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml |
31
|
|
|
*/ |
32
|
|
|
class QaCommands extends DrushCommands { |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The plugin.manager.qa_check service. |
36
|
|
|
* |
37
|
|
|
* @var \Drupal\qa\Plugin\QaCheckManager |
38
|
|
|
*/ |
39
|
|
|
protected $qam; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* QaCommands constructor. |
43
|
|
|
* |
44
|
|
|
* @param \Drupal\qa\Plugin\QaCheckManager $qam |
45
|
|
|
* The plugin.manager.qa_check service. |
46
|
|
|
*/ |
47
|
|
|
public function __construct(QaCheckManager $qam) { |
48
|
|
|
$this->qam = $qam; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Show the content moderation as a table. |
53
|
|
|
* |
54
|
|
|
* @command como:table |
55
|
|
|
* @aliases cmt,como-table |
56
|
|
|
*/ |
57
|
|
|
public function table() { |
58
|
|
|
$table = ContentModerationGrid::create(\Drupal::getContainer()); |
59
|
|
|
$table->report(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Show the content moderation as a Graphviz DOT file. |
64
|
|
|
* |
65
|
|
|
* @param string $workflow |
66
|
|
|
* The machine name of a workflow. |
67
|
|
|
* |
68
|
|
|
* @command como:graphviz |
69
|
|
|
* @aliases cmg,como-graphviz |
70
|
|
|
*/ |
71
|
|
|
public function graphviz(string $workflow = '') { |
72
|
|
|
$graph = ContentModerationGraph::create(\Drupal::getContainer()); |
73
|
|
|
echo $graph->report(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Show a summary of available workflows. |
78
|
|
|
* |
79
|
|
|
* @command qa:workflows-list |
80
|
|
|
* @aliases qawl,qa-workflows-list |
81
|
|
|
*/ |
82
|
|
|
public function workflowsList() { |
83
|
|
|
$listBuilder = WorkflowsReportController::create(\Drupal::getContainer()); |
84
|
|
|
$list = $listBuilder->getWorkflowSummary( |
85
|
|
|
$listBuilder->storage->loadMultiple() |
86
|
|
|
); |
87
|
|
|
$this->output->writeln(Yaml::dump($list)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Build a Graphviz DOT file showing the module and theme dependencies. |
92
|
|
|
* |
93
|
|
|
* @command qa:dependencies |
94
|
|
|
* @aliases qadep,qa-dependencies |
95
|
|
|
*/ |
96
|
|
|
public function dependencies() { |
97
|
|
|
/** @var \Drupal\qa\Dependencies $qaDep */ |
98
|
|
|
$qaDep = \Drupal::service('qa.dependencies'); |
99
|
|
|
$g = $qaDep->build(); |
100
|
|
|
echo $g->build(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Command helper: runs a QaCheck plugin and display its results. |
105
|
|
|
* |
106
|
|
|
* @param string $name |
107
|
|
|
* The plugin name. |
108
|
|
|
* |
109
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
110
|
|
|
*/ |
111
|
|
|
public function runPlugin(string $name): void { |
112
|
|
|
$check = $this->qam->createInstance($name); |
113
|
|
|
$pass = $check->run(); |
114
|
|
|
$res = [ |
115
|
|
|
'age' => $pass->life->age(), |
116
|
|
|
'ok' => $pass->ok, |
117
|
|
|
'result' => [], |
118
|
|
|
]; |
119
|
|
|
/** @var \Drupal\qa\Result $result */ |
120
|
|
|
foreach ($pass->result as $key => $result) { |
121
|
|
|
$res['result'][$key] = [ |
122
|
|
|
'ok' => $result->ok, |
123
|
|
|
'data' => $result->data, |
124
|
|
|
]; |
125
|
|
|
} |
126
|
|
|
$this->output->writeln(Yaml::dump($res, 6, 2)); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Show oversize cache data. |
131
|
|
|
* |
132
|
|
|
* @command qa:cache:sizes |
133
|
|
|
* |
134
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
135
|
|
|
*/ |
136
|
|
|
public function cacheSizes() { |
137
|
|
|
$this->runPlugin(Sizes::NAME); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Show undeclared function-based dependencies. |
142
|
|
|
* |
143
|
|
|
* @command qa:dependencies:undeclared |
144
|
|
|
* |
145
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
146
|
|
|
*/ |
147
|
|
|
public function dependenciesUndeclared() { |
148
|
|
|
$this->runPlugin(Undeclared::NAME); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Show code which is either external or without an identifiable source. |
153
|
|
|
* |
154
|
|
|
* @command qa:system:external |
155
|
|
|
* |
156
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
157
|
|
|
*/ |
158
|
|
|
public function externalCode() { |
159
|
|
|
$this->runPlugin(ExternalCode::NAME); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Show broken entity_reference fields. |
164
|
|
|
* |
165
|
|
|
* @command qa:references:integrity |
166
|
|
|
* |
167
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
168
|
|
|
*/ |
169
|
|
|
public function referencesIntegrity() { |
170
|
|
|
$this->runPlugin(Integrity::NAME); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Show broken taxonomy_index data. |
175
|
|
|
* |
176
|
|
|
* @command qa:references:taxonomy_index |
177
|
|
|
* |
178
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
179
|
|
|
*/ |
180
|
|
|
public function referencesTaxonomyIndex() { |
181
|
|
|
$this->runPlugin(TaxonomyIndex::NAME); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Show projects entirely unused and unused themes. |
186
|
|
|
* |
187
|
|
|
* @command qa:system:unused |
188
|
|
|
* |
189
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
190
|
|
|
*/ |
191
|
|
|
public function systemUnused() { |
192
|
|
|
$this->runPlugin(UnusedExtensions::NAME); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* List extensions removed without a clean uninstall. |
197
|
|
|
* |
198
|
|
|
* @command qa:force-removed |
199
|
|
|
* @aliases qafrm,qa-force-removed |
200
|
|
|
*/ |
201
|
|
|
public function forceRemoved() { |
202
|
|
|
$finder = ForceRemoved::create(); |
203
|
|
|
echo $finder->find(); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
} |
207
|
|
|
|
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