Skip to content

Commit

Permalink
Merge branch 'develop' into DEV-71-replace-drupal-check-with-phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
byrond authored Sep 24, 2024
2 parents b1f828b + ba04c00 commit f67a1bb
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
working_directory: ~/project
docker:
- image: cimg/php:8.1.18-browsers
- image: cimg/php:8.3-browsers
- image: cimg/mysql:5.7
command: --max_allowed_packet=16M
environment:
Expand Down
2 changes: 1 addition & 1 deletion defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ phpmd:
# Output format for phpmd.
format: text
# Comma-separated list of ruleset paths or names.
rulesets: "${build.thebuild.dir}/defaults/standard/phpmd.xml"
rulesets: "${build.dir}/phpmd.xml"
# File extensions to review.
suffixes: php,inc,module,theme,profile,install,test

Expand Down
25 changes: 15 additions & 10 deletions defaults/install/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
working_directory: ~/${projectname}
docker:
- image: cimg/php:8.1-browsers
- image: cimg/php:8.3-browsers
- image: cimg/mysql:5.7
command: --max_allowed_packet=16M
environment:
Expand All @@ -20,7 +20,7 @@ jobs:
environment:
- PALANTIR_ENVIRONMENT: circleci
- DRUPAL_ROOT: ${drupal.root}
- NODE_VERSION: 8
- NODE_VERSION: 18

steps:
- run:
Expand Down Expand Up @@ -50,10 +50,11 @@ jobs:
name: Configure URL in /etc/hosts
command: echo 127.0.0.1 ${CIRCLE_PROJECT_REPONAME}.local | sudo tee -a /etc/hosts

# Composer package cache
# Package cache
- restore_cache:
keys:
- composer-v1-
- package-cache-v1-

# Source cache
- restore_cache:
keys:
Expand All @@ -64,15 +65,19 @@ jobs:
- run:
name: Composer install
command: composer install --no-interaction --prefer-dist
- run:
name: Yarn install
command: yarn install

# Composer package cache - update when the contents of the Composer cache directory
# change
- run: ls -1R ~/.cache/composer/ > /tmp/composer-cache.txt
# Package cache. This is updated when the contents of the ~/.cache directory change.
# Both Composer and Yarn use this directory.
- run: ls -1R ~/.cache/ > /tmp/package-cache.txt
- save_cache:
key: composer-v1-{{ checksum "/tmp/composer-cache.txt" }}
key: package-cache-v1-{{ checksum "/tmp/package-cache.txt" }}
paths:
- ~/.cache/composer
# Source cache - update when branch changes
- ~/.cache

# Source cache. This is updated for each different branch.
- save_cache:
key: source-v1-{{ .Branch }}
paths:
Expand Down
4 changes: 2 additions & 2 deletions defaults/install/.circleci/deploy-acquia-example
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
deploy:
working_directory: ~/project
docker:
- image: cimg/php:8.1-browsers
- image: cimg/php:8.3-browsers
environment:
- NODE_VERSION: 8
- NODE_VERSION: 18
- GITHUB_PUBKEY: "github.com,192.30.253.113 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="
- ACQUIA_PUBKEY: "svn-23450.prod.hosting.acquia.com,54.245.120.237 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDit0Rj8j59i9Gj2vOg2TXjIbPswIc27PwncapyBLi9R3FtECXq+md1BfykBJjME83m78CtqkTlWwNZu+LyhF+IYlshKo82JXQzV4kWwi5L9H7KpdyFDMDLVCNVYmU4EQY9ngRq1cwbMBYsfWxv4sSlbsvZv2C8U7luNoc4SiBY4sGpgiMJLFOHWRw6YvhOamLTKfxSoJUT8uRbfkamxas1EK21XjvrdUSN0Bf5LmTdvs/9iIaUH4AlYr0SW0tc2IbIuoFVxuvSzZj2GJjmtCcW1poDMQLTGq+EuO4Mk1WyoUSJC9L8CFonKH7++EPHopvIbPMinO4r2zLEot3lL5TH"

