204 lines
10 KiB
XML
204 lines
10 KiB
XML
<?xml version="1.0"?>
|
|
<ruleset name="MailPoet">
|
|
<config name="installed_paths" value="tasks/code_sniffer/vendor/squizlabs/php_codesniffer,tasks/code_sniffer/vendor/phpcompatibility/php-compatibility,tasks/code_sniffer/vendor/slevomat/coding-standard"/>
|
|
<description>MailPoet specific rule set</description>
|
|
<exclude-pattern>*/phpstan/woocommerce.php</exclude-pattern>
|
|
|
|
<!-- Files -->
|
|
<rule ref="Generic.Files.ByteOrderMark"/> <!-- Disallow usage of BOMs -->
|
|
<rule ref="Generic.Files.LineEndings"> <!-- Use Unix newlines -->
|
|
<properties>
|
|
<property name="eolChar" value="\n"/>
|
|
</properties>
|
|
</rule>
|
|
<rule ref="PSR2.Files.EndFileNewline"/>
|
|
<rule ref="Generic.Files.InlineHTML">
|
|
<exclude-pattern>lib/Form/Widget.php</exclude-pattern>
|
|
<exclude-pattern>lib/PostEditorBlocks/SubscriptionFormBlock.php</exclude-pattern>
|
|
</rule>
|
|
|
|
<!-- Namespaces -->
|
|
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
|
|
<properties>
|
|
<property name="linesCountBeforeNamespace" value="1" />
|
|
<property name="linesAfterNamespace" value="1" />
|
|
</properties>
|
|
</rule>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/>
|
|
|
|
<!-- Namespaces - "use" statements -->
|
|
<rule ref="PSR2.Namespaces.UseDeclaration"/> <!-- One namespace per use, one blank line after final use statement -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/> <!-- Prohibits multiple uses separated by commas -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
|
|
<properties>
|
|
<property name="linesCountBeforeFirstUse" value="1" />
|
|
<property name="linesCountAfterLastUse" value="1" />
|
|
<property name="linesCountBetweenUseTypes" value="1" />
|
|
</properties>
|
|
</rule>
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> <!-- Disallow unused "use" statements -->
|
|
<properties>
|
|
<property name="searchAnnotations" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Classes, interfaces, traits -->
|
|
<rule ref="Generic.Files.OneClassPerFile"/> <!-- Limit classes to one per file -->
|
|
<rule ref="Generic.Files.OneInterfacePerFile"/> <!-- Limit interfaces to one per file -->
|
|
<rule ref="Generic.Classes.DuplicateClassName"/> <!-- Disallow same class or interface name in multiple files -->
|
|
<rule ref="Generic.Classes.OpeningBraceSameLine"/> <!-- Opening brace of a class/interface/trait must be on the same line as declaration -->
|
|
<rule ref="Squiz.Classes.ClassFileName"/> <!-- Class name and file name must match -->
|
|
<rule ref="Squiz.Classes.ValidClassName"/> <!-- Classes should be named camel case with first letter capitalised -->
|
|
<rule ref="Squiz.Classes.LowercaseClassKeywords"/> <!-- The "class" keyword must be lowercased -->
|
|
<rule ref="PSR1.Classes.ClassDeclaration"/> <!-- Each class must be in a file by itself and must be under a namespace -->
|
|
<rule ref="PSR2.Classes.PropertyDeclaration"/> <!-- Properties must have visibility, no trailing "_", one property per statement, "static" before visibility -->
|
|
|
|
<!-- checks for unused methods, unused or write-only properties in a class and unused private constants -->
|
|
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements">
|
|
<properties>
|
|
<property name="alwaysUsedPropertiesAnnotations" type="array"
|
|
value="@ORM\Column,@ORM\ManyToOne,@ORM\OneToMany,@ORM\ManyToMany,@ORM\OneToOne"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Indentation -->
|
|
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/> <!-- Disallow indenting with tabs -->
|
|
<rule ref="Generic.WhiteSpace.ScopeIndent"> <!-- Control structures, classes, functions indent 2 spaces per level -->
|
|
<properties>
|
|
<property name="indent" value="2"/>
|
|
</properties>
|
|
</rule>
|
|
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"> <!-- Closing brace should be at the same level as opening brace -->
|
|
<properties>
|
|
<property name="indent" value="2"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Spacing -->
|
|
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
|
|
<properties>
|
|
<property name="spacing" value="1" /> <!-- 1 space between methods -->
|
|
<property name="spacingBeforeFirst" value="0" /> <!-- no spaces before first method -->
|
|
<property name="spacingAfterLast" value="0" /> <!-- no spaces after last method -->
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Typehints -->
|
|
<rule ref="Generic.PHP.LowerCaseType"/> <!-- Force PHP 7 param and return types to be lowercased -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/> <!-- Enforces short scalar typehint variants ("int", not "integer", etc.) -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/> <!-- Space between type and name, no space between "?" and type -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/> <!-- Space between type and name, no space between "?" and type -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/> <!-- No space before colon, one space before "?", no space after -->
|
|
|
|
<!-- Reports empty comments -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
|
|
<!-- This sniff enforces trailing commas in multi-line arrays -->
|
|
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
|
|
<!-- Disallows assignments in if, elseif and do-while loop conditions -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
|
|
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
|
|
<!-- Control structures must have at least one statement in the body -->
|
|
<!--<rule ref="Generic.CodeAnalysis.EmptyStatement"/>-->
|
|
<!-- For loops with only second expression should be while loops -->
|
|
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
|
|
<!-- Same variable should not be used for two nested loops as incrementers -->
|
|
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
|
|
<!-- Shouldn't use if statements that are always evaluated -->
|
|
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
|
|
<!-- Final methods don't need final in classes marked as final -->
|
|
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
|
|
<!-- All parameters in function signature should be used within the function -->
|
|
<!--<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>-->
|
|
<!-- Don't use methods that extend and only call the parent method -->
|
|
<!--<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>-->
|
|
|
|
<!-- Only short array syntax is allowed -->
|
|
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
|
<rule ref="Squiz.Strings.ConcatenationSpacing">
|
|
<properties>
|
|
<property name="ignoreNewlines" value="true" />
|
|
<property name="spacing" value="1" />
|
|
</properties>
|
|
</rule>
|
|
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
|
|
<properties>
|
|
<property name="ignoreNewlines" value="true" />
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Disallow multiple statements on a single line -->
|
|
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
|
<!-- There should be no space after cast -->
|
|
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
|
|
|
|
<!-- Function calls should have one space after comma -->
|
|
<!-- And single spaces should surround equals sign for default values -->
|
|
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
|
<!-- Opening brace should be on the same line as the function declaration -->
|
|
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
|
|
|
|
<!-- Nesting level should be kept under 5, not more than 10 -->
|
|
<rule ref="Generic.Metrics.NestingLevel"/>
|
|
|
|
<!-- Method names should use camelCaps -->
|
|
<rule ref="PSR1.Methods.CamelCapsMethodName"/>
|
|
<!-- Constants should be all uppercase with underscores separating words -->
|
|
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
|
|
|
<!-- Disallow characters before PHP opening tag -->
|
|
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
|
|
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
|
<!-- true, false, null should always be lower case -->
|
|
<rule ref="Generic.PHP.LowerCaseConstant"/>
|
|
<!-- System keywords should always be lower case -->
|
|
<rule ref="Generic.PHP.LowerCaseKeyword"/>
|
|
<!-- Disallow silencing errors with @ -->
|
|
<!--<rule ref="Generic.PHP.NoSilencedErrors"/>-->
|
|
|
|
<!-- When referencing arrays there should be no whitespace between brackets -->
|
|
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
|
|
<!-- Checks for empty catch statements. It must at least have a comment -->
|
|
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
|
|
<!-- There should be a space between each foreach condition -->
|
|
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
|
|
<!-- There should be a space between each for condition -->
|
|
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
|
|
|
|
<!-- There should not be commented out code -->
|
|
<rule ref="Squiz.PHP.CommentedOutCode">
|
|
<properties>
|
|
<property name="maxPercentage" value="50"/>
|
|
</properties>
|
|
</rule>
|
|
<!-- Discourage use of debug functions -->
|
|
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
|
|
<!-- Discourage use of eval -->
|
|
<rule ref="Squiz.PHP.Eval"/>
|
|
<!-- Warn about non executable code -->
|
|
<rule ref="Squiz.PHP.NonExecutableCode"/>
|
|
|
|
<!-- Warn about usage of "$this" in static methods -->
|
|
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
|
|
|
<!-- Remove space between if/for/while and opening parenthesis -->
|
|
<rule ref="MailPoet.ControlStructures.ControlSignature" />
|
|
|
|
<!-- Run against the PHPCompatibility ruleset -->
|
|
<rule ref="PHPCompatibility" />
|
|
|
|
<!-- Visibility MUST be declared on all methods. -->
|
|
<rule ref="Squiz.Scope.MethodScope"/>
|
|
|
|
<!-- Enforce camelCase naming of variables and properties -->
|
|
<rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps"/>
|
|
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
|
|
<rule ref="Squiz.NamingConventions.ValidVariableName.StringNotCamelCaps"/>
|
|
</ruleset>
|