-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomposer-dependency-analyser.php
More file actions
73 lines (64 loc) · 2.59 KB
/
composer-dependency-analyser.php
File metadata and controls
73 lines (64 loc) · 2.59 KB
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
<?php declare(strict_types = 1);
use Orchestra\Testbench\TestCase as TestbenchTestCase;
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
use ShipMonk\ComposerDependencyAnalyser\Path;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\Glob;
// It is not loaded by default, and may lead to 'Class "Symfony\Component\Finder\Finder"
// not found' error.
require_once __DIR__ . '/vendor-bin/composer-dependency-analyser/vendor/autoload.php';
// General
$config = (new Configuration())
->enableAnalysisOfUnusedDevDependencies()
->ignoreErrorsOnPackage('bamarni/composer-bin-plugin', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('laravel/scout', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnExtension('ext-pdo_sqlite', [ErrorType::UNUSED_DEPENDENCY])
->ignoreUnknownClasses([
TestbenchTestCase::class,
]);
// Load composer.json
$path = Path::realpath(getopt('', ['composer-json:'])['composer-json'] ?? 'composer.json');
$root = Path::realpath(dirname(__FILE__).'/composer.json') === $path;
if (!$root) {
$config->disableReportingUnmatchedIgnores();
// fixme: Hotfix for https://github.com/shipmonk-rnd/composer-dependency-analyser/issues/253
$config->ignoreErrorsOnPaths(
[
'packages/graphql-printer/src/Blocks/Document/Argument.php',
'packages/graphql-printer/src/Blocks/Document/InputValueDefinition.php',
'packages/graphql-printer/src/Blocks/Document/ValueTest.php',
'packages/graphql-printer/src/Blocks/Document/VariableDefinition.php',
],
[
ErrorType::SHADOW_DEPENDENCY,
],
);
}
// Configure paths
$files = Finder::create()
->in(dirname($path))
->ignoreVCSIgnored(true)
->ignoreDotFiles(true)
->exclude('node_modules')
->exclude('vendor-bin')
->exclude('vendor')
->exclude('dev')
->path(Glob::toRegex('*Test.php'))
->path(Glob::toRegex('*/**/*Test.php'))
->path(Glob::toRegex('*Test~*.php'))
->path(Glob::toRegex('*/**/*Test~*.php'))
->path(Glob::toRegex('*Test/*.php'))
->path(Glob::toRegex('*/**/*Test/*.php'))
->path(Glob::toRegex('*Test/**/*.php'))
->path(Glob::toRegex('*/**/*Test/**/*.php'))
->path(Glob::toRegex('src/Package/*.php'))
->path(Glob::toRegex('src/Package/**/*.php'))
->path(Glob::toRegex('packages/*/src/Package/*.php'))
->path(Glob::toRegex('packages/*/src/Package/**/*.php'))
->files();
foreach ($files as $file) {
$config->addPathToScan($file->getPathname(), true);
}
// Return
return $config;