Skip to content
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

Move phpcs configuration from the-build into a phpcs.xml file #185

Merged
merged 4 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"cweagans/composer-patches": true
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
Expand Down
11 changes: 3 additions & 8 deletions defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ phplint:
# Configuration for using PHP_CodeSniffer to review code according to the Drupal coding
# standards.
#
# DEPRECATED - to be removed in the-build 4.2
# This configuration is replaced by defaults/install/phpcs.xml.
#
# @see https://www.drupal.org/docs/develop/standards
# @see https://github.com/squizlabs/PHP_CodeSniffer
# @see https://www.drupal.org/project/coder
Expand All @@ -235,14 +238,6 @@ phpcs:
# Space-separated list of directories to review.
directories: "${drupal.root}/modules/custom ${drupal.root}/themes/custom"

# Comma-separated list of patterns for files and directories to exclude from the
# PHP_CodeSniffer review.
#
# This is deprecated and will be removed in 3.0, and build.xml will need to be updated then to
# use the extensions option (below). This option should not be used with Coder >= 8.3.7, which only
# checks php, inc, css, and js by default.
ignore: "*.md"

# Comma-separated list of extensions to check in the PHP_CodeSniffer review.
extensions: "php,module,inc,install,test,profile,theme,css,info,txt,yml,js"

Expand Down
5 changes: 2 additions & 3 deletions defaults/install/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@
</phplint>

<!-- Run PHP Code Sniffer. -->
<property name="phpcs.command" value="vendor/bin/phpcs --standard=${phpcs.standard} --extensions=${phpcs.extensions} ${phpcs.directories}" />
<echo msg="$> ${phpcs.command}" />
<exec command="${phpcs.command}" logoutput="true" checkreturn="true" />
<echo msg="$> vendor/bin/phpcs" />
<exec command="vendor/bin/phpcs" logoutput="true" checkreturn="true" />

<!-- Run PHP Mess Detector. -->
<property name="phpmd.command" value="vendor/bin/phpmd ${phpmd.directories} ${phpmd.format} ${phpmd.rulesets} --suffixes=${phpmd.suffixes}" />
Expand Down
39 changes: 39 additions & 0 deletions defaults/install/phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>

<!--
@see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml#the-annotated-sample-file
@see https://www.drupal.org/docs/develop/standards
@see https://github.com/squizlabs/PHP_CodeSniffer
@see https://www.drupal.org/project/coder
@see vendor/drupal/coder/coder_sniffer/
-->

<ruleset name="@projectname@">
<description>PHP_CodeSniffer configuration.</description>

<!-- Warnings and errors should throw an exception. -->
<config name="ignore_warnings_on_exit" value="0" />
<config name="ignore_errors_on_exit" value="0" />

<!-- Set extensions to scan. -->
<arg name="extensions" value="php,module,inc,install,test,profile,theme,info,yml,css,js"/>

<!-- Use colors in output. -->
<arg name="colors"/>

<!-- Show progress. -->
<arg value="p"/>

<!-- Include existing standards. -->
<rule ref="Drupal"/>
<rule ref="DrupalPractice"/>

<!-- Directories to scan. -->
<file>docroot/modules/custom</file>
<file>docroot/themes/custom</file>

<exclude-pattern>*/behat</exclude-pattern>
<exclude-pattern>*/node_modules</exclude-pattern>
<exclude-pattern>*/vendor</exclude-pattern>

</ruleset>
11 changes: 11 additions & 0 deletions targets/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@
</filterchain>
</copy>

<!-- Copy the phpcs.xml file template.
This doesn't do any property substitution except for the "projectname".
-->
<copy file="${phing.dir.install}/../defaults/install/phpcs.xml" tofile="${application.startdir}/phpcs.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="projectname" value="${projectname}" />
</replacetokens>
</filterchain>
</copy>

<!-- Copy other templates into place.
These copy commands use <expandproperties /> for property substitution.
-->
Expand Down