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