rector.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. use Rector\Config\RectorConfig;
  8. $nextcloudDir = dirname(__DIR__);
  9. $config = RectorConfig::configure()
  10. ->withPaths([
  11. $nextcloudDir . '/apps',
  12. $nextcloudDir . '/build',
  13. $nextcloudDir . '/config',
  14. $nextcloudDir . '/core',
  15. $nextcloudDir . '/lib',
  16. $nextcloudDir . '/ocs',
  17. $nextcloudDir . '/ocs-provider',
  18. $nextcloudDir . '/tests',
  19. $nextcloudDir . '/themes',
  20. $nextcloudDir . '/*.php',
  21. ])
  22. ->withSkip([
  23. $nextcloudDir . '/build/stubs/*',
  24. $nextcloudDir . '/lib/composer/*',
  25. $nextcloudDir . '/apps/*/3rdparty/*',
  26. $nextcloudDir . '/apps/*/build/stubs/*',
  27. $nextcloudDir . '/apps/*/composer/*',
  28. $nextcloudDir . '/apps/*/config/*',
  29. ])
  30. // uncomment to reach your current PHP version
  31. // ->withPhpSets()
  32. ->withTypeCoverageLevel(0);
  33. $ignoredEntries = shell_exec('git status --porcelain --ignored ' . escapeshellarg($nextcloudDir));
  34. $ignoredEntries = explode("\n", $ignoredEntries);
  35. $ignoredEntries = array_filter($ignoredEntries, static fn (string $line) => str_starts_with($line, '!! '));
  36. $ignoredEntries = array_map(static fn (string $line) => substr($line, 3), $ignoredEntries);
  37. $ignoredEntries = array_values($ignoredEntries);
  38. foreach ($ignoredEntries as $ignoredEntry) {
  39. if (str_ends_with($ignoredEntry, '/')) {
  40. $config->withSkip([$ignoredEntry . '*']);
  41. } else {
  42. $config->withSkip([$ignoredEntry . '/*']);
  43. }
  44. }
  45. return $config;