Skip to content

Commit

Permalink
Check upgrade notice length for all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Jan 17, 2024
1 parent 1dd4f21 commit 9a9871a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions includes/Checker/Checks/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,27 @@ private function check_stable_tag( Check_Result $result, string $readme_file, Pa
* @param Parser $parser The Parser object.
*/
private function check_upgrade_notice( Check_Result $result, string $readme_file, Parser $parser ) {
if ( 0 === count( $parser->upgrade_notice ) ) {
$notices = $parser->upgrade_notice;

$maximum_characters = 300;

// Bail if no upgrade notices.
if ( 0 === count( $notices ) ) {
return;
}

$notice = reset( $parser->upgrade_notice );

if ( strlen( $notice ) > 300 ) {
$this->add_result_warning_for_file(
$result,
__( 'The upgrade notice exceeds the limit of 300 characters.', 'plugin-check' ),
'upgrade_notice_limit',
$readme_file
);
foreach ( $notices as $version => $notice ) {
if ( strlen( $notice ) > $maximum_characters ) {
if ( empty( $version ) ) {
/* translators: Maximum characters. */
$message = sprintf( __( 'The upgrade notice exceeds the limit of %d characters.', 'plugin-check' ), $maximum_characters );
} else {
/* translators: 1: Version, 2: Maximum characters. */
$message = sprintf( __( 'The upgrade notice for \'%1$s\' exceeds the limit of %2$d characters.', 'plugin-check' ), $version, $maximum_characters );

Check warning on line 218 in includes/Checker/Checks/Plugin_Readme_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Readme_Check.php#L218

Added line #L218 was not covered by tests
}

$this->add_result_warning_for_file( $result, $message, 'upgrade_notice_limit', $readme_file );
}
}
}

Expand Down

0 comments on commit 9a9871a

Please sign in to comment.