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

VACMS-15954 Add phpcs baselines #16109

Merged
merged 2 commits into from
Nov 14, 2023
Merged

VACMS-15954 Add phpcs baselines #16109

merged 2 commits into from
Nov 14, 2023

Conversation

JunTaoLuo
Copy link
Contributor

@JunTaoLuo JunTaoLuo commented Nov 13, 2023

Description

Closes #15954. To reduce the number of existing violations, phpcbf (PHP Code Beautifier and Fixer) was used to fix the use statement ordering issues.

Testing done

Tested locally using the php_codesniffer composer script, i.e. running composer run-script va:test:php_codesniffer. No more errors are observed.

Screenshots

Before:
Screenshot 2023-11-13 at 2 57 35 PM
After:
image

QA steps

As user with access to this repository

  1. Run the command composer run-script va:test:php_codesniffer locally
    • Validate that PHP Code Sniffer runs successfully without errors.

Definition of Done

  • Documentation has been updated, if applicable.
  • Tests have been added if necessary.
  • Automated tests have passed.
  • Code Quality Tests have passed.
  • Acceptance Criteria in related issue are met.
  • Manual Code Review Approved.
  • If there are field changes, front end output has been thoroughly checked.

Select Team for PR review

  • CMS Team
  • Public websites
  • Facilities
  • User support
  • Accelerated Publishing

@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 13, 2023 22:10 Destroyed
@github-actions github-actions bot added the CMS Team CMS Product team that manages both editor exp and devops label Nov 13, 2023
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE: Do not edit this file manually. If regenerating this file, copy this note manually to the new file. -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note here since the command we need is different from the official guidance at https://github.com/123inkt/php-codesniffer-baseline#create-baseline. Our repo has a custom vendor-dir so we need to ensure the report-file is generated in the right location.

@@ -8,6 +8,7 @@
"require-dev": {
"behat/mink": "^1.10",
"behat/mink-browserkit-driver": "^2.1",
"digitalrevolution/php-codesniffer-baseline": "^1.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any procedure to follow when adding new PHP packages?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JunTaoLuo Not at present and not historically.

Side note: Historically we've been bad about adding to require-dev vs. require. We install dev dependencies on the AMI that gets used for both staging and prod, so it's easy to be sloppy there at present. Something to think about 🙂

- This prevents phpcs from failing due to existing errors
- Bulk fix use ordering with phpcbf
@JunTaoLuo JunTaoLuo force-pushed the VACMS-15954-PHPCS-Baselines branch from 507f098 to 0a3c851 Compare November 14, 2023 15:30
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 14, 2023 15:30 Destroyed
@JunTaoLuo JunTaoLuo marked this pull request as ready for review November 14, 2023 15:31
@JunTaoLuo JunTaoLuo requested review from a team as code owners November 14, 2023 15:31
@JunTaoLuo
Copy link
Contributor Author

FYI reviewers, changes to most files are from sorting of use statements by phpcbf. The functional changes are in composer.json and docroot/phpcs.baseline.xml.

Copy link
Contributor

@tjheffner tjheffner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance LGTM overall. I think AP is a codeowner of va_gov_api, and those changes in particular are a-ok 👍

Copy link
Contributor

@ndouglas ndouglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root@php:/var/lib/tugboat# composer run-script va:test:php_codesniffer
> # Run PHP_CodeSniffer tests.
> ! ./scripts/should-run-directly.sh || phpcs --colors --
> ./scripts/should-run-directly.sh || ddev composer va:test:php_codesniffer --
root@php:/var/lib/tugboat# echo $?
0

Great work! And thank you for clearing up those ordering issues ❤️

@JunTaoLuo JunTaoLuo enabled auto-merge (squash) November 14, 2023 15:44
@JunTaoLuo JunTaoLuo merged commit 531ad7f into main Nov 14, 2023
14 checks passed
@JunTaoLuo JunTaoLuo deleted the VACMS-15954-PHPCS-Baselines branch November 14, 2023 15:59
tjheffner pushed a commit that referenced this pull request Dec 6, 2023
* Add PHP Codesniffer Baselines

- This prevents phpcs from failing due to existing errors
- Bulk fix use ordering with phpcbf
- Add php-codesniffer-baseline as dev requirement and regenerate baseline file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMS Team CMS Product team that manages both editor exp and devops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate/implement PHP_CodeSniffer Baseline
4 participants