Expand Down
4 changes: 2 additions & 2 deletions defaults/install/.circleci/deploy-pantheon.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
deploy:
working_directory: ~/project
docker:
- image: cimg/php:8.1-browsers
- image: cimg/php:8.3-browsers
environment:
- NODE_VERSION: 8
- NODE_VERSION: 18
- GITHUB_PUBKEY: "github.com,192.30.253.113 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="
- PANTHEON_PUBKEY: "[codeserver.dev.56f20816-b4b7-4517-a90f-667b4785708d.drush.in]:2222,[35.193.151.123]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSY3gnr0DrbqJJSnEFy6jazDmAdBm4Zs/EkWIQa7x31qgSYyYJMz5V+pk62lBf2BN42VtubwO83vW9G+yG2K1RGOvZJaK5GBvBb/Ws2ZPcp/4sNHpPzkdd75e5/Pk8AWA59XUbJcBWmrDrHMbWV1j2zqPPikxbqGeTTjSx4QR18LIRei5OwT6VQnaVnJqPAqFZ+oCbpr0DL96foL3UEY8EWT/6GH2cANEGZO4ppbhdDw4uG6TaI7S0lxWMQEVy+iwjCNH/nanjd73cwoYd90E0OVdgNDr3hVbIuE6sUW6UwlaAwuyOM/xJYPg1y0rF66958pyVJlZ9KD5A0kY3bHg7"

Expand Down
2 changes: 1 addition & 1 deletion defaults/install/.platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - https://github.com/platformsh/platformsh-example-drupal8/blob/master/.platform.app.yaml

name: 'app'
type: 'php:7.2'
type: 'php:8.3'

relationships:
database: 'mysqldb:mysql'
Expand Down
31 changes: 5 additions & 26 deletions defaults/install/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@
<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}" />
<echo msg="$> ${phpmd.command}" />
<exec command="${phpmd.command}" logoutput="true" checkreturn="true" />
<echo msg="$> vendor/bin/phpmd" />
<exec command="vendor/bin/phpmd ${phpmd.directories} ${phpmd.format} ${phpmd.rulesets} --suffixes ${phpmd.suffixes}" logoutput="true" checkreturn="true" />

<!-- Run Drupal Check. -->
<foreach list="${drupal-check.directories}" param="drupal-check.dir" target="drupal-check" />
Expand All @@ -150,7 +149,7 @@
<target name="eslint" depends="install-node-dependencies">
<!-- Lint custom module and theme (by default) javascript. -->
<echo msg="$> yarn run eslint --ext ${eslint.extensions} ${eslint.directory}" />
<exec command="yarn run eslint --fix-dry-run --ext ${eslint.extensions} --resolve-plugins-relative-to ${drupal.root}/core --no-error-on-unmatched-pattern ${eslint.directory}" logoutput="true" checkreturn="true" />
<exec command="yarn run eslint --fix-dry-run --ext ${eslint.extensions} --no-error-on-unmatched-pattern ${eslint.directory}" logoutput="true" checkreturn="true" />
</target>


Expand All @@ -163,28 +162,8 @@

<!-- Target: install-node-dependencies -->
<target name="install-node-dependencies" depends="" description="Install project, core, and custom module node dependencies">
<echo msg="Seeing if project npm packages are installed and at the expected version." />
<exec command="yarn install --check-files --verbose" returnProperty="project_dependencies" logoutput="true" />
<if>
<not>
<equals arg1="${project_dependencies}" arg2="0" />
</not>
<then>
<echo msg="Install project node dependencies to get eslint libraries." />
<exec dir="${drupal.root}/.." command="yarn install" logoutput="true" />
</then>
</if>
<echo msg="Seeing if Drupal core npm packages are installed and at the expected version." />
<exec dir="${drupal.root}/core" command="yarn install --check-files --verbose" returnProperty="core_dependencies" logoutput="true" />
<if>
<not>
<equals arg1="${core_dependencies}" arg2="0" />
</not>
<then>
<echo msg="Install Core node dependencies to get eslint libraries." />
<exec dir="${drupal.root}/core" command="yarn install" logoutput="true" checkreturn="true" />
</then>
</if>
<echo msg="Install project node dependencies to get eslint libraries." />
<exec dir="${drupal.root}/.." command="yarn install" logoutput="true" />
</target>


Expand Down
78 changes: 78 additions & 0 deletions defaults/install/phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PMD Ruleset for Drupal" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
A PMD Ruleset for Drupal coding standards.
</description>

<!--
Include each rule explicitly so we know what we have.
@see https://github.com/phpmd/phpmd/blob/master/src/main/resources/rulesets/
-->

