diff --git a/includes/Checker/Check.php b/includes/Checker/Check.php index 9e74935a0..d6fe6c41d 100644 --- a/includes/Checker/Check.php +++ b/includes/Checker/Check.php @@ -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. * diff --git a/includes/Checker/Check_Result.php b/includes/Checker/Check_Result.php index 4750c09f2..520e6d25f 100644 --- a/includes/Checker/Check_Result.php +++ b/includes/Checker/Check_Result.php @@ -100,6 +100,7 @@ public function add_message( $error, $message, $args = array() ) { 'line' => 0, 'column' => 0, 'link' => '', + 'check' => '', ); $data = array_merge( diff --git a/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php b/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php index a9e827f65..b134c1ec8 100644 --- a/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php +++ b/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php @@ -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() ); } } diff --git a/includes/Checker/Checks/Late_Escaping_Check.php b/includes/Checker/Checks/Late_Escaping_Check.php index 9a020e914..6a3e7fc04 100644 --- a/includes/Checker/Checks/Late_Escaping_Check.php +++ b/includes/Checker/Checks/Late_Escaping_Check.php @@ -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. * diff --git a/includes/Checker/Default_Check_Repository.php b/includes/Checker/Default_Check_Repository.php index 9b91bc83a..ebb642bfb 100644 --- a/includes/Checker/Default_Check_Repository.php +++ b/includes/Checker/Default_Check_Repository.php @@ -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(), ) ); diff --git a/includes/Traits/Amend_Check_Result.php b/includes/Traits/Amend_Check_Result.php index b13bb3c4a..6cf5348e0 100644 --- a/includes/Traits/Amend_Check_Result.php +++ b/includes/Traits/Amend_Check_Result.php @@ -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, @@ -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, ) ); } @@ -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 ); } /** @@ -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 ); } }