Skip to content

Commit 16a5f6c

Browse files
committed
Update i18n erro codes severity
1 parent 1b32e0f commit 16a5f6c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

includes/Checker/Checks/General/I18n_Usage_Check.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function get_documentation_url(): string {
9797
* @param string $docs URL for further information about the message.
9898
* @param int $severity Severity level. Default is 5.
9999
*
100+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
100101
* @SuppressWarnings(PHPMD.NPathComplexity)
101102
*/
102103
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) {
@@ -132,11 +133,8 @@ protected function add_result_message_for_file( Check_Result $result, $error, $m
132133

133134
// Update severity.
134135
switch ( $code ) {
135-
case 'WordPress.WP.I18n.InterpolatedVariableDomain':
136136
case 'WordPress.WP.I18n.MissingArgText':
137137
case 'WordPress.WP.I18n.NoEmptyStrings':
138-
case 'WordPress.WP.I18n.NonSingularStringLiteralContext':
139-
case 'WordPress.WP.I18n.NonSingularStringLiteralDomain':
140138
case 'WordPress.WP.I18n.TooManyFunctionArgs':
141139
$severity = 7;
142140
break;
@@ -145,6 +143,11 @@ protected function add_result_message_for_file( Check_Result $result, $error, $m
145143
break;
146144
}
147145

146+
// Update severity for error code variations. Eg: WordPress.WP.I18n.NonSingularStringLiteralXXX.
147+
if ( str_starts_with( $code, 'WordPress.WP.I18n.InterpolatedVariable' ) || str_starts_with( $code, 'WordPress.WP.I18n.NonSingularStringLiteral' ) ) {
148+
$severity = 7;
149+
}
150+
148151
if ( 'WordPress.WP.I18n.TextDomainMismatch' === $code ) {
149152
$restricted_textdomains = $this->get_restricted_textdomains();
150153

0 commit comments

Comments
 (0)