<!-- Clean Code -->
<!--
These don't align with Drupal standards, so they are excluded.
@todo Static calls are hard to test and extend, is there a way to whitelist the ones that are OK?
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
<rule ref="rulesets/cleancode.xml/ElseExpression"/>
<rule ref="rulesets/cleancode.xml/StaticAccess"/>
-->

<!-- Code Size -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>
<rule ref="rulesets/codesize.xml/NPathComplexity"/>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
<rule ref="rulesets/codesize.xml/TooManyFields"/>

<!-- Controversial -->
<rule ref="rulesets/controversial.xml/Superglobals"/>
<!--
These checks do not need to be included since PHPCS will check for style.
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
<rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
<rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>
-->

<!-- Design -->
<rule ref="rulesets/design.xml/ExitExpression"/>
<rule ref="rulesets/design.xml/EvalExpression"/>
<rule ref="rulesets/design.xml/GotoStatement"/>
<rule ref="rulesets/design.xml/NumberOfChildren"/>
<rule ref="rulesets/design.xml/DepthOfInheritance"/>
<rule ref="rulesets/design.xml/CouplingBetweenObjects"/>
<rule ref="rulesets/design.xml/DevelopmentCodeFragment"/>

<!-- Naming -->
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<!-- Allow $id as a variable name. -->
<property name="exceptions" description="Comma-separated list of exceptions" value="id"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<!-- Bump variable length to a more reasonable number. -->
<property name="maximum" description="The variable length reporting threshold" value="35"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortMethodName"/>
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass"/>
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>

<!-- Unused Code -->
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
<!--
Hooks often have unused parameters, so ignore this warning.
@todo is there a way to allow unused parameters in hooks but not elsewhere?
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
-->

</ruleset>
48 changes: 1 addition & 47 deletions targets/drupal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,9 @@ Or, you can specify the export file directly:
<param>the_build_utility</param>
</drush>

<phingcall target="drupal-change-profile">
<property name="new_profile" value="minimal" />
</phingcall>

<drush command="pm-uninstall" assume="yes">
<param>the_build_utility</param>
<param>standard</param>
</drush>

<drush command="config-export" assume="yes" />
Expand All @@ -318,49 +315,6 @@ Or, you can specify the export file directly:
</target>


<target name="drupal-change-profile" description="Change the install profile on an existing Drupal site.">
<fail unless="new_profile" />

<!-- Get the name of the current profile. -->
<drush command="config-get" returnProperty="current_profile">
<param>core.extension</param>
<param>profile</param>
<option name="format">csv</option>
</drush>

<!-- If the current profile is enabled in the core extensions list, disable it. -->
<drush command="config-get" returnProperty="current_profile_weight">
<param>core.extension</param>
<param>module.${current_profile}</param>
<option name="format">csv</option>
</drush>

<if>
<not><equals arg1="${current_profile_weight}" arg2="" /></not>
<then>
<drush command="config-delete" assume="yes">
<param>core.extension</param>
<param>module.${current_profile}</param>
</drush>
</then>
</if>

<!-- Enable the new profile. -->
<drush command="config-set" assume="yes">
<param>core.extension</param>
<param>module.${new_profile}</param>
<param>1000</param>
</drush>

<!-- Update the profile setting itself. -->
<drush command="config-set" assume="yes">
<param>core.extension</param>
<param>profile</param>
<param>${new_profile}</param>
</drush>
</target>


<target name="drupal-add-multisite" description="Set up a new Drupal multisite.">
<if>
<equals arg1="${build.host}" arg2="pantheon" />
Expand Down
21 changes: 21 additions & 0 deletions targets/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@
</filterchain>
</copy>

<!-- Copy the phpmd.xml file template.
-->
<echo>Updating phpmd.xml file for project root.</echo>
<if>
<equals arg1="${build.host}" arg2="acquia"/>
<then>
<property name="phpmd_dir" value="docroot"/>
</then>
<else>
<property name="phpmd_dir" value="web"/>
</else>
</if>
<copy file="${phing.dir.install}/../defaults/install/phpmd.xml" tofile="${application.startdir}/phpmd.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="projectname" value="${projectname}" />
<token key="webroot" value="${phpmd_dir}" />
</replacetokens>
</filterchain>
</copy>

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

0 comments on commit f67a1bb

Please sign in to comment.