Skip to content

Commit

Permalink
Fix path issue in CLI output
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Sep 7, 2024
1 parent 9d72214 commit 647d1e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion includes/Traits/Amend_Check_Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ trait Amend_Check_Result {
* @param int $severity Severity level. Default is 5.
*/
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) {
$filename = explode( $result->plugin()->path(), $file );

$result->add_message(
(bool) $error,
$message,
array(
'code' => $code,
'file' => str_replace( $result->plugin()->path(), '', $file ),
'file' => ( 1 === count( $filename ) ) ? reset( $filename ) : $filename[1],
'line' => $line,
'column' => $column,
'link' => $this->get_file_editor_url( $result, $file, $line ),
Expand Down
4 changes: 4 additions & 0 deletions tests/behat/features/plugin-check-remote.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Feature: Test that the WP-CLI plugin check command works with remote ZIP url.
Scenario: Test with valid ZIP
When I run the WP-CLI command `plugin check https://github.com/WordPress/plugin-check/raw/trunk/tests/behat/testdata/foo-bar-wp.zip --fields=code,type --format=csv`
Then STDOUT should contain:
"""
FILE: foo-bar-wp.php
"""
And STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/behat/features/plugin-check-severity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Feature: Test that the severity level in plugin check works.

When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity`
Then STDOUT should contain:
"""
FILE: foo-bar-wp.php
"""
And STDOUT should contain:
"""
allow_unfiltered_uploads_detected,ERROR,7
"""
Expand Down

0 comments on commit 647d1e3

Please sign in to comment.