rector.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 . '/config',
  13. // $nextcloudDir . '/core',
  14. // $nextcloudDir . '/lib',
  15. // $nextcloudDir . '/ocs',
  16. // $nextcloudDir . '/ocs-provider',
  17. // $nextcloudDir . '/tests',
  18. // $nextcloudDir . '/themes',
  19. ])
  20. ->withSkip([
  21. $nextcloudDir . '/apps/*/3rdparty/*',
  22. $nextcloudDir . '/apps/*/build/stubs/*',
  23. $nextcloudDir . '/apps/*/composer/*',
  24. $nextcloudDir . '/apps/*/config/*',
  25. ])
  26. // uncomment to reach your current PHP version
  27. // ->withPhpSets()
  28. ->withTypeCoverageLevel(0);
  29. $ignoredEntries = shell_exec('git status --porcelain --ignored ' . escapeshellarg($nextcloudDir));
  30. $ignoredEntries = explode("\n", $ignoredEntries);
  31. $ignoredEntries = array_filter($ignoredEntries, static fn (string $line) => str_starts_with($line, '!! '));
  32. $ignoredEntries = array_map(static fn (string $line) => substr($line, 3), $ignoredEntries);
  33. $ignoredEntries = array_values($ignoredEntries);
  34. foreach ($ignoredEntries as $ignoredEntry) {
  35. if (str_ends_with($ignoredEntry, '/')) {
  36. $config->withSkip([$ignoredEntry . '*']);
  37. } else {
  38. $config->withSkip([$ignoredEntry . '/*']);
  39. }
  40. }
  41. return $config;