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

Create a way to remove certain readme warnings, contributors_ignored. #276

Merged
merged 4 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions checks/readme.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace WordPressdotorg\Plugin_Check\Checks;
use WordPressdotorg\Plugin_Check\{Error, Guideline_Violation, Message, Notice, Warning};
use WordPressdotorg\Plugin_Directory\Readme\Parser;

class Readme extends Check_Base {
/**
Expand Down Expand Up @@ -76,13 +77,31 @@ function check_for_default_text() {
}

function check_for_warnings() {
if ( ! empty( $this->readme->warnings ) ) {
$warnings = $this->readme->warnings ?? [];
$warning_keys = array_keys( $warnings );
$ignored_warnings = [
'contributor_ignored'
];

/**
* Filter the list of ignored readme parser warnings.
*
* @since 0.2.2
*
* @param array $ignored_warnings Array of ignored warning keys.
* @param Parser $readme The readme object.
*/
$ignored_warnings = (array) apply_filters( 'plugin_check_readme_warnings_ignored', $ignored_warnings, $this->readme );

$warning_keys = array_diff( $warning_keys, $ignored_warnings );

if ( ! empty( $warning_keys ) ) {
return new Warning(
'readme_parser_warnings',
sprintf(
/* translators: %1$s: list of warnings */
__( 'The following readme parser warnings were detected: %1$s', 'plugin-check' ),
esc_html( implode( ', ', array_keys( $this->readme->warnings ) ) )
esc_html( implode( ', ', $warning_keys ) )
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ This plugin checker is not perfect, and never will be. It is only a tool to help

= [0.2.2] 2023-11-XX =

* Fix - Remove extra period on the end of the sentence for Phar warning. Props @bordoni, @pixolin. [#275](https://github.com/10up/plugin-check/pull/265)
* Fix - Prevent problems with Readme parser warning related to `contributor_ignored` for when running the check outside of WP.org. Props @bordoni, @dev4press. [#276](https://github.com/10up/plugin-check/pull/276)
* Fix - Remove extra period on the end of the sentence for Phar warning. Props @bordoni, @pixolin. [#275](https://github.com/10up/plugin-check/pull/275)

= [0.2.1] 2023-09-22 =

Expand Down