Skip to content

Commit 5d8f74d

Browse files
authored
Merge pull request #14 from OSInet/12-orphans
Implement taxonomy_index integrity check
2 parents 626d2d2 + e9a55ca commit 5d8f74d

File tree

14 files changed

+247
-231
lines changed

14 files changed

+247
-231
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ typically by piping the output like this:
6262
<td>OK</td>
6363
</tr>
6464
<tr>
65-
<td>References</td>
66-
<td>References</td>
65+
<td rowspan="2">References</td>
66+
<td>Integrity</td>
6767
<td>OK:<ul>
6868
<li>file</li>
6969
<li>image</li>
@@ -74,6 +74,12 @@ typically by piping the output like this:
7474
<td></td>
7575
<td></td>
7676
</tr>
77+
<tr>
78+
<td>Taxonomy Index</td>
79+
<td>OK</td>
80+
<td></td>
81+
<td>OK</td>
82+
</tr>
7783
<tr>
7884
<td rowspan="3">System</td>
7985
<td>Dependency (graph)</td>
@@ -94,18 +100,12 @@ typically by piping the output like this:
94100
<td></td>
95101
</tr>
96102
<tr>
97-
<td rowspan="2">Taxonomy</td>
103+
<td>Taxonomy</td>
98104
<td>Freetagging</td>
99105
<td>Planned</td>
100106
<td></td>
101107
<td>OK</td>
102108
</tr>
103-
<tr>
104-
<td>Orphans</td>
105-
<td>Planned</td>
106-
<td></td>
107-
<td>OK</td>
108-
</tr>
109109
<tr>
110110
<td>Variables</td>
111111
<td>Size</td>

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"name": "osinet/qa",
1919
"require": {
2020
"php": ">=7.3",
21+
"drupal/core": "^8 || ^9",
2122
"osinet/grafizzi": "^0.0.2"
2223
},
2324
"type": "drupal-module"

src/Commands/QaCommands.php

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Drupal\qa\Controller\WorkflowsReportController;
88
use Drupal\qa\Plugin\QaCheck\References\Integrity;
9+
use Drupal\qa\Plugin\QaCheck\References\TaxonomyIndex;
910
use Drupal\qa\Plugin\QaCheck\System\UnusedExtensions;
1011
use Drupal\qa\Plugin\QaCheckManager;
1112
use Drupal\qa\Workflows\ContentModerationGraph;
@@ -97,14 +98,15 @@ public function dependencies() {
9798
}
9899

99100
/**
100-
* Show broken entity_reference fields.
101+
* Command helper: runs a QaCheck plugin and display its results.
101102
*
102-
* @command qa:references:integrity
103+
* @param string $name
104+
* The plugin name.
103105
*
104106
* @throws \Drupal\Component\Plugin\Exception\PluginException
105107
*/
106-
public function referencesIntegrity() {
107-
$check = $this->qam->createInstance(Integrity::NAME);
108+
public function runPlugin(string $name): void {
109+
$check = $this->qam->createInstance($name);
108110
$pass = $check->run();
109111
$res = [
110112
'age' => $pass->life->age(),
@@ -121,6 +123,28 @@ public function referencesIntegrity() {
121123
$this->output->writeln(Yaml::dump($res, 5, 2));
122124
}
123125

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+
124148
/**
125149
* Show projects entirely unused and unused themes.
126150
*
@@ -129,21 +153,7 @@ public function referencesIntegrity() {
129153
* @throws \Drupal\Component\Plugin\Exception\PluginException
130154
*/
131155
public function systemUnused() {
132-
$check = $this->qam->createInstance(UnusedExtensions::NAME);
133-
$pass = $check->run();
134-
$res = [
135-
'age' => $pass->life->age(),
136-
'ok' => $pass->ok,
137-
'result' => [],
138-
];
139-
/** @var \Drupal\qa\Result $result */
140-
foreach ($pass->result as $key => $result) {
141-
$res['result'][$key] = [
142-
'ok' => $result->ok,
143-
'data' => $result->data,
144-
];
145-
}
146-
$this->output->writeln(Yaml::dump($res, 4, 2));
156+
$this->runPlugin(UnusedExtensions::NAME);
147157
}
148158

149159
/**

src/Controller/ResultsReportController.php

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

3+
declare(strict_types = 1);
4+
35
namespace Drupal\qa\Controller;
46

57
use Drupal\Core\Controller\ControllerBase;
68

79
/**
810
* Class ResultsReportController.
9-
*
10-
* @package Drupal\qa\Controller
1111
*/
1212
class ResultsReportController extends ControllerBase {
1313

@@ -24,6 +24,15 @@ public function report() {
2424
];
2525
}
2626

27+
/**
28+
* Placeholder controller for "results".
29+
*
30+
* @param string $qaVariable
31+
* The variable name.
32+
*
33+
* @return array
34+
* A render array.
35+
*/
2736
public function view($qaVariable) {
2837
return [
2938
'#type' => 'markup',

src/Exportable.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Drupal\qa;
44

5+
use Drupal\Core\StringTranslation\StringTranslationTrait;
6+
57
abstract class Exportable {
8+
use StringTranslationTrait;
69

710
/**
811
* The directory containing the file containing this class.
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,22 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
namespace Drupal\qa\Cache;
46

57
use Drupal\qa\BasePackage;
68

79
/**
8-
* @file
9-
* OSInet QA Plugin for cache checks.
10-
*
11-
* @copyright Copyright (C) 2014 Frederic G. MARAND for Ouest Systèmes Informatiques (OSInet)
12-
*
13-
* @since DRUPAL-7
14-
*
15-
* @license Licensed under the disjunction of the CeCILL, version 2 and General Public License version 2 and later
16-
*
17-
* License note: QA is distributed by OSInet to its customers under the
18-
* CeCILL 2.0 license. OSInet support services only apply to the module
19-
* when distributed by OSInet, not by any third-party further down the
20-
* distribution chain.
21-
*
22-
* If you obtained QA from drupal.org, that site received it under the
23-
* GPLv2 license and can therefore distribute it under the GPLv2, and
24-
* so can you and just anyone down the chain as long as the GPLv2 terms
25-
* are abided by, the module distributor in that case being the
26-
* drupal.org organization or the downstream distributor, not OSInet.
10+
* OSInet QA Plugin for cache check.
2711
*/
28-
2912
class Package extends BasePackage {
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
3017
public function init() {
31-
$this->title = t('Cache');
32-
$this->description = t('Look for suspicious content in database cache. Do NOT use with other cache types.');
18+
$this->title = $this->t('Cache');
19+
$this->description = $this->t('Look for suspicious content in database cache. Do NOT use with other cache types.');
3320
}
21+
3422
}
Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
<?php
2-
/**
3-
* @file
4-
* OSInet QA Plugin for i18n (internationalization) module
5-
*
6-
* @copyright Copyright (C) 2011 Frederic G. MARAND for Ouest Systèmes Informatiques (OSInet)
7-
*
8-
* @since DRUPAL-6
9-
*
10-
* @license Licensed under the disjunction of the CeCILL, version 2 and General Public License version 2 and later
11-
*
12-
* License note: QA is distributed by OSInet to its customers under the
13-
* CeCILL 2.0 license. OSInet support services only apply to the module
14-
* when distributed by OSInet, not by any third-party further down the
15-
* distribution chain.
16-
*
17-
* If you obtained QA from drupal.org, that site received it under the
18-
* GPLv2 license and can therefore distribute it under the GPLv2, and
19-
* so can you and just anyone down the chain as long as the GPLv2 terms
20-
* are abided by, the module distributor in that case being the
21-
* drupal.org organization or the downstream distributor, not OSInet.
22-
*/
2+
3+
declare(strict_types = 1);
234

245
namespace Drupal\qa\I18n;
256

267
use Drupal\qa\BasePackage;
278

9+
/**
10+
* OSInet QA Plugin for i18n (internationalization) module.
11+
*/
2812
class Package extends BasePackage {
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
2917
public function init() {
30-
$this->title = t('i18n');
31-
$this->description = t('Inconsistent variables translation');
18+
$this->title = $this->t('i18n');
19+
$this->description = $this->t('Inconsistent variables translation');
3220
}
21+
3322
}

src/Plugin/Qa/Control/Taxonomy/Freetagging.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22

33
namespace Drupal\qa\Taxonomy;
44

5+
use Drupal\qa\BaseControl;
6+
57
/**
68
* Find views containing PHP code
79
*/
8-
class Freetagging extends Taxonomy {
10+
class Freetagging extends BaseControl {
11+
12+
/**
13+
* {@inheritdoc]
14+
*/
15+
public function __construct() {
16+
parent::__construct();
17+
$this->package_name = __NAMESPACE__;
18+
}
19+
20+
public static function getDependencies() {
21+
$ret = BaseControl::getDependencies();
22+
$ret = array_merge($ret, ['taxonomy']);
23+
return $ret;
24+
}
925

1026
/**
1127
* {@inheritdoc]

src/Plugin/Qa/Control/Taxonomy/Orphans.php

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

0 commit comments

Comments
 (0)