From 9d709e254fe0f464d536172fac08bda194c49290 Mon Sep 17 00:00:00 2001 From: joegl <20383-joegl@users.noreply.drupalcode.org> Date: Tue, 19 Nov 2024 14:09:13 -0600 Subject: [PATCH] Added phpcs to CI. --- .github/workflows/phpcs.yml | 33 ++++ composer.json | 4 +- composer.lock | 341 +++++++++++++++++++++++++++++++++++- phpcs.dist.xml | 25 +++ 4 files changed, 396 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/phpcs.yml create mode 100644 phpcs.dist.xml diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 000000000..87fe4f64d --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,33 @@ +name: Drupal PHP CodeSniffer +on: push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + run-phpcs: + runs-on: ubuntu-latest + container: + image: pookmish/drupal8ci:php8.3 + steps: + - uses: actions/checkout@v4 + - name: Restore Cache + uses: actions/cache@v4 + with: + path: | + vendor + docroot/core + docroot/libraries + docroot/modules/contrib + key: 1.0-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }} + restore-keys: | + 1.0-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }} + 1.0-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}- + 1.0-${{ hashFiles('blt/blt.yml') }}- + - name: Run PHPCS + run: | + composer install -n && + vendor/bin/phpcs --standard=./phpcs.dist.xml + + + + diff --git a/composer.json b/composer.json index 93ccea05e..6e670843b 100644 --- a/composer.json +++ b/composer.json @@ -194,14 +194,12 @@ "su-sws/stanford_samlauth": "^1.0" }, "require-dev": { + "drupal/core-dev": "~10.3.0", "drupal/upgrade_status": "^4.0", "phpspec/prophecy-phpunit": "^2.0", "su-sws/blt-sws": "dev-main", "su-sws/drupal-dev": "^10" }, - "replace": { - "drupal/coder": "*" - }, "conflict": { "drupal/drupal": "*", "drupal/gin": ">3.0.0-rc13" diff --git a/composer.lock b/composer.lock index b7eeb4301..551a22edc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1e65d1799c121c32646a68f2c2e68967", + "content-hash": "29b5787fc17307b4deb6eca11b2fe334", "packages": [ { "name": "acquia/blt", @@ -20527,6 +20527,84 @@ }, "time": "2022-03-11T17:43:07+00:00" }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "time": "2023-01-05T11:28:13+00:00" + }, { "name": "dekor/php-array-table", "version": "2.0", @@ -20924,6 +21002,57 @@ ], "time": "2024-10-30T19:48:12+00:00" }, + { + "name": "drupal/coder", + "version": "8.3.25", + "source": { + "type": "git", + "url": "https://github.com/pfrenssen/coder.git", + "reference": "c58e5a0c44c0010bbc8a91fc468f4667e177b976" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pfrenssen/coder/zipball/c58e5a0c44c0010bbc8a91fc468f4667e177b976", + "reference": "c58e5a0c44c0010bbc8a91fc468f4667e177b976", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1 || ^1.0.0", + "ext-mbstring": "*", + "php": ">=7.2", + "sirbrillig/phpcs-variable-analysis": "^2.11.7", + "slevomat/coding-standard": "^8.11", + "squizlabs/php_codesniffer": "^3.9.1", + "symfony/yaml": ">=3.4.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.7.12", + "phpunit/phpunit": "^8.0" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "Drupal\\": "coder_sniffer/Drupal/", + "DrupalPractice\\": "coder_sniffer/DrupalPractice/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "description": "Coder is a library to review Drupal code.", + "homepage": "https://www.drupal.org/project/coder", + "keywords": [ + "code review", + "phpcs", + "standards" + ], + "support": { + "issues": "https://www.drupal.org/project/issues/coder", + "source": "https://www.drupal.org/project/coder" + }, + "time": "2024-09-22T19:02:16+00:00" + }, { "name": "drupal/config_inspector", "version": "2.1.9", @@ -25071,6 +25200,210 @@ }, "time": "2023-09-03T09:24:00+00:00" }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.11.19", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1", + "reference": "bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5.6" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", + "phpcsstandards/phpcsdevcs": "^1.1", + "phpstan/phpstan": "^1.7", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", + "sirbrillig/phpcs-import-detection": "^1.1", + "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "keywords": [ + "phpcs", + "static analysis" + ], + "support": { + "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", + "source": "https://github.com/sirbrillig/phpcs-variable-analysis", + "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" + }, + "time": "2024-06-26T20:08:34+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "f2cc4c553eae68772624ffd7dd99022343b69c31" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/f2cc4c553eae68772624ffd7dd99022343b69c31", + "reference": "f2cc4c553eae68772624ffd7dd99022343b69c31", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", + "php": "^7.4 || ^8.0", + "phpstan/phpdoc-parser": "^2.0", + "squizlabs/php_codesniffer": "^3.10.0" + }, + "require-dev": { + "phing/phing": "3.0.0", + "php-parallel-lint/php-parallel-lint": "1.4.0", + "phpstan/phpstan": "1.12.8", + "phpstan/phpstan-deprecation-rules": "1.2.1", + "phpstan/phpstan-phpunit": "1.4.0", + "phpstan/phpstan-strict-rules": "1.6.1", + "phpunit/phpunit": "9.6.8|10.5.38|11.4.3" + }, + "default-branch": true, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "8.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/master" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2024-11-08T15:15:07+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.11.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-11-16T12:02:36+00:00" + }, { "name": "su-sws/blt-sws", "version": "dev-main", @@ -26145,14 +26478,14 @@ "drupal/views_ical": 15, "drupal/webform": 10, "onlyextart/colorbox": 20, - "su-sws/stanford_basic": 20, - "su-sws/blt-sws": 20 + "su-sws/blt-sws": 20, + "su-sws/stanford_basic": 20 }, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": ">=8.3" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/phpcs.dist.xml b/phpcs.dist.xml new file mode 100644 index 000000000..b84701ad9 --- /dev/null +++ b/phpcs.dist.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + docroot/profiles/humsci + docroot/modules/humsci + docroot/themes/humsci + + */tests/* + */node_modules/* + */dist/* +