Disable PHPCS rule of long condition

I don’t want to comment long code statements end, but PHP CodeSniffer with WordPress Coding Standards does complain with the following error:

End comment for long condition not found; expected “//end if”

So I added the following to the projects phpcs.xml

Sniff source code PHP_CodeSniffer/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php
For more help with PHPCS rules check out Listing phpcs rules and excluding commenting sniff

Advertisements

Listing phpcs rules and excluding commenting sniff

While testing WordPress-Coding-Standards PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions the following command came handy. It lists all enabled rules:

phpcs --standard=phpcs.xml -e

Output example

The WordPress Project standard contains 100 sniffs

Generic (34 sniffs)
-------------------
  Generic.Classes.DuplicateClassName
  Generic.Classes.OpeningBraceSameLine
  Generic.CodeAnalysis.EmptyStatement
  Generic.CodeAnalysis.ForLoopShouldBeWhileLoop
  Generic.CodeAnalysis.ForLoopWithTestFunctionCall
  Generic.CodeAnalysis.JumbledIncrementer
  Generic.CodeAnalysis.UnconditionalIfStatement
  Generic.CodeAnalysis.UnnecessaryFinalModifier
  Generic.CodeAnalysis.UnusedFunctionParameter
  Generic.CodeAnalysis.UselessOverridingMethod
  Generic.Commenting.DocComment
  Generic.Commenting.Fixme
  Generic.Commenting.Todo
  Generic.ControlStructures.InlineControlStructure
  Generic.Files.ByteOrderMark
  Generic.Files.EndFileNewline
  Generic.Files.LineEndings
  Generic.Formatting.DisallowMultipleStatements
  Generic.Formatting.SpaceAfterCast
  Generic.Functions.CallTimePassByReference
  Generic.Functions.OpeningFunctionBraceKernighanRitchie
  Generic.NamingConventions.UpperCaseConstantName
  Generic.PHP.BacktickOperator
  Generic.PHP.DeprecatedFunctions
  Generic.PHP.DisallowAlternativePHPTags
  Generic.PHP.DisallowShortOpenTag
  Generic.PHP.ForbiddenFunctions
  Generic.PHP.LowerCaseConstant
  Generic.PHP.LowerCaseKeyword
  Generic.PHP.NoSilencedErrors
  Generic.PHP.Syntax
  Generic.Strings.UnnecessaryStringConcat
  Generic.WhiteSpace.DisallowSpaceIndent
  Generic.WhiteSpace.ScopeIndent

PEAR (2 sniffs)
---------------
  PEAR.Functions.FunctionCallSignature
  PEAR.NamingConventions.ValidClassName

PSR2 (3 sniffs)
---------------
  PSR2.ControlStructures.ElseIfDeclaration
  PSR2.ControlStructures.SwitchDeclaration
  PSR2.Files.ClosingTag

Squiz (26 sniffs)
-----------------
  Squiz.Classes.SelfMemberReference
  Squiz.Commenting.BlockComment
  Squiz.Commenting.ClassComment
  Squiz.Commenting.ClosingDeclarationComment
  Squiz.Commenting.DocCommentAlignment
  Squiz.Commenting.EmptyCatchComment
  Squiz.Commenting.FileComment
  Squiz.Commenting.FunctionComment
  Squiz.Commenting.FunctionCommentThrowTag
  Squiz.Commenting.InlineComment
  Squiz.Commenting.VariableComment
  Squiz.ControlStructures.ControlSignature
  Squiz.Functions.FunctionDeclarationArgumentSpacing
  Squiz.Functions.FunctionDuplicateArgument
  Squiz.Operators.IncrementDecrementUsage
  Squiz.Operators.ValidLogicalOperators
  Squiz.PHP.CommentedOutCode
  Squiz.PHP.DisallowMultipleAssignments
  Squiz.PHP.DisallowSizeFunctionsInLoops
  Squiz.PHP.EmbeddedPhp
  Squiz.PHP.Eval
  Squiz.PHP.NonExecutableCode
  Squiz.Strings.ConcatenationSpacing
  Squiz.Strings.DoubleQuoteUsage
  Squiz.WhiteSpace.CastSpacing
  Squiz.WhiteSpace.SuperfluousWhitespace

WordPress (35 sniffs)
---------------------
  WordPress.Arrays.ArrayDeclarationSpacing
  WordPress.Arrays.ArrayIndentation
  WordPress.Arrays.ArrayKeySpacingRestrictions
  WordPress.Arrays.CommaAfterArrayItem
  WordPress.CSRF.NonceVerification
  WordPress.Classes.ClassInstantiation
  WordPress.CodeAnalysis.EmptyStatement
  WordPress.DB.RestrictedClasses
  WordPress.DB.RestrictedFunctions
  WordPress.Files.FileName
  WordPress.Functions.DontExtract
  WordPress.Functions.FunctionCallSignatureNoParams
  WordPress.NamingConventions.PrefixAllGlobals
  WordPress.NamingConventions.ValidFunctionName
  WordPress.NamingConventions.ValidHookName
  WordPress.NamingConventions.ValidVariableName
  WordPress.PHP.DevelopmentFunctions
  WordPress.PHP.DiscouragedPHPFunctions
  WordPress.PHP.POSIXFunctions
  WordPress.PHP.StrictComparisons
  WordPress.PHP.StrictInArray
  WordPress.PHP.YodaConditions
  WordPress.Variables.GlobalVariables
  WordPress.WP.AlternativeFunctions
  WordPress.WP.CapitalPDangit
  WordPress.WP.DeprecatedClasses
  WordPress.WP.DeprecatedFunctions
  WordPress.WP.DeprecatedParameters
  WordPress.WP.DiscouragedFunctions
  WordPress.WP.EnqueuedResources
  WordPress.WP.I18n
  WordPress.WP.PreparedSQL
  WordPress.WhiteSpace.CastStructureSpacing
  WordPress.WhiteSpace.DisallowInlineTabs
  WordPress.WhiteSpace.OperatorSpacing

Now I can disable that annoys me 🙂