Php_codesniffer: Is there an option to specify the root of shown paths in CS's output?

Created on 6 Jan 2020  路  3Comments  路  Source: squizlabs/PHP_CodeSniffer

@gsherwood

Hi

Before I deal with RegEx, I first wanted to find out if there might be an easier way.

Example:

FILE: ...tcheck\temp\5e139b3f2c8175.24077215\ext\mike\ftcheck\ext.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------

CS shows always the complete path of files and that's what I not want in my automated test system. It would be nice if CS shows only the relative paths in output. Example:

If I call CS with the path [...]\temp\5e139b3f2c8175.24077215\ext\ then CS should only show the paths in this manner:

FILE: mike\ftcheck\ext.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------

mike is a folder in ext.

Is this possible?

Most helpful comment

@gsherwood
@jrfnl

Darn! I simply overlooked the option. Just called the help again when I saw your answer:

<basepath> A path to strip from the front of file paths inside reports

That is exactly what I am looking for. Works perfect. :) Thank you both!

Note to myself: finally buy yourself new glasses.

All 3 comments

@LukeWCS You mean the --basepath setting ? Sounds like that would do exactly what you're looking for.

Try using the --basepath CLI option. This will strip a path from the front of all displayed file paths.

In your case, you'll probably want to set the basepath to the same value as the directory you are checking: phpcs [...]\temp\5e139b3f2c8175.24077215\ext\ --basepath=[...]\temp\5e139b3f2c8175.24077215\ext\

Edit: What @jrfnl said :)

@gsherwood
@jrfnl

Darn! I simply overlooked the option. Just called the help again when I saw your answer:

<basepath> A path to strip from the front of file paths inside reports

That is exactly what I am looking for. Works perfect. :) Thank you both!

Note to myself: finally buy yourself new glasses.

Was this page helpful?
0 / 5 - 0 ratings