-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: update phpcs.xml from Drupal examples #670
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,26 @@ | ||
<?xml version="1.0" ?> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Based on Examples for Developers phpcs.xml.dist. Modified for use for Drupal | ||
projects. See https://git.drupalcode.org/project/examples/blob/HEAD/phpcs.xml.dist | ||
for source. | ||
--> | ||
<ruleset name="AxelerantDrupal"> | ||
<description>Axelerant baseline rules for PHP CodeSniffer</description> | ||
|
||
<!--Exclude folders used by common frontend tools.--> | ||
<exclude-pattern>*/bower_components/*</exclude-pattern> | ||
<exclude-pattern>*/node_modules/*</exclude-pattern> | ||
<!--Exclude third party code.--> | ||
<exclude-pattern>./assets/vendor/*</exclude-pattern> | ||
|
||
<file>.</file> | ||
|
||
<!-- PHPCS Arguments --> | ||
<arg name="extensions" value="inc,yml,install,module,php,profile,test,theme" /> | ||
<arg name="colors" /> | ||
|
||
<!--Allow global variables in settings file.--> | ||
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable"> | ||
<exclude-pattern>settings(\.[a-zA-Z0-9]+)?\.php</exclude-pattern> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove this, phpcs will stop catching UndefinedVariable. Currently it did not catch it in settings.php because
Same applies for other |
||
</rule> | ||
|
||
<!--Allow section separators in settings.php file.--> | ||
<rule ref="DrupalPractice.Commenting.CommentEmptyLine.SpacingAfter"> | ||
<exclude-pattern>settings(\.[a-zA-Z0-9]+)?\.php</exclude-pattern> | ||
</rule> | ||
<rule ref="Drupal.Commenting.InlineComment.InvalidEndChar"> | ||
<exclude-pattern>settings(\.[a-zA-Z0-9]+)?\.php</exclude-pattern> | ||
</rule> | ||
<rule ref="Drupal.Commenting.InlineComment.NoSpaceBefore"> | ||
<exclude-pattern>settings(\.[a-zA-Z0-9]+)?\.php</exclude-pattern> | ||
</rule> | ||
<rule ref="Drupal.Commenting.InlineComment.SpacingAfter"> | ||
<exclude-pattern>settings(\.[a-zA-Z0-9]+)?\.php</exclude-pattern> | ||
</rule> | ||
|
||
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.--> | ||
<!-- Drupal sniffs --> | ||
<rule ref="Drupal"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing in doc comment can be achieved using |
||
<rule ref="Drupal.Arrays.Array"> | ||
<!-- Sniff for these errors: CommaLastItem --> | ||
<exclude name="Drupal.Arrays.Array.ArrayClosingIndentation"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These rules exclude were present earlier too. I removed it. It improves code readability when arrays are properly indented. So I will suggest to remove it. |
||
<exclude name="Drupal.Arrays.Array.ArrayIndentation"/> | ||
<exclude name="Drupal.Arrays.Array.LongLineDeclaration"/> | ||
</rule> | ||
<rule ref="Drupal.Classes.ClassCreateInstance"/> | ||
<rule ref="Drupal.Classes.ClassDeclaration"/> | ||
<rule ref="Drupal.Classes.FullyQualifiedNamespace"/> | ||
<rule ref="Drupal.Classes.InterfaceName"/> | ||
<rule ref="Drupal.Classes.UnusedUseStatement"/> | ||
<rule ref="Drupal.Classes.UseGlobalClass"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason for removing this? This checks the following. You cannot |
||
<rule ref="Drupal.Classes.UseLeadingBackslash"/> | ||
<rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/> | ||
<rule ref="Drupal.CSS.ColourDefinition"/> | ||
|
@@ -342,17 +314,8 @@ | |
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" /> | ||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/> | ||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> | ||
<rule ref="Squiz.WhiteSpace.OperatorSpacing"> | ||
<properties> | ||
<property name="ignoreNewlines" value="true"/> | ||
</properties> | ||
</rule> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This checks operator spacing rules. Here are few examples. Correct: Correct $abc = [
"abc3" => "dssdsd3",
"abc41" => [
"dssdsd4"
],
];
$abc = [
"abc3" => "dssdsd3",
"abc41" =>
[
"dssdsd4"
],
]; Incorrect $abc = [
"abc3"=> "dssdsd3",
"abc41" =>[
"dssdsd4"
],
]; |
||
|
||
<!-- Zend sniffs --> | ||
<rule ref="Zend.Files.ClosingTag"/> | ||
|
||
<!-- sniffs from https://github.com/acquia/coding-standards-php --> | ||
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are from Acquia coding standards and sorts use statements in ascending order. This can be removed as sorting manually is a challenge but phpcbf can help sort it. |
||
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also keep this to discourage direct use of $_GET, $_POST, $_SERVER and $GLOBALS etc. |
||
|
||
</ruleset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\contrib_tracker\EventSubscriber; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hussainweb Exclude is mostly for use when we run phpcs directly. but again, if we don't pass include directories, it will run on whole codebase so if we plan to keep this up and allow user to run
phpcs -v
then we will have to exclude other directories as well and I think, this will be overkill. We can remove this as we have exclude dirs specified in grumphp conf file.Mostly exclude all these dirs