Skip to content

Commit

Permalink
add more tolerated words
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPurvis committed Aug 7, 2024
1 parent 8471c4c commit 0c94515
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Config/tolerated.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
return [
'class',
'subject',
'assume',
'start',
'object',
'parse',
'assign',
'pass',
];
1 change: 0 additions & 1 deletion src/Config/words.php
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,6 @@
'shat',
'she-male',
'sheeeet',
'sheet',
'sheister',
'shemal3',
'shemale',
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, '', $fileContents);
$fileContents = str_replace([$toleratedWord, ucwords($toleratedWord)], '', $fileContents);
}

$foundWords = array_filter($words, fn ($word): bool => preg_match('/'.preg_quote($word, '/').'/i', $fileContents) === 1);
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixtures/HasCapitalisedToleratedProfanity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Tests\Fixtures;

class HasCapitalisedToleratedProfanity
{
// We should Start by adding a construct
}
5 changes: 5 additions & 0 deletions tests/toHaveNoProfanity.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
expect('Tests\Fixtures\HasProfanityInComment')
->toHaveNoProfanity(excluding: ['shit']);
});

it('passes if a file contains capitalised tolerated profanity', function () {
expect('Tests\Fixtures\HasCapitalisedToleratedProfanity')
->toHaveNoProfanity();
});

0 comments on commit 0c94515

Please sign in to comment.