Skip to content

Commit

Permalink
fix: ensure issues are reported always in the same order
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Dec 27, 2024
1 parent 4d6d232 commit fdc4aa1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/Checkers/FileSystemChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function check(array $parameters): array
];
}

return $issues;
usort($issues, fn (Issue $a, Issue $b): int => $a->file <=> $b->file);

return array_values($issues);
}
}
49 changes: 25 additions & 24 deletions tests/Unit/Checkers/FileSystemCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
'typo\'s',
'types',
'type\'s',
])->and($issues[1]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FolderThatShouldBeIgnored/FileThatShoudBeIgnoredBecauseItsInsideWhitelistedFolder.php')
])->and($issues[1]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileThatShouldBeIgnroed.php')
->and($issues[1]->line)->toBe(0)
->and($issues[1]->misspelling->word)->toBe('shoud')
->and($issues[1]->misspelling->word)->toBe('ignroed')
->and($issues[1]->misspelling->suggestions)->toBe([
'should',
'shroud',
'shod',
'shout',
])->and($issues[2]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileThatShouldBeIgnroed.php')
->and($issues[2]->line)->toBe(0)
->and($issues[2]->misspelling->word)->toBe('ignroed')
->and($issues[2]->misspelling->suggestions)->toBe([
'ignored',
'ignores',
'ignore',
'inroad',
])->and($issues[3]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileWithTppyo.php')
->and($issues[3]->line)->toBe(0)
->and($issues[3]->misspelling->word)->toBe('tppyo')
->and($issues[3]->misspelling->suggestions)->toBe([
])->and($issues[2]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileWithTppyo.php')
->and($issues[2]->line)->toBe(0)
->and($issues[2]->misspelling->word)->toBe('tppyo')
->and($issues[2]->misspelling->suggestions)->toBe([
'typo',
'Tokyo',
'typos',
'topi',
])->and($issues[3]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FolderThatShouldBeIgnored/FileThatShoudBeIgnoredBecauseItsInsideWhitelistedFolder.php')
->and($issues[3]->line)->toBe(0)
->and($issues[3]->misspelling->word)->toBe('shoud')
->and($issues[3]->misspelling->suggestions)->toBe([
'should',
'shroud',
'shod',
'shout',
]);
});

Expand Down Expand Up @@ -90,22 +90,23 @@
'typo\'s',
'types',
'type\'s',
])->and($issues[1]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FolderThatShouldBeIgnored/FileThatShoudBeIgnoredBecauseItsInsideWhitelistedFolder.php')
])->and($issues[1]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileWithTppyo.php')
->and($issues[1]->line)->toBe(0)
->and($issues[1]->misspelling->word)->toBe('shoud')
->and($issues[1]->misspelling->word)->toBe('tppyo')
->and($issues[1]->misspelling->suggestions)->toBe([
'should',
'shroud',
'shod',
'shout',
])->and($issues[2]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FileWithTppyo.php')
->and($issues[2]->line)->toBe(0)
->and($issues[2]->misspelling->word)->toBe('tppyo')
->and($issues[2]->misspelling->suggestions)->toBe([
'typo',
'Tokyo',
'typos',
'topi',
])
->and($issues[2]->file)->toEndWith('tests/Fixtures/FolderWithTypoos/FolderThatShouldBeIgnored/FileThatShoudBeIgnoredBecauseItsInsideWhitelistedFolder.php')
->and($issues[2]->line)->toBe(0)
->and($issues[2]->misspelling->word)->toBe('shoud')
->and($issues[2]->misspelling->suggestions)->toBe([
'should',
'shroud',
'shod',
'shout',
]);
});

Expand Down

0 comments on commit fdc4aa1

Please sign in to comment.