Get to zero violations of the CiviCRM code standards
The approach is likely to be different for each sniff.
If we think it is a bad sniff, then we should just remove it. If we think it is a good sniff then what we do depends on the number of violations.
Low number of violations -> just fix low number of violations
High number of violations -> consider adjusting the sniff OR fix all the violations, hopefully automatically.
Here is a summary of the current violations for https://lab.civicrm.org/dev/core/:
Array
(
[Drupal.WhiteSpace.ScopeIndent.IncorrectExact] => 18702
[Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction] => 2926
[Generic.PHP.UpperCaseConstant.Found] => 1766
[Drupal.Commenting.VariableComment.Missing] => 1690
[Drupal.Arrays.DisallowLongArraySyntax.Found] => 1137
[Drupal.Commenting.ClassComment.Short] => 502
[Drupal.Commenting.TodoComment.TodoFormat] => 460
[SlevomatCodingStandard.PHP.ShortList.LongListUsed] => 286
[Drupal.Classes.UseGlobalClass.RedundantUseStatement] => 192
[Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore] => 119
[Drupal.ControlStructures.InlineControlStructure.NotAllowed] => 91
[Squiz.Functions.MultiLineFunctionDeclaration.SpaceBeforeBrace] => 89
[Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter] => 85
[Squiz.ControlStructures.SwitchDeclaration.SpacingAfterBreak] => 67
[Drupal.Classes.UnusedUseStatement.UnusedUse] => 53
[SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator.NullCoalesceOperatorNotUsed] => 23
[Squiz.Functions.MultiLineFunctionDeclaration.SpaceBeforeOpenParen] => 19
[Drupal.Commenting.DataTypeNamespace.DataTypeNamespace] => 18
[Drupal.Commenting.GenderNeutralComment.GenderNeutral] => 16
[Drupal.Commenting.PostStatementComment.Found] => 12
[Drupal.Commenting.HookComment.HookCommentFormat] => 12
[Drupal.Commenting.FunctionComment.ParamTypeSpaces] => 12
[Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines] => 11
[Generic.WhiteSpace.DisallowTabIndent.TabsUsed] => 10
[Drupal.Commenting.FunctionComment.ReturnTypeSpaces] => 7
[Drupal.Files.EndFileNewline.TooMany] => 6
[Drupal.Commenting.InlineVariableComment.VarInline] => 6
[Squiz.WhiteSpace.SemicolonSpacing.Incorrect] => 6
[PEAR.Functions.FunctionCallSignature.SpaceAfterCloseBracket] => 6
[Drupal.Scope.MethodScope.Missing] => 5
[Squiz.WhiteSpace.OperatorSpacing.SpacingAfter] => 4
[Drupal.Files.EndFileNewline.NoneFound] => 4
[Squiz.CSS.SemicolonSpacing.NotAtEnd] => 4
[Generic.Formatting.DisallowMultipleStatements.SameLine] => 4
[Squiz.WhiteSpace.FunctionSpacing.AfterLast] => 3
[Squiz.CSS.EmptyClassDefinition.Found] => 3
[Drupal.Commenting.DocComment.ContentAfterOpen] => 3
[Drupal.Classes.ClassDeclaration.CloseBraceAfterBody] => 3
[Drupal.Commenting.VariableComment.IncorrectVarType] => 3
[Drupal.Commenting.InlineComment.SpacingAfterAtFunctionEnd] => 2
[Squiz.Arrays.ArrayDeclaration.SpaceAfterKeyword] => 2
[Drupal.Commenting.FunctionComment.ReturnCommentIndentation] => 2
[Squiz.WhiteSpace.SuperfluousWhitespace.EndFile] => 2
[Drupal.WhiteSpace.EmptyLines.EmptyLines] => 2
[Squiz.ControlStructures.SwitchDeclaration.SpacingAfterDefault] => 2
[Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterUse] => 2
[Squiz.PHP.NonExecutableCode.ReturnNotRequired] => 2
[Generic.Files.LineEndings.InvalidEOLChar] => 1
[Squiz.WhiteSpace.OperatorSpacing.SpacingBefore] => 1
[Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine] => 1
[Drupal.Arrays.Array.CommaLastItem] => 1
[Drupal.WhiteSpace.CloseBracketSpacing.ClosingWhitespace] => 1
[Drupal.WhiteSpace.OpenBracketSpacing.OpeningWhitespace] => 1
[Drupal.Classes.ClassDeclaration.SpaceBeforeBrace] => 1
[Squiz.WhiteSpace.FunctionSpacing.BeforeFirst] => 1
[Generic.PHP.DeprecatedFunctions.Deprecated] => 1
[Drupal.Functions.DiscouragedFunctions.Discouraged] => 1
[Squiz.Arrays.ArrayDeclaration.SpaceInEmptyArray] => 1
[Drupal.Commenting.FunctionComment.SpacingAfter] => 1
[Squiz.WhiteSpace.FunctionSpacing.After] => 1
[Squiz.WhiteSpace.SuperfluousWhitespace.StartFile] => 1
[PEAR.Files.IncludingFile.BracketsNotRequired] => 1
[PEAR.Functions.FunctionCallSignature.SpaceBeforeOpenBracket] => 1
[Squiz.WhiteSpace.ScopeKeywordSpacing.Incorrect] => 1
)
See https://lab.civicrm.org/michaelmcandrew/civicrm-coding-standards/-/tree/master#testing for instructions on how to repeat this.
Edited by Michael McAndrew