|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @copyright Copyright (c) 2017 Joas Schilling <[email protected]> |
| 4 | + * @copyright Copyright (c) 2020 Gary Kim <[email protected]> |
| 5 | + * |
| 6 | + * @author Gary Kim <[email protected]> |
| 7 | + * |
| 8 | + * @license GNU AGPL version 3 or any later version |
| 9 | + * |
| 10 | + * This program is free software: you can redistribute it and/or modify |
| 11 | + * it under the terms of the GNU Affero General Public License as |
| 12 | + * published by the Free Software Foundation, either version 3 of the |
| 13 | + * License, or (at your option) any later version. |
| 14 | + * |
| 15 | + * This program is distributed in the hope that it will be useful, |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | + * GNU Affero General Public License for more details. |
| 19 | + * |
| 20 | + * You should have received a copy of the GNU Affero General Public License |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +$directories = [ |
| 26 | + __DIR__ . '/../apps', |
| 27 | + __DIR__ . '/../core' |
| 28 | +]; |
| 29 | + |
| 30 | +$errors = []; |
| 31 | +foreach ($directories as $dir) { |
| 32 | + $it = new \RecursiveDirectoryIterator($dir); |
| 33 | + |
| 34 | + foreach (new RecursiveIteratorIterator($it) as $file) { |
| 35 | + if ($file->getExtension() === 'map') { |
| 36 | + continue; |
| 37 | + } |
| 38 | + $content = file_get_contents($file->getPathname()); |
| 39 | + $matches = preg_grep('/[^A-Za-z][tn]\([\'"][^\'"]*?[\'"],( ?)[\'"][^\'"]*?(\.\.\.)[^\'"]*?[\'"]/sU', explode(PHP_EOL, $content)); |
| 40 | + |
| 41 | + foreach ($matches as $ln => $match) { |
| 42 | + if (file_exists($file->getPathname() . '.map')) { |
| 43 | + $errors[] = sprintf('At line %d in file %s (file may be transpiled)', $ln, $file); |
| 44 | + } else { |
| 45 | + $errors[] = sprintf('At line %d in file %s', $ln, $file); |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +echo PHP_EOL . PHP_EOL; |
| 52 | +if (count($errors) > 0) { |
| 53 | + $verb = count($errors) > 1 ? "are" : "is"; |
| 54 | + if (count($errors) > 1) { |
| 55 | + echo sprintf('ERROR: There are %d uses of triple dot instead of ellipsis:', count($errors)) . PHP_EOL; |
| 56 | + } else { |
| 57 | + echo 'ERROR: There is 1 use of triple dot instead of ellipsis:' . PHP_EOL; |
| 58 | + } |
| 59 | + echo implode(PHP_EOL, $errors) . PHP_EOL; |
| 60 | + exit(1); |
| 61 | +} |
| 62 | + |
| 63 | +echo 'OK: all good! No use of triple dot instead of ellipsis found.' . PHP_EOL; |
| 64 | +exit(0); |
0 commit comments