-
Notifications
You must be signed in to change notification settings - Fork 3
Fix PHP linting #435
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
Fix PHP linting #435
Conversation
This makes it more clear and reads more like an `if else` statement.
Path filtering is already being applied at the workflow level. Checking that relevant file types are modified within a given event is not necessary. This allows the archived third-party action to be removed.
This action handles caching and running `composer validate` under the hood. Those steps can now be removed.
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.
Pull Request Overview
This PR fixes the PHP linting workflow by addressing configuration issues and improving performance. The main changes include updating PHPCS configuration, removing unused function parameters that were causing linting violations, and overhauling the GitHub Actions workflow to use modern caching strategies.
- Updates PHP and WordPress version requirements in PHPCS configuration
- Removes unused parameters from several functions to fix linting violations
- Replaces problematic file-based linting with full project scans and improved caching
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
phpcs.xml | Updates PHP/WP versions, adds caching, expands exclusions and scan scope |
inc/partners.php | Removes unused $network_activation parameter from plugin_activated function |
inc/base.php | Removes unused $install_date parameter from bluehost_install_date_filter function |
inc/GoogleSiteKit.php | Removes unused $expiration and $transient parameters from transient handler |
.github/workflows/lint.yml | Overhauls workflow to use modern caching, removes deprecated actions, adds result annotations |
.distignore | Excludes new .cache directory from distribution |
Proposed changes
This makes some follow up adjustments to the PHP linting workflow after #176.
The linting workflow currently tries to pass the list of edited files to the
phpcs
command. This is causing an issue because the list of files output by the earlier step is a space separated list with each file surrounded in single quotes. Enclosing the list in double quotes to guard against possible security vulnerabilities is makingphpcs
read it as one file name.The step responsible for generating a list of modified files is also configured incorrectly causing all modified files to be passed resulting in the workflow always running. Because path filtering is being used at the workflow level for the
push
events, this third party action is not required (it has actually been archived and abandoned upstream).If a pull request is required to make a change to the code base, It's reasonable to assume that the branch was free of violations prior to creation. Because of this, it's fine to run the scan on the whole project. However, there are a few modifications that can also be made for performance and effectiveness:
phpcs.xml
file has been updated to accurately reflect the PHP and WordPress versions supported through thetestVersion
andminimum_supported_wp_version
configuration settings, respectively.phpcs
will now scan all PHP files in the repository except those explicitly excluded through an<exclude-patter>
in thephpcs.xml
file (which have been expanded to avoid scanning thevendor
andnode_modules
directories).phpcs
runs has been configured locally.actions/cache
. The cache is keyed by the hash of thecomposer.lock
andphpcs.xml
files which control the behavior ofphpcs
, but an additional date value is included to ensure the cache is flushed at least once a week if those files don't change.composer validate
under the hood. Previously, there were unique steps in the linting workflow for this.push
andpull_request
events has been expanded to also include files that may affect the results ofphpcs
.technote-space/get-diff-action
are not required. The former has been archived, so removing this dependency is desired.phpcs
scan are now displayed contextually as annotations within pull requests and commits.Type of Change
Production
Development
Visual
Checklist
Further comments