179 lines
8.1 KiB
XML
179 lines
8.1 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>
|
|
<!-- 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>
|
|
|
|
<!-- 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>
|
|
|
|
<!-- 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 usage of BOMs -->
|
|
<rule ref="Generic.Files.ByteOrderMark"/>
|
|
<!-- Lines can be 80 chars long, show errors at 120 chars -->
|
|
<!--<rule ref="Generic.Files.LineLength">-->
|
|
<!--<properties>-->
|
|
<!--<property name="lineLimit" value="80"/>-->
|
|
<!--<property name="absoluteLineLimit" value="120"/>-->
|
|
<!--</properties>-->
|
|
<!--</rule>-->
|
|
<!-- Use Unix newlines -->
|
|
<rule ref="Generic.Files.LineEndings">
|
|
<properties>
|
|
<property name="eolChar" value="\n"/>
|
|
</properties>
|
|
</rule>
|
|
<!-- Limit classes to one per file -->
|
|
<rule ref="Generic.Files.OneClassPerFile"/>
|
|
<!-- Limit interfaces to one per file -->
|
|
<rule ref="Generic.Files.OneInterfacePerFile"/>
|
|
|
|
<!-- 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"/>-->
|
|
|
|
<!-- Disallow indenting with tabs -->
|
|
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
|
<!-- Control structures, classes, functions indent 2 spaces per level -->
|
|
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
|
<properties>
|
|
<property name="indent" value="2"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Closing brace should be at the same level as opening brace -->
|
|
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace">
|
|
<properties>
|
|
<property name="indent" value="2"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Each class must be in a file by itself and must be under a namespace -->
|
|
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
|
|
|
<!-- When referencing arrays there should be no whitespace between brackets -->
|
|
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
|
|
<!-- Class name and file name must match -->
|
|
<rule ref="Squiz.Classes.ClassFileName"/>
|
|
<!-- Classes should be named camel case with first letter capitalised -->
|
|
<rule ref="Squiz.Classes.ValidClassName"/>
|
|
<!-- 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" />
|
|
</ruleset>
|