Skip to content

Commit 647d1e3

Browse files
committed
Fix path issue in CLI output
1 parent 9d72214 commit 647d1e3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

includes/Traits/Amend_Check_Result.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ trait Amend_Check_Result {
3434
* @param int $severity Severity level. Default is 5.
3535
*/
3636
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) {
37+
$filename = explode( $result->plugin()->path(), $file );
3738

3839
$result->add_message(
3940
(bool) $error,
4041
$message,
4142
array(
4243
'code' => $code,
43-
'file' => str_replace( $result->plugin()->path(), '', $file ),
44+
'file' => ( 1 === count( $filename ) ) ? reset( $filename ) : $filename[1],
4445
'line' => $line,
4546
'column' => $column,
4647
'link' => $this->get_file_editor_url( $result, $file, $line ),

tests/behat/features/plugin-check-remote.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Feature: Test that the WP-CLI plugin check command works with remote ZIP url.
3535
Scenario: Test with valid ZIP
3636
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`
3737
Then STDOUT should contain:
38+
"""
39+
FILE: foo-bar-wp.php
40+
"""
41+
And STDOUT should contain:
3842
"""
3943
WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR
4044
"""

tests/behat/features/plugin-check-severity.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ Feature: Test that the severity level in plugin check works.
6464

6565
When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity`
6666
Then STDOUT should contain:
67+
"""
68+
FILE: foo-bar-wp.php
69+
"""
70+
And STDOUT should contain:
6771
"""
6872
allow_unfiltered_uploads_detected,ERROR,7
6973
"""

0 commit comments

Comments
 (0)