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

Collection of hacks for PHP 8 batch compatibility scanning #306

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

rinatkhaziev
Copy link

@rinatkhaziev rinatkhaziev commented Oct 7, 2022

I don't expect this ever to get merged, but maybe some of the things done can be worked in the codebase properly.

When running the scans, we have had to deal with a few issues:

To achieve better concurrency we had to reduce the number of IO operations.

I spotted that vip-go-ci copies over the file to a temporary file and then scans that - I'm not sure of the reason, but I don't think it's relevant when running locally. So I just circumvented the part.

Log verbosity

Had to tweak log levels to reduce the amount of information, so that only the errors are printed.
For example, the entry is not printed when the scan result is empty.

Increase intervals

GH Issues API is throttling aggressively with "secondary rate-limits". To account for that, the VIPGOCI_HTTP_API_WAIT_TIME_SECONDS was bumped to 5.

--error-severity vs --warning-severity

The production version uses --severity=5 which means --error-severity=5 --warning-severity=5. However, I discovered that having --severity=5 trumps both specific arguments.

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.

Code analysis identified issues

VIP Code Analysis Bot has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 10 errors

⚠️ 1 warning


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.3.1
  • PHP runtime version for vip-go-ci: 8.1.11
  • PHP runtime for linting:
    • PHP 8.1: 8.1.11
  • PHP runtime version for PHPCS: 7.4.32
  • PHPCS version: 3.7.1
  • PHP runtime version for SVG scanner: 7.4.32

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

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-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

WPScan API configuration

WPScan API scanning enabled: false

@@ -37,6 +37,9 @@ function vipgoci_log(
* otherwise, do print it,
*/

// HACK
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).

);
// Hack - we don't need to copy over the file, we can just pass the contents
// $temp_file_name = vipgoci_save_temp_file(
// 'vipgoci-phpcs-scan-',
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Expected 1 space before comment text but found 2; use block comment if you need indentation (Squiz.Commenting.InlineComment.SpacingBefore).

// Hack - we don't need to copy over the file, we can just pass the contents
// $temp_file_name = vipgoci_save_temp_file(
// 'vipgoci-phpcs-scan-',
// $file_extension,
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Expected 1 space before comment text but found 2; use block comment if you need indentation (Squiz.Commenting.InlineComment.SpacingBefore).

// $temp_file_name = vipgoci_save_temp_file(
// 'vipgoci-phpcs-scan-',
// $file_extension,
// $file_contents
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Expected 1 space before comment text but found 2; use block comment if you need indentation (Squiz.Commenting.InlineComment.SpacingBefore).

// 'vipgoci-phpcs-scan-',
// $file_extension,
// $file_contents
// );
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).


unlink( $temp_file_name );
// HACK
// unlink( $temp_file_name );
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).

$file_issues_arr_master['totals'] : null,
)
);
// HACK
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).


// HACK
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).

/* Get rid of temporary file */
unlink( $temp_file_name );
// unlink( $temp_file_name );
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚫 Error( severity 5 ): Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).

/* Get rid of temporary file */
unlink( $temp_file_name );
// unlink( $temp_file_name );
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Warning( severity 5 ): This comment is 58% valid code; is this commented out code? (Squiz.PHP.CommentedOutCode.Found).

@gudmdharalds
Copy link
Contributor

Hi,

Thanks for submitting this. I will have look and evaluate each change.

@gudmdharalds
Copy link
Contributor

I will be working through this item by item 🙂

Log verbosity

Had to tweak log levels to reduce the amount of information, so that only the errors are printed. For example, the entry is not printed when the scan result is empty.

How about that each log message has an associated log level? The levels would be: INFO, DEBUG and ERROR. ERROR would always be printed, but whether to log INFO and DEBUG messages would be configurable on the command line. This means that different use cases can make use of different log levels:

  • The scanner can be configured only to print ERROR when fully configured to scan repositories.
    • While being configured, one could use INFO and ERROR.
  • vip-go-ci in production would print INFO and ERROR.
    • While in development, it would print INFO, DEBUG and ERROR.

What do you think?

@rinatkhaziev
Copy link
Author

ERROR would always be printed, but whether to log INFO and DEBUG messages would be configurable on the command line.

I like that, it seems to make the most sense and allows us the necessary flexibility depending on the use case.

@gudmdharalds gudmdharalds self-assigned this Oct 21, 2022
@gudmdharalds
Copy link
Contributor

Increase intervals

GH Issues API is throttling aggressively with "secondary rate-limits". To account for that, the VIPGOCI_HTTP_API_WAIT_TIME_SECONDS was bumped to 5.

This is resolved via #316 and Automattic/vip-go-compatibility-scanner#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants