Skip to content

Written Additional PHPCS Rules for Detecting Code Quality Issues & Even Automatically fixing it using PHPCBF

License

Notifications You must be signed in to change notification settings

PushpenderIndia/rtSniffs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rtSniffs

Written Additional PHPCS Rules for Detecting Code Quality Issues & Even Automatically fixing it using PHPCBF

Installation (If Installed phpcs using composer)

  1. Clone this repo
git clone https://github.com/pushpenderindia/rtSniffs ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/rtSniffs 
  1. Check whether rtSniffs is getting detected by phpcs
phpcs -i

2.1 Expected Output (Should contain rtSniffs):

➜  rtSniffs git:(main) ✗ phpcs -i
The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, rtSniffs, WordPress-VIP-Go, WordPressVIPMinimum, PHPCompatibility, PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP, Modernize, NormalizedArrays, Universal, PHPCSUtils, VariableAnalysis, WordPress, WordPress-Core, WordPress-Docs and WordPress-Extra

Usage

  1. Detecting Code Quality Issues in current directory
phpcs --standard=rtSniffs .
  1. Fixing Issues using phpcbf
phpcs --standard=rtSniffs .

NOTE

  • rtSniffs is in developmental stage, so use phpcs command only, don't rely on phpcbf for autofix.

Current Coding Sniffs

  • Sniffs.Commenting.MissingReturnTagSniff: Checks if docblock contains @return Type
  • Sniffs.Spacing.ExcessiveBlankLineSniff: Detects more than one consecutive blank line.
  • Sniffs.Spacing.MissingSpaceBeforeCommentSniff: Checking if there is a space before start of single line comment.
  • Sniffs.Spacing.MissingSpaceAfterDeclarationSniff: Ensure there is a blank line after function, loop, or if statement declarations.
  • ValidateFunctionReturnType: Validate the function return type and if exceptions are not handled then throw warning

About

Written Additional PHPCS Rules for Detecting Code Quality Issues & Even Automatically fixing it using PHPCBF

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages