blob: 248958e13456182ef3ce7129a41ce24b1165d238 (
plain)
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
|
<?php
declare(strict_types=1);
namespace Shirabe\Lint\Linters;
use Shirabe\Lint\Linter;
use Shirabe\Lint\Support\FileFinder;
use Shirabe\Lint\Support\Paths;
final class NoModRs implements Linter
{
public function name(): string
{
return 'no_mod_rs';
}
public function failureIntro(): string
{
return 'Found `mod.rs` file(s). Use `src/<submodule>.rs` instead of `<submodule>/mod.rs`:';
}
public function check(string $rootDir, array $excludes): array
{
$errors = [];
foreach (FileFinder::modRsFiles($rootDir) as $path) {
$relative = Paths::relativeTo($rootDir, $path);
if (in_array($relative, $excludes, true)) {
continue;
}
$errors[] = $relative;
}
return $errors;
}
}
|