Skip to content

Commit

Permalink
Merge pull request #11 from faissaloux/fix-tolerated-words-not-detected
Browse files Browse the repository at this point in the history
Fix tolerated words not detected
  • Loading branch information
JonPurvis authored Aug 11, 2024
2 parents 3d1c45b + 305e544 commit 603ac39
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Config/tolerated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

// SHOULD ALL WORDS BE lowercase!

return [
'class',
'subject',
Expand Down
2 changes: 2 additions & 0 deletions src/Config/words.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

// SHOULD ALL WORDS BE lowercase!

return [
'69',
'@55',
Expand Down
2 changes: 1 addition & 1 deletion src/Expectations/Profanity.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function (ObjectDescription $object) use (&$foundWords, $excluding, $including):
$fileContents = (string) file_get_contents($object->path);

foreach ($toleratedWords as $toleratedWord) {
$fileContents = str_replace([$toleratedWord, ucwords($toleratedWord)], '', $fileContents);
$fileContents = str_replace($toleratedWord, '', strtolower($fileContents));
}

$foundWords = array_filter($words, fn ($word): bool => preg_match('/'.preg_quote($word, '/').'/i', $fileContents) === 1);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/HasCapitalisedToleratedProfanity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

class HasCapitalisedToleratedProfanity
{
// We should Start by adding a construct
// We should Start or StArT by adding a construct
}

0 comments on commit 603ac39

Please sign in to comment.