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

Fix/phpcs #286

Merged
merged 53 commits into from
Oct 4, 2022
Merged

Fix/phpcs #286

merged 53 commits into from
Oct 4, 2022

Conversation

oscarssanchez
Copy link
Contributor

@oscarssanchez oscarssanchez commented Aug 4, 2022

Description of the Change

This PR fixes PHPCS issues detected as well as adding a new PHPCS check

How to test the Change

Changelog Entry

Added - New feature
Changed - Existing functionality
Deprecated - Soon-to-be removed feature
Removed - Feature
Fixed - Bug fix
Security - Vulnerability

Credits

Props @username, @username2, ...

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

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

@oscarssanchez left some comments throughout the PR, let me know if you have any questions. Congrats on the huge effort here!

uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
Copy link
Member

Choose a reason for hiding this comment

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

@oscarssanchez I imagine you are not using the default PHP 8.1 because it is still incompatible with the codebase. Can we bump this to PHP 7.4 at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped here: db2d1d9

Comment on lines 228 to 259
if ( isset( $_POST['folderId'] ) && isset( $_POST['oldFolderId'] ) ) {
$folderId = sanitize_text_field( $_POST['folderId'] );
$oldFolderId = sanitize_text_field( $_POST['oldFolderId'] );
if ( isset( $_POST['folder_id'] ) && isset( $_POST['oldfolder_id'] ) ) {
$folder_id = sanitize_text_field( $_POST['folder_id'] );
$old_folder_id = sanitize_text_field( $_POST['oldfolder_id'] );
Copy link
Member

Choose a reason for hiding this comment

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

@oscarssanchez I am probably missing it but did you also change the place where oldFolderId is sent in the POST request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right @felipeelia , I've fixed it here: 552364b

Comment on lines 461 to 492
while ( count( $results ) <= ( $page * $posts_per_page ) ) {
$count_results = count( $results );

while ( $count_results <= ( $page * $posts_per_page ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

As $results is changed inside the while, are you sure this will keep the same behavior it had before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is actually not used anymore, so I just removed the whole method db94cfc

Comment on lines -551 to +582
$folder_id = ( isset( $_POST['folderId'] ) && '' !== $_POST['folderId'] ) ? sanitize_text_field( $_POST['folderId'] ) : false;
$folder_id = ( isset( $_POST['folder_id'] ) && '' !== $_POST['folder_id'] ) ? sanitize_text_field( $_POST['folder_id'] ) : false;
Copy link
Member

Choose a reason for hiding this comment

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

Same as before: did we also change the place where that POST field is sent?

Comment on lines 880 to 884
* @param string $account_hash The account hash for the account.
* @param int $video_id The ID of the video to associate the image with.
* @param string $url The URL of the image to upload.
* @param int $width The width of the image.
* @param int $height The height of the image.
Copy link
Member

Choose a reason for hiding this comment

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

Can we align these descriptions? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here 1069e77

Comment on lines 69 to 72
*
* This hook doesn't follow standard naming convention but needs to stay as it is for retro compatibility.
*/
do_action( 'brightcove/admin/settings_page' );
do_action( 'brightcove/admin/settings_page' ); // phpcs:ignore
Copy link
Member

Choose a reason for hiding this comment

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

Can't we mark this as deprecated with do_action_deprecated and add a properly named action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here ff0df76

Comment on lines 80 to 96
echo $this->render_source_rows();
echo $this->render_source_rows() // phpcs:ignore
Copy link
Member

Choose a reason for hiding this comment

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

This should keep the ; (this is a good example of why ignoring specific rules can help :P )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here af798f7

Comment on lines 406 to 416
* name strings or quoted strings
* text strings or quoted strings (name, description, long_description)
* tags strings or quoted strings
* reference_id string or quoted string
* state ACTIVE, INACTIVE, DELETED, PENDING
* updated_at date range
* created_at date range
* schedule.starts_at date range
* schedule.ends_at date range
* published_at date range
* complete true or false
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we could align these descriptions here too. I think that would increase readability by a ton. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here ab24ae0

Comment on lines -64 to +94
public function _request_access_token( $force_new_token = false, $retry = true ) {
public function request_access_token( $force_new_token = false, $retry = true ) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know how many people would use or extend this code but we should mark this as a breaking change OR keep the old version of the method marking it with _doing_it_wrong or similar.

Copy link
Contributor Author

@oscarssanchez oscarssanchez Oct 3, 2022

Choose a reason for hiding this comment

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

Fixed here 31b09b8

Comment on lines 556 to 564
$message = sprintf(
'<div class="error"><p><strong>%1$s</strong>%2$s<strong>%3$s</strong>%4$s %5$s %6$s<strong>4.2</strong></p></div>',
esc_html__( 'Brightcove Video Cloud Enhanced', 'brightcove' ),
esc_html__( 'has been', 'brightcove' ),
esc_html__( 'deactivated', 'brightcove' ),
esc_html__( 'because it\'s incompatibale with WordPress version', 'brightcove' ),
esc_html( get_bloginfo( 'version' ) ),
esc_html__( 'The minimum compatible WordPress version is ', 'brightcove' )
);
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, breaking up strings to make parts translatable makes translators work much harder. WP core does not care about leaving <strong> in the string to be translated, for example.
A suggestion here would be something like:

$message = sprintf(
	/* translators: 1. WP version; 2. Minimum compatible WP version */
	__( '<strong>Brightcove Video Cloud Enhanced</strong> has been <strong>deactivated</strong> because it is incompatible with WordPress version %1$s. The minimum compatible WordPress version is <strong>%2$s</strong></p>', 'brightcove' ),
	esc_html( get_bloginfo( 'version' ) ),
	'4.2'
);

echo wp_kses_post( '<div class="error"><p>' . $message . '</p></div>' );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also not used anymore so It was removed here 8b6cce4

Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

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

lgtm, just remember to state in the changelog that some methods had their names changed @oscarssanchez

@oscarssanchez oscarssanchez merged commit 8af718a into develop Oct 4, 2022
@oscarssanchez oscarssanchez deleted the fix/phpcs branch October 4, 2022 16:21
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.

2 participants