PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

`GitModified` and `GitStaged` filters blindly expect that the `git` command is available

Open fredden opened this issue 7 months ago • 2 comments

Is your feature request related to a problem?

When the GitModified or GitStaged filters are used, the code blindly expects that the git command-line tool is available. This results in unexpected behaviour if this assumption is not true.

Describe the solution you'd like

It would be better for end users if a suitable error message (and exit code) is presented describing the problem.

Additional context (optional)

This suggestion was initially raised in https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/1105#pullrequestreview-2868073742

fredden avatar May 26 '25 12:05 fredden

I wonder whether it would even make sense to do this validation as early as in the Config class ?

jrfnl avatar May 26 '25 12:05 jrfnl

Oh and another one for which the same applies: the GitBlame report class ;-)

jrfnl avatar Jul 13 '25 22:07 jrfnl