| title | description |
|---|---|
Profanity |
The Profanity plugin will scan your codebase for profanity in places like comments, constants and properties |
Source code: github.com/pestphp/pest-plugin-profanity
The Profanity plugin will scan your codebase for profanity in places like comments, constants and properties. This can help you maintain a more professional and respectful codebase. As developers, we've all faced moments of frustration, whether it be debugging a persistent issue or trying to decipher confusing code written by someone else. These moments can sometimes result in the inclusion of profanity in your code.
To start using Pest's Profanity plugin, you need to require the plugin via Composer.
composer require pestphp/pest-plugin-profanity --devAfter requiring the plugin, you may utilize the --profanity option to generate a report of your profanity.
./vendor/bin/pest --profanityProfanity does not require you to write any tests. Instead, it analyses your codebase and generates a report of your profanity. This report will display a list of files and their corresponding profanity results.
If any of your files contain profanity, they will be highlighted in red and displayed using their respective line numbers and the profane word(s) that have been found.
As an example, pr31(fuck) means that the word "fuck" was found on line 31.
Often, a codebase is a single language, so you would only want to flag profanity for the language of the codebase. To
do this, you can use the --language option:
./vendor/bin/pest --profanity --language=enIf needed, you can pass in multiple comma separated languages too:
./vendor/bin/pest --profanity --language=en,daWe currently support: ar, da, en, es, it, ja, nl, pt_BR and ru. If no language is specified,
we use en as the default.
There may be times when you want to flag certain words specific to your application as profane. To do this, you can use
the --include option:
./vendor/bin/pest --profanity --include=elephpantThere may be times when you want to exclude certain words from being flagged up as profane. To do this, you can use the
--exclude option:
./vendor/bin/pest --profanity --exclude=elephpantOften, when checking for profanity, you only want to see files that do contain profanity. To do this, you can use
the --compact option:
./vendor/bin/pest --profanity --compactIn addition, Pest supports reporting the profanity results to a specific file:
./vendor/bin/pest --profanity --output=my-report.jsonIf you wish to exclude certain lines that contain profanity from being flagged, without excluding words from the whole application, you can tell the checker to ignore certain lines:
const string Fuck; // @pest-ignore-profanityIn this chapter, we have discussed Pest's Profanity plugin and how it can be used to help you maintain a professional codebase. In the following chapter, we will explore additional CLI options that Pest provides: CLI API Reference
