This repository was archived by the owner on Feb 16, 2021. It is now read-only.
forked from akeneo/pim-community-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.php_cd
387 lines (369 loc) · 16.4 KB
/
.php_cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<?php
use \Akeneo\CouplingDetector\Configuration\DefaultFinder;
use \Akeneo\CouplingDetector\Configuration\Configuration;
use \Akeneo\CouplingDetector\Domain\Rule;
use \Akeneo\CouplingDetector\Domain\RuleInterface;
$finder = new DefaultFinder();
$finder->notPath('Oro');
$forbidDoctrineExceptCommon = ['Doctrine\ORM', 'Doctrine\ODM', 'Doctrine\DBAL'];
$forbidPimAndEnterprise = ['Pim', 'PimEnterprise'];
$forbidPimEnterprise = ['PimEnterprise'];
$forbidAnyBundles = ['Bundle'];
$forbidAnySymfony = ['Symfony'];
$forbidCatalogModelImplementations = [
'Pim\Component\Catalog\Model\AbstractAssociation',
'Pim\Component\Catalog\Model\AbstractAttribute',
'Pim\Component\Catalog\Model\AbstractCompleteness',
'Pim\Component\Catalog\Model\AbstractMetric',
'Pim\Component\Catalog\Model\AbstractProduct',
'Pim\Component\Catalog\Model\AbstractProductPrice',
'Pim\Component\Catalog\Model\AbstractProductValue',
'Pim\Bundle\CatalogBundle\Entity',
];
$forbidCatalogRepositoryImplementations = [
'Pim\Bundle\CatalogBundle\Doctrine\ORM\Repository',
'Pim\Bundle\CatalogBundle\Doctrine\MongoDBODM\Repository',
];
$rules = [
// ONLY and OK
new Rule(
'Akeneo\Component\Analytics',
['Akeneo\Component\Analytics'],
RuleInterface::TYPE_ONLY,
'The component analytics should depends on nothing'
),
new Rule(
'Akeneo\Component\Batch',
['Akeneo\Component\Batch', 'Symfony\Component\EventDispatcher', 'Symfony\Component\PropertyAccess', 'Doctrine\Common', 'Exception'],
RuleInterface::TYPE_ONLY,
'The component batch should depends on event dispatcher, property access and doctrine common'
),
new Rule(
'Akeneo\Component\Buffer',
['Akeneo\Component\Buffer'],
RuleInterface::TYPE_ONLY,
'The component buffer should depends on nothing'
),
new Rule(
'Akeneo\Component\Console',
['Akeneo\Component\Console', 'Symfony\Component\Process'],
RuleInterface::TYPE_ONLY,
'The component console should depends only on symfony process'
),
new Rule(
'Akeneo\Component\FileStorage',
['Akeneo\Component\FileStorage', 'Akeneo\Component\StorageUtils', 'League\Flysystem', 'Symfony\Component\HttpFoundation', 'Symfony\Component\Filesystem', 'Doctrine\Common'],
RuleInterface::TYPE_ONLY,
'The component file storage should depends only on akeneo storageutils, flysystem, symfony filesystem, symfony http foundation, doctrine common'
),
new Rule(
'Akeneo\Component\Localization',
['Akeneo\Component\Localization', 'Doctrine\Common'],
RuleInterface::TYPE_ONLY,
'The component console should depends only on doctrine common'
),
new Rule(
'Akeneo\Component\StorageUtils',
['Akeneo\Component\StorageUtils', 'Symfony\Component\EventDispatcher', 'Doctrine\Common'],
RuleInterface::TYPE_ONLY,
'The component storage utils should depends only on symfony event dispatcher, doctrine common'
),
new Rule(
'Akeneo\Component\Versioning',
['Akeneo\Component\Versioning'],
RuleInterface::TYPE_ONLY,
'The component versioning should depends on nothing'
),
new Rule(
'PimEnterprise\Component',
array_merge($forbidAnyBundles, $forbidDoctrineExceptCommon),
RuleInterface::TYPE_FORBIDDEN,
'PimEnterprise components contain Enterprise Business Logic, they does not depend on Bundle, Doctrine or Symfony'
),
new Rule(
'Akeneo\Bundle',
$forbidPimAndEnterprise,
RuleInterface::TYPE_FORBIDDEN,
'A Akeneo bundle contain Symfony or Doctine glue for Akeno components, must not depend on Pim'
),
new Rule(
'Pim\Bundle',
$forbidPimEnterprise,
RuleInterface::TYPE_FORBIDDEN,
'Pim bundles should never use the namespace PimEnterprise'
),
];
$rulesToFix = [
// TODO following is "easy" to fix
// TODO fix AttributeValidatorHelper
new Rule(
'Pim\Component\ReferenceData',
['Pim\Component\ReferenceData', 'Pim\Component\Catalog', 'Doctrine\Common', 'Symfony\Component\PropertyAccess', 'Symfony\Component\OptionsResolver'],
RuleInterface::TYPE_ONLY,
'The component reference data should depends only on catalog component, symfony property access, symfony options resolver and doctrine common'
),
// TODO: violations with QB
new Rule(
'Akeneo\Component',
array_merge($forbidAnyBundles, $forbidPimAndEnterprise, $forbidDoctrineExceptCommon),
RuleInterface::TYPE_FORBIDDEN,
'A Akeneo component must only contain technical logic re-usable out of the Pim, must not depends on Pim, Bundle, Doctrine'
),
// TODO: violations with QB
new Rule(
'Akeneo\Component\Classification',
['Akeneo\Component\Classification', 'Akeneo\Component\Localization', 'Akeneo\Component\StorageUtils', 'Doctrine\Common', 'Symfony\Component\PropertyAccess', 'Gedmo\Tree\RepositoryInterface'],
RuleInterface::TYPE_ONLY,
'The component classification should only depends on storageutils, doctrine common and symfony property access (gedmo is an implementation detail?)'
),
// TODO: WIP
new Rule(
'Pim\Component\Catalog',
[
'Pim\Component\Catalog',
'Akeneo\Component\Versioning',
'Akeneo\Component\Comment',
'Akeneo\Component\Classification',
'Akeneo\Component\Localization',
'Akeneo\Component\FileStorage',
'Akeneo\Component\StorageUtils',
'Doctrine\Common',
'League\Flysystem',
'Symfony\Component\HttpFoundation',
'Symfony\Component\PropertyAccess',
'Symfony\Component\OptionsResolver',
'Symfony\Component\Serializer',
'Exception'
],
RuleInterface::TYPE_ONLY,
'The component catalog should depends on Akeneo components, Doctrine common, Flysystem, Symfony http foundation, property access, option resolver and serializer'
),
new Rule(
'Pim\Component\Connector',
[
'Pim\Component\Connector',
'Akeneo\Component\Buffer',
'Akeneo\Component\Batch',
'Akeneo\Component\StorageUtils',
'Akeneo\Component\FileStorage',
'Akeneo\Component\Classification',
'Akeneo\Component\Versioning',
'Pim\Component\Catalog',
'Pim\Component\Localization', // TODO => move to Akeneo\Component\Localization
'Symfony\Component\Filesystem',
'Symfony\Component\OptionsResolver',
'Symfony\Component\Validator',
'Symfony\Component\Yaml',
'Symfony\Component\HttpFoundation',
'League\Flysystem',
'Doctrine\Common'
],
RuleInterface::TYPE_ONLY,
'The component connector should depends only on ... bunch of stuff :)'
),
// DISCOURAGED to be fixed to forbidden
new Rule(
'Pim\Component',
array_merge($forbidAnyBundles, $forbidPimEnterprise, $forbidDoctrineExceptCommon),
RuleInterface::TYPE_DISCOURAGED,
'A Pim component must only contain business logic related to the PIM, must not depends on Bundle or Doctrine'
),
new Rule(
'Pim',
array_merge($forbidCatalogModelImplementations),
RuleInterface::TYPE_DISCOURAGED,
'A Pim component or bundle must never depends on model implementations to allow to replace implementation'
),
new Rule(
'Pim',
array_merge($forbidCatalogRepositoryImplementations),
RuleInterface::TYPE_DISCOURAGED,
'A Pim component or bundle must never depends on repositories implementations to allow to replace implementation'
),
// Following is ok but really permissive
new Rule(
'Akeneo\Bundle\BatchBundle',
[
'Akeneo\Bundle\BatchBundle',
'Akeneo\Bundle\StorageUtilsBundle',
'Akeneo\Component\Batch',
'Monolog',
'Psr\Log',
'Symfony\Component\Console',
'Symfony\Component\Validator',
'Symfony\Component\DependencyInjection',
'Symfony\Component\Config',
'Symfony\Component\Yaml',
'Symfony\Component\HttpKernel',
'Symfony\Component\EventDispatcher',
'Symfony\Component\Translation',
'Symfony\Component\Security',
'Symfony\Component\PropertyAccess',
'Symfony\Component\HttpFoundation',
'Symfony\Component\Process',
'Symfony\Component\Security',
'Symfony\Bundle\FrameworkBundle',
'Symfony\Bridge\Doctrine',
'Doctrine\Common',
'Doctrine\DBAL',
'Doctrine\ORM'
],
RuleInterface::TYPE_ONLY,
'BatchBundle should use only batch component, monolog, symfony console'
),
// TODO: real stuff to fix
new Rule(
'Pim\Bundle\CatalogBundle',
[
// bundles
'AnalyticsBundle',
'CommentBundle',
'DataGridBundle',
'ImportExportBundle',
'LocalizationBundle',
'PdfGeneratorBundle',
'TranslationBundle',
'VersioningBundle',
'BaseConnectorBundle',
'ConnectorBundle',
'EnrichBundle',
'InstallerBundle',
'NavigationBundle',
'ReferenceDataBundle',
'UIBundle',
'WebServiceBundle',
'DashboardBundle',
'FilterBundle',
'JsFormValidationBundle',
'NotificationBundle',
'TransformBundle',
'UserBundle',
'BatchBundle',
// components
'Connector',
],
RuleInterface::TYPE_FORBIDDEN,
'CatalogBundle should never use components or bundles related to UI or Import/Export'
),
// Following is ok but really permissive
new Rule(
'Pim\Bundle\ConnectorBundle',
[
'AnalyticsBundle',
'CommentBundle',
'DataGridBundle',
'ImportExportBundle',
'LocalizationBundle',
'PdfGeneratorBundle',
'TranslationBundle',
'VersioningBundle',
'BaseConnectorBundle',
'CatalogBundle',
'EnrichBundle',
'InstallerBundle',
'NavigationBundle',
'ReferenceDataBundle',
'UIBundle',
'WebServiceBundle',
'DashboardBundle',
'FilterBundle',
'JsFormValidationBundle',
'NotificationBundle',
'TransformBundle',
'UserBundle',
],
RuleInterface::TYPE_FORBIDDEN,
'ConnectorBundle should never use components or bundles related to UI or to the deprecated Import/Export system'
),
];
$rules = array_merge($rules, $rulesToFix);
// TODO: list of violations to fix
$legacyExclusions = [
// Repository interfaces should never expose QueryBuilder as parameter
'Akeneo\Component\Classification\Repository' => [
'Doctrine\ORM\QueryBuilder',
],
'Pim\Component\Catalog' => [
// Repository interfaces of CatalogBundle should be extracted in the catalog component
'Pim\Bundle\CatalogBundle\Repository\GroupTypeRepositoryInterface',
'Pim\Bundle\CatalogBundle\Repository\AttributeGroupRepositoryInterface',
'Pim\Bundle\CatalogBundle\Repository\AttributeRequirementRepositoryInterface',
// Extract at least an interface of these factories in the catalog component (ideally move implem too)
'Pim\Bundle\CatalogBundle\Factory\FamilyFactory',
'Pim\Bundle\CatalogBundle\Factory\AttributeRequirementFactory',
'Pim\Bundle\CatalogBundle\Factory\MetricFactory',
// What to do with this class?
'Pim\Bundle\CatalogBundle\Validator\AttributeValidatorHelper',
// Avoid to use this manager, extract an interface from this or maybe use repository and depreciate it
'Pim\Bundle\CatalogBundle\Manager\CurrencyManager',
// What to do with this, cannot be extracted due to dependencies to symfony form
'Pim\Bundle\CatalogBundle\AttributeType\AbstractAttributeType',
'Pim\Component\Catalog\AttributeTypes',
],
'Pim\Component\Connector' => [
// Repositories interfaces of CatalogBundle should be extracted in the catalog component
'Pim\Bundle\CatalogBundle\Repository\CurrencyRepositoryInterface',
'Pim\Bundle\CatalogBundle\Repository\GroupTypeRepositoryInterface',
'Pim\Bundle\CatalogBundle\Repository\AssociationTypeRepositoryInterface',
// What to do with this, cannot be extracted due to dependencies to symfony form
'Pim\Component\Catalog\AttributeTypes',
'Pim\Bundle\CatalogBundle\AttributeType\AbstractAttributeType',
// We need to check why we use these classes, interfaces should be extracted in the catalog component
'Pim\Bundle\CatalogBundle\Manager\AttributeValuesResolver',
'Pim\Bundle\CatalogBundle\Manager\ProductTemplateApplierInterface',
'Pim\Bundle\CatalogBundle\Validator\Constraints\File',
// For factories and builders of CatalogBundle, interfaces should be created in the catalog component
'Pim\Bundle\CatalogBundle\Factory\AttributeFactory',
'Pim\Bundle\CatalogBundle\Factory\FamilyFactory',
'Pim\Bundle\CatalogBundle\Factory\GroupFactory',
// Version manager should be exploded with SRP and introduce different interfaces in a component, here we use it
// to switch real time versionning that should be moved in VersioningContext/VersioningState?
'Pim\Bundle\VersioningBundle\Manager\VersionManager',
],
// Same issues than catalog component updater classes, same fixes expected
'Pim\Component\ReferenceData\Updater' => [
'Pim\Bundle\CatalogBundle\Validator\AttributeValidatorHelper',
],
// Same issues than catalog component updater classes, same fixes expected
'Pim\Component\Localization' => [
'Pim\Component\Catalog\AttributeTypes',
'Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface',
// Why we use it?
'Pim\Component\Localization\Normalizer\MetricNormalizer',
],
'Pim\Bundle\CatalogBundle\Model' => [
// should be extracted in a component in a akeneo component in a BC way (localization?)
'Pim\Bundle\TranslationBundle\Entity\TranslatableInterface',
'Pim\Bundle\TranslationBundle\Entity\AbstractTranslation',
// should be extracted in a akeneo component in a BC way
'Pim\Bundle\CommentBundle\Model\CommentSubjectInterface',
],
'Pim\Bundle\CatalogBundle\Entity' => [
// should be extracted in a component in a akeneo component in a BC way (localization?)
'Pim\Bundle\TranslationBundle\Entity\TranslatableInterface',
'Pim\Bundle\TranslationBundle\Entity\AbstractTranslation',
],
'Pim\Bundle\CatalogBundle\Manager\FamilyManager' => [
// FamilyManager should be dropped and not even used
'Pim\Bundle\UserBundle\Context\UserContext',
],
'Pim\Bundle\CatalogBundle\Helper\LocaleHelper' => [
// LocaleHelper should be simplified and moved to LocalizationBundle
'Pim\Bundle\UserBundle\Context\UserContext',
],
'Pim\Bundle\CatalogBundle\Repository' => [
// CatalogBundle repository interfaces should not rely on an EnrichBundle DataTransformer interface,
// this enrich interface is not even related to UI and should be moved
'Pim\Bundle\EnrichBundle\Form\DataTransformer\ChoicesProviderInterface',
// CatalogBundle repository interfaces should not rely on a UIBundle repository interface, this ui
// interface should be moved
'Pim\Bundle\UIBundle\Entity\Repository\OptionRepositoryInterface',
],
// CatalogBundle MongoDB normalizers should not use a TransformBundle normalizer, will be better to
// duplicate code or extract
'Pim\Bundle\CatalogBundle\MongoDB\Normalizer' => [
'Pim\Bundle\TransformBundle\Normalizer\Structured\TranslationNormalizer',
],
];
$config = new Configuration($rules, $finder);
return $config;