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

Apply WP CS and variable types to final files #272

Merged
merged 39 commits into from
Jun 22, 2022
Merged

Conversation

gudmdharalds
Copy link
Contributor

@gudmdharalds gudmdharalds commented May 17, 2022

This pull request will resolve #157 by applying WordPress Coding Standards and specifying variable types to files in the main code that was missing this. Also included is updates to a number of automated tests and small formatting changes.

TODO:

  • Define variable types, declare strict types and WordPress coding standard to final files of main code:
    • ap-svg-files.php
    • file-validation.php
    • git-repo.php
    • github-api.php
    • misc.php
    • options.php
    • other-web-services.php
  • Add function vipgoci_gitrepo_commit_id_validate_format() to validate commit-ID strings.
  • Added & updated tests:
    • Apply WP CS and strict variable types:
      • tests/integration/OptionsReadRepoFileTest.php
      • tests/unit/VipgociOptionsBoolHandleTest.php. Renamed to tests/unit/OptionsBoolHandleTest.php as well.
      • tests/integration/GitRepoSubmoduleFilePathGetTest.php
      • tests/integration/GitRepoRepoOkTest.php. Extended test to failure condition as well.
      • tests/integration/ApSvgFilesTest.php
      • tests/integration/A01StatsStatsPerFileTest.php
    • Update tests to ensure GitHub token strings are internally treated as empty strings when none are available:
      • tests/integration/SvgScanScanSingleFileTest.php
      • tests/integration/PhpcsScanSingleFileTest.php
      • tests/integration/OptionsReadRepoSkipFilesTest.php
      • tests/integration/MainRunInitOptionsRepoOptionsTest.php
      • tests/integration/GitRepoRepoFetchCommittedFileTest.php
    • Add test tests/unit/GitRepoCommitIdVerifyTest.php for function vipgoci_gitrepo_commit_id_validate_format()
    • Added testing for cached condition in tests/integration/GitRepoGitVersionTest.php
  • Check status of automated tests
  • Add or update PHPDoc comments for new or updated functions (main code only; for VIP)
  • Temporarily disable auto-approval of SVG files removed, to be fixed in a different pull request (Re-enable auto-approval of removed SVG files #280).
  • Changelog entry (for VIP) [ Changelog for version 1.2.4 #275 ]

This resolves #157.

@gudmdharalds gudmdharalds added this to the 1.2.4 milestone May 17, 2022
@gudmdharalds gudmdharalds self-assigned this May 17, 2022
Copy link
Collaborator

@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot left a comment

Choose a reason for hiding this comment

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

phpcs scanning turned up:

🚫 5 errors


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.


Scan run detail

Software versions

  • vip-go-ci version: 1.2.3
  • PHP runtime version for vip-go-ci: 8.1.6
  • PHP runtime for linting:
    • PHP 8.1: 8.1.6
  • PHP runtime version for PHPCS: 7.4.29
  • PHPCS version: 3.6.2
  • PHP runtime version for SVG scanner: 7.4.29

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes
  • hashes-api

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approval DB enabled: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • tests/unit

tests/integration/GitRepoRepoOkTest.php Outdated Show resolved Hide resolved
tests/integration/GitRepoRepoOkTest.php Outdated Show resolved Hide resolved
tests/integration/GitRepoRepoOkTest.php Outdated Show resolved Hide resolved
tests/integration/GitRepoRepoOkTest.php Outdated Show resolved Hide resolved
tests/integration/GitRepoRepoOkTest.php Outdated Show resolved Hide resolved
@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot dismissed their stale review May 17, 2022 20:03

Dismissing review as all inline comments are obsolete by now

@gudmdharalds gudmdharalds changed the title Apply WP CS and varible types to final files Apply WP CS and variable types to final files May 17, 2022
@wpcomvip-vipgoci-bot
Copy link
Collaborator

No issues were found to report when scanning latest commit (commit-ID: dd24d9e)


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.



Scan run detail

Software versions

  • vip-go-ci version: 1.2.3
  • PHP runtime version for vip-go-ci: 8.1.7
  • PHP runtime for linting:
    • PHP 8.1: 8.1.7
  • PHP runtime version for PHPCS: 7.4.30
  • PHPCS version: 3.6.2
  • PHP runtime version for SVG scanner: 7.4.30

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes
  • hashes-api

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approval DB enabled: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • tests/unit

@gudmdharalds gudmdharalds merged commit a2bc924 into trunk Jun 22, 2022
@gudmdharalds gudmdharalds deleted the fix-issue-157 branch June 22, 2022 16:46
@gudmdharalds gudmdharalds mentioned this pull request Feb 9, 2023
54 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define variable types, declare strict types, WordPress coding standard
2 participants