// docs / profanity

Profanity

Source code: github.com/pestphp/pest-plugin-profanity

The Profanity plugin scans your codebase for profanity in places like comments, constants, and properties, helping you maintain a more professional and respectful codebase. As developers, we've all faced moments of frustration — whether debugging a persistent issue or deciphering confusing code written by someone else. Those moments can sometimes lead to profanity slipping into your code.

To get started, require the plugin via Composer:

1composer require pestphp/pest-plugin-profanity --dev

Once the plugin is installed, you may use the --profanity option to generate a report of your profanity:

1./vendor/bin/pest --profanity

The Profanity plugin does not require you to write any tests. Instead, it analyzes your codebase and generates a report of your profanity. This report will display a list of files and their corresponding profanity results:

app/Providers/AppServiceProvider.phpOK
app/Models/User.phpOK
app/Http/Requests/Auth/LoginRequest.phpOK
app/Http/Requests/ProfileUpdateRequest.phppr20(shit)
app/Http/Controllers/Controller.phpOK
app/Http/Controllers/Auth/NewPasswordController.phpOK
app/Http/Controllers/Auth/EmailVerificationPromptController.phpOK
app/Http/Controllers/Auth/VerifyEmailController.phpOK
app/Http/Controllers/Auth/PasswordResetLinkController.phpOK
app/Http/Controllers/Auth/PasswordController.phppr18(dogshit)
app/Http/Controllers/Auth/EmailVerificationNotificationController.phpOK
app/Http/Controllers/Auth/AuthenticatedSessionController.phpOK
app/Http/Controllers/Auth/RegisteredUserController.phpOK
app/Http/Controllers/Auth/ConfirmablePasswordController.phpOK
app/Http/Controllers/ProfileController.phppr19(fuck), pr46(shit)
app/View/Components/GuestLayout.phpOK
app/View/Components/AppLayout.phpOK
app/Console/Commands/ListUsersCommand.phppr36(bastard)
 
  ERROR  Found 5 instances of profanity in 4 files

If any of your files contain profanity, they will be highlighted in red and displayed with their respective line numbers and the profane word(s) that were found.

For example, pr31(fuck) means that the word "fuck" was found on line 31.

Specific Language

Often, a codebase is written in a single language, so you may wish to flag profanity only for that language. To do this, you may use the --language option:

1./vendor/bin/pest --profanity --language=en

If needed, you may also pass in multiple comma-separated languages:

1./vendor/bin/pest --profanity --language=en,da

The supported languages are ar, da, en, es, it, ja, nl, pt_BR, and ru. By default, en is used if no language is specified.

Include Words

Sometimes you may wish to flag certain words specific to your application as profane. To do this, you may use the --include option:

1./vendor/bin/pest --profanity --include=elephpant

Exclude Words

Conversely, you may wish to exclude certain words from being flagged as profane. To do this, you may use the --exclude option:

1./vendor/bin/pest --profanity --exclude=elephpant

Compact Output

Often, when checking for profanity, you only want to see the files that actually contain it. To do this, you may use the --compact option:

1./vendor/bin/pest --profanity --compact

Different Formats

In addition, Pest may report the profanity results to a specific file:

1./vendor/bin/pest --profanity --output=my-report.json

Exclude Lines

Sometimes you may wish to exclude certain lines that contain profanity from being flagged, without excluding words from the whole application. In these cases, you may tell the checker to ignore specific lines:

1const string Fuck; // @pest-ignore-profanity

In this chapter, we have discussed Pest's Profanity plugin and how it helps you maintain a professional codebase. In the next chapter, we will explore the additional CLI options that Pest provides: CLI API Reference