Profanify is a PestPHP plugin created by Jon Purvis that helps detect and flag instances of profanity within your application. This tool lets you test your codebase for common swear words that may have inadvertently entered your code.
Install Profanify using composer:
composer require jonpurvis/profanify --dev
In your Pest PHP test file, you can check for profanity using a simple assertion:
expect('App') ->toHaveNoProfanity();
This scans your entire codebase for any instances of profanity. To narrow the scope to specific directories, simply modify the path:
expect('App\Http\Controllers') ->toHaveNoProfanity();
Profanify is flexible in its configuration. You can also:
- Add custom phrases to test for profanity beyond the default word lists
- Specify exceptions to ignore certain phrases that would otherwise be flagged
When a test fails due to profanity being detected, Profanify will display the offending file and line number in the output, making locating and removing unwanted content easy.
Profanify currently detects profanity in the following languages:
- English
- Italian
- Arabic
- Portuguese
The project welcomes contributions! Whether you'd like to add support for additional languages or make other improvements, feel free to submit pull requests on GitHub.
Learn more about this package and view the source code on GitHub.