diff --git a/src/ProfanityAnalyser.php b/src/ProfanityAnalyser.php index 563a556..f3349b8 100644 --- a/src/ProfanityAnalyser.php +++ b/src/ProfanityAnalyser.php @@ -56,15 +56,13 @@ public static function analyse(string $file, array $excludingWords = [], array $ $foundProfanity = []; foreach ($words as $word) { - if (preg_match('/\b'.preg_quote($word, '/').'\b/i', $fileContents) === 1) { - foreach ($lines as $lineNumber => $line) { - $key = $lineNumber.'-'.$word; - if (preg_match('/\b'.preg_quote($word, '/').'\b/i', $line) === 1 && ! isset($foundProfanity[$key])) { - // Skip reporting profanity if the line contains the ignore annotation - if (! str_contains($line, '@pest-ignore-profanity')) { - $errors[] = new Error($file, $lineNumber + 1, $word); - $foundProfanity[$key] = true; - } + foreach ($lines as $lineNumber => $line) { + $key = $lineNumber.'-'.$word; + if (preg_match('/(?