Skip to content

Commit

Permalink
Added slevomat coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Dec 23, 2023
1 parent 3983ea4 commit ade14ef
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"squizlabs/php_codesniffer": "^3.0",
"wp-coding-standards/wpcs": "^3.0",
"phan/phan": "^5.0",
"phpstan/phpstan": "^1.4"
"phpstan/phpstan": "^1.4",
"slevomat/coding-standard": "^8.14"
},
"scripts": {
"phpcs": "phpcs",
Expand Down
67 changes: 66 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,110 @@
<property name="blank_line_check" value="true"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard">
<!-- Conflicts with WPCS -->
<!--
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.NoEmptyLineBeforeClosingBrace"/>
<exclude name="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace.SpaceAfterArrayOpen"/>
<exclude name="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace.SpaceBeforeArrayClose"/>
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectAnnotationsGroup"/>
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectOrderOfAnnotationsGroup"/>
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison.DisallowedYodaComparison"/>
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName"/>
<exclude name="SlevomatCodingStandard.Whitespaces.DuplicateSpaces.DuplicateSpaces"/>
-->

<!-- Covered by PHPMD -->
<exclude name="SlevomatCodingStandard.Files.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>

<!-- Disabled due to style preferences -->
<!--
<exclude name="SlevomatCodingStandard.Arrays.DisallowPartiallyKeyed.DisallowedPartiallyKeyed"/>
<exclude name="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature.RequiredSingleLineSignature"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses.UselessParentheses"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireSingleLineCall.RequiredSingleLineCall"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions.NonFullyQualifiedException"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions.NonFullyQualified"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseFromSameNamespace.UseFromSameNamespace"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces.NonFullyQualified"/>
<exclude name="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators.DisallowedPreIncrementOperator"/>
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint"/>
<exclude name="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable.DisallowedSuperGlobalVariable"/>
-->
</rule>

<!--
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<!- Needed to not conflict with "case" spacing ->
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="annotationsGroups" type="array">
<element value="@package"/>
<element value="@see"/>
<element value="@covers"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
<element value="@phan-,@SuppressWarnings,phpcs:"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Complexity.Cognitive">
<properties>
<property name="maxComplexity" value="10"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<properties>
<property name="ignoreOneLineTrailingIf" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator">
<properties>
<property name="lineLengthLimit" value="121"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition">
<properties>
<property name="alwaysForSimpleConditions" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Files.LineLength">
<properties>
<property name="ignoreComments" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowPartialUses" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
-->
</ruleset>

0 comments on commit ade14ef

Please sign in to comment.