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

Add check name in results #376

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions includes/Checker/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public function get_stability();
*/
public function run( Check_Result $result );

/**
* Gets the check name.
*
* @since n.e.x.t
*
* @return array The name of the check.
*/
public function get_name();

/**
* Gets the categories for the check.
*
Expand Down
1 change: 1 addition & 0 deletions includes/Checker/Check_Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function add_message( $error, $message, $args = array() ) {
'line' => 0,
'column' => 0,
'link' => '',
'check' => '',
);

$data = array_merge(
Expand Down
3 changes: 2 additions & 1 deletion includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ final public function run( Check_Result $result ) {
$file_message['source'],
$file_name,
$file_message['line'],
$file_message['column']
$file_message['column'],
$this->get_name()
);
}
}
Expand Down
11 changes: 11 additions & 0 deletions includes/Checker/Checks/Late_Escaping_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class Late_Escaping_Check extends Abstract_PHP_CodeSniffer_Check {

use Stable_Check;

/**
* Gets the check name.
*
* @since n.e.x.t
*
* @return array The name of the check.
*/
public function get_name() {
return 'late_escaping';
}

/**
* Gets the categories for the check.
*
Expand Down
30 changes: 15 additions & 15 deletions includes/Checker/Default_Check_Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ private function register_default_checks() {
$checks = apply_filters(
'wp_plugin_check_checks',
array(
'i18n_usage' => new Checks\I18n_Usage_Check(),
'enqueued_scripts_size' => new Checks\Enqueued_Scripts_Size_Check(),
'code_obfuscation' => new Checks\Code_Obfuscation_Check(),
'file_type' => new Checks\File_Type_Check(),
'plugin_header_text_domain' => new Checks\Plugin_Header_Text_Domain_Check(),
// 'i18n_usage' => new Checks\I18n_Usage_Check(),
// 'enqueued_scripts_size' => new Checks\Enqueued_Scripts_Size_Check(),
// 'code_obfuscation' => new Checks\Code_Obfuscation_Check(),
// 'file_type' => new Checks\File_Type_Check(),
// 'plugin_header_text_domain' => new Checks\Plugin_Header_Text_Domain_Check(),
'late_escaping' => new Checks\Late_Escaping_Check(),
'plugin_updater' => new Checks\Plugin_Updater_Check(),
'plugin_review_phpcs' => new Checks\Plugin_Review_PHPCS_Check(),
'direct_db_queries' => new Checks\Direct_DB_Queries_Check(),
'performant_wp_query_params' => new Checks\Performant_WP_Query_Params_Check(),
'enqueued_scripts_in_footer' => new Checks\Enqueued_Scripts_In_Footer_Check(),
'plugin_readme' => new Checks\Plugin_Readme_Check(),
'enqueued_styles_scope' => new Checks\Enqueued_Styles_Scope_Check(),
'localhost' => new Checks\Localhost_Check(),
'no_unfiltered_uploads' => new Checks\No_Unfiltered_Uploads_Check(),
'trademarks' => new Checks\Trademarks_Check(),
// 'plugin_updater' => new Checks\Plugin_Updater_Check(),
// 'plugin_review_phpcs' => new Checks\Plugin_Review_PHPCS_Check(),
// 'direct_db_queries' => new Checks\Direct_DB_Queries_Check(),
// 'performant_wp_query_params' => new Checks\Performant_WP_Query_Params_Check(),
// 'enqueued_scripts_in_footer' => new Checks\Enqueued_Scripts_In_Footer_Check(),
// 'plugin_readme' => new Checks\Plugin_Readme_Check(),
// 'enqueued_styles_scope' => new Checks\Enqueued_Styles_Scope_Check(),
// 'localhost' => new Checks\Localhost_Check(),
// 'no_unfiltered_uploads' => new Checks\No_Unfiltered_Uploads_Check(),
// 'trademarks' => new Checks\Trademarks_Check(),
)
);

Expand Down
11 changes: 6 additions & 5 deletions includes/Traits/Amend_Check_Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait Amend_Check_Result {
* @param int $line The line on which the message occurred. Default is 0 (unknown line).
* @param int $column The column on which the message occurred. Default is 0 (unknown column).
*/
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0 ) {
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, $check = '' ) {
$result->add_message(
(bool) $error,
$message,
Expand All @@ -41,6 +41,7 @@ protected function add_result_message_for_file( Check_Result $result, $error, $m
'line' => $line,
'column' => $column,
'link' => $this->get_file_editor_url( $result, $file, $line ),
'check' => $check,
)
);
}
Expand All @@ -57,8 +58,8 @@ protected function add_result_message_for_file( Check_Result $result, $error, $m
* @param int $line The line on which the error occurred. Default is 0 (unknown line).
* @param int $column The column on which the error occurred. Default is 0 (unknown column).
*/
protected function add_result_error_for_file( Check_Result $result, $message, $code, $file, $line = 0, $column = 0 ) {
$this->add_result_message_for_file( $result, true, $message, $code, $file, $line, $column );
protected function add_result_error_for_file( Check_Result $result, $message, $code, $file, $line = 0, $column = 0, $check = '') {
$this->add_result_message_for_file( $result, true, $message, $code, $file, $line, $column, $check );
}

/**
Expand All @@ -73,7 +74,7 @@ protected function add_result_error_for_file( Check_Result $result, $message, $c
* @param int $line The line on which the warning occurred. Default is 0 (unknown line).
* @param int $column The column on which the warning occurred. Default is 0 (unknown column).
*/
protected function add_result_warning_for_file( Check_Result $result, $message, $code, $file, $line = 0, $column = 0 ) {
$this->add_result_message_for_file( $result, false, $message, $code, $file, $line, $column );
protected function add_result_warning_for_file( Check_Result $result, $message, $code, $file, $line = 0, $column = 0, $check = '' ) {
$this->add_result_message_for_file( $result, false, $message, $code, $file, $line, $column, $check );
}
}
Loading