squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.67k stars 1.48k forks source link

phpcs_input_file ignored for --ignore test #733

Closed Arcanemagus closed 8 years ago

Arcanemagus commented 9 years ago

When feeding a file to PHPCS via stdin the defined method of telling PHPCS what the file name is is to prepend the content with a single line of the format:

phpcs_input_file: filePathGoesHere

Unfortunately it appears that this "self-defined file name" is not respected when running the test for the --ignore option.

Discovered in https://github.com/AtomLinter/linter-phpcs/issues/66, where we may be working around this issue, but I figured it should be filed here to hopefully be fixed in the source :wink:.

gsherwood commented 9 years ago

PHPCS assumes that if you are passing in standard input to it, you want that input checked. None of the ignore rules will be processed as they are only used when traversing the file system looking for files to process.

I'll leave this as a feature request as it may be possible to implement in the 3.0 refactor. Not 100% sure though, and not 100% sure if I should actually make this change.

Arcanemagus commented 9 years ago

It looks like we will just be re-implementing this in linter-phpcs, I'm not actually to sure what I would define as "correct" behavior here as the option only really makes sense when scanning a directory but apparently is in use for single files as well.

gsherwood commented 8 years ago

I figured out a way of doing it in 3.0.

Arcanemagus commented 8 years ago

Awesome, thanks!