Skip to content

Commit 24ccb05

Browse files
authored
tests(phpcs): Enable Coder Sniffer in Travis CI, exclude failing standards for now (#1058)
1 parent 0c07a44 commit 24ccb05

3 files changed

Lines changed: 78 additions & 9 deletions

File tree

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,19 @@ install:
8989
# require also triggers a full 'composer install'.
9090
- composer --no-interaction --working-dir=$DRUPAL_BUILD_DIR require webonyx/graphql-php:^0.13.1 drupal/typed_data:^1.0
9191
- composer --no-interaction --working-dir=$DRUPAL_BUILD_DIR run-script drupal-phpunit-upgrade
92+
93+
# Install PHPCS to check for Drupal coding standards.
94+
- travis_retry composer global require drupal/coder
95+
- $HOME/.composer/vendor/bin/phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer
9296

9397
script:
9498
# Run the unit tests using phpdbg if the environment variable is 'true'.
9599
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
96100
then phpdbg -qrr $DRUPAL_BUILD_DIR/vendor/bin/phpunit --configuration $DRUPAL_BUILD_DIR/core/phpunit.xml --coverage-clover $TRAVIS_BUILD_DIR/coverage.xml $TRAVIS_BUILD_DIR;
97101
fi
102+
103+
# Check for coding standards violations.
104+
- cd $DRUPAL_BUILD_DIR/modules/graphql && $HOME/.composer/vendor/bin/phpcs
98105

99106
# Run the unit tests with standard php otherwise.
100107
- if [[ "$WITH_PHPDBG_COVERAGE" != "true" ]];

examples/graphql_composable/src/Wrappers/Response/ArticleResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<?php
32

43
declare(strict_types = 1);

phpcs.xml.dist

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,77 @@
33
<description>Default PHP CodeSniffer configuration for GraphQL.</description>
44
<file>.</file>
55

6-
<arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
6+
<arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
77

8-
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
9-
<!-- Annotations must use the same property names as in the configuration. -->
10-
<exclude-pattern>src/Annotation</exclude-pattern>
11-
<exclude-pattern>src/Core/Annotation</exclude-pattern>
8+
<rule ref="Drupal">
9+
<!-- TODO: those rules are disabled for now until we fix the coding standards for them. -->
10+
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace"/>
11+
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace"/>
12+
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd"/>
13+
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter"/>
14+
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse"/>
15+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeComma"/>
16+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction"/>
17+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceBeforeBrace"/>
18+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After"/>
19+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.AfterLast"/>
20+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.Before"/>
21+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.BeforeFirst"/>
22+
<exclude name="Squiz.WhiteSpace.LanguageConstructSpacing.Incorrect"/>
23+
<exclude name="Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore"/>
24+
<exclude name="Squiz.WhiteSpace.OperatorSpacing.SpacingAfter"/>
25+
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/>
26+
<exclude name="Drupal.Arrays.Array.CommaLastItem"/>
27+
<exclude name="Drupal.Arrays.Array.LongLineDeclaration"/>
28+
<exclude name="Drupal.Arrays.DisallowLongArraySyntax.Found"/>
29+
<exclude name="Drupal.Classes.ClassDeclaration.CloseBraceAfterBody"/>
30+
<exclude name="Drupal.Classes.FullyQualifiedNamespace.UseStatementMissing"/>
31+
<exclude name="Drupal.Classes.PropertyDeclaration.ScopeMissing"/>
32+
<exclude name="Drupal.Classes.UnusedUseStatement.UnusedUse"/>
33+
<exclude name="Drupal.Commenting.ClassComment.Missing"/>
34+
<exclude name="Drupal.Commenting.DataTypeNamespace.DataTypeNamespace"/>
35+
<exclude name="Drupal.Commenting.DocComment.MissingShort"/>
36+
<exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
37+
<exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
38+
<exclude name="Drupal.Commenting.DocComment.SpacingAfter"/>
39+
<exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
40+
<exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
41+
<exclude name="Drupal.Commenting.DocCommentAlignment.SpaceBeforeStar"/>
42+
<exclude name="Drupal.Commenting.FileComment.Missing"/>
43+
<exclude name="Drupal.Commenting.FunctionComment.IncorrectParamVarName"/>
44+
<exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
45+
<exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
46+
<exclude name="Drupal.Commenting.FunctionComment.InvalidReturn"/>
47+
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
48+
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
49+
<exclude name="Drupal.Commenting.FunctionComment.MissingParamName"/>
50+
<exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
51+
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
52+
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentIndentation"/>
53+
<exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
54+
<exclude name="Drupal.Commenting.FunctionComment.ParamNameNoMatch"/>
55+
<exclude name="Drupal.Commenting.FunctionComment.ReturnCommentIndentation"/>
56+
<exclude name="Drupal.Commenting.FunctionComment.ReturnTypeSpaces"/>
57+
<exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
58+
<exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
59+
<exclude name="Drupal.Commenting.InlineComment.NoSpaceBefore"/>
60+
<exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>
61+
<exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
62+
<exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
63+
<exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
64+
<exclude name="Drupal.Commenting.VariableComment.Missing"/>
65+
<exclude name="Drupal.ControlStructures.ControlSignature.NewlineAfterCloseBrace"/>
66+
<exclude name="Drupal.Files.EndFileNewline.NoneFound"/>
67+
<exclude name="Drupal.Files.EndFileNewline.TooMany"/>
68+
<exclude name="Drupal.Files.LineLength.TooLong"/>
69+
<exclude name="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
70+
<exclude name="Drupal.WhiteSpace.CloseBracketSpacing.ClosingWhitespace"/>
71+
<exclude name="Drupal.WhiteSpace.Comma.NoSpace"/>
72+
<exclude name="Drupal.WhiteSpace.Comma.TooManySpaces"/>
73+
<exclude name="Drupal.WhiteSpace.OpenBracketSpacing.OpeningWhitespace"/>
74+
<exclude name="Drupal.WhiteSpace.OpenTagNewline.BlankLine"/>
75+
<exclude name="Drupal.WhiteSpace.ScopeClosingBrace.Line"/>
76+
<exclude name="Drupal.WhiteSpace.ScopeIndent.IncorrectExact"/>
1277
</rule>
1378

14-
<!-- We always want short array syntax only. -->
15-
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
16-
</ruleset>
79+
</ruleset>

0 commit comments

Comments
 (0)