Closed OndraM closed 6 years ago
Hey Ondra,
severity can be replaced better way in imports
.
More broad sets are included in more strict ones, see for e.g.:
I may not understand, but how to set severity only for one type of error of one sniff, as in the example above? I didn't find anything similar in the referenced configs :-/
There is no such feature as severity in ECS. Code is either checked or not. Using severity levels and warning made simple thing complicated.
Use classic Symfony approach with yaml imports
instead:
# simple-config.yml
services:
SomeFixer: ~
# strict-config.yml
imports:
{ resource: 'simple-config.yml' }
services:
CommentFixer: ~
Basically:
# instead of vendor/bin/phpcs ... --severity=0
vendor/bin/ecs check /src --config simple-config.yml
# instead of vendor/bin/phpcs ...
vendor/bin/ecs check /src --config strict-config.yml
Some more context...
All PHP_CodeSniffer Errors are reported by default: https://github.com/Symplify/Symplify/blob/771d597fb5f337fc559a97e1704cffedaae75746/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php#L134
Some PHP CS Fixer Warnings are reported: https://github.com/Symplify/Symplify/blob/771d597fb5f337fc559a97e1704cffedaae75746/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php#L148; those are configured here ATM: https://github.com/Symplify/Symplify/blob/771d597fb5f337fc559a97e1704cffedaae75746/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php#L52-L55
I think we still don't understand each other :)). Setting severity to zero is just a way how to skip some codes in PHP_CS config, which is what I want - I don't need actually the severity at all.
So I was actually talking about a way how ti ignore specific error code from the sniff, but keeping rest of the sniff active. I thought you can in ECS skip only whole sniffs or files, but you can ignore also the code from sniffs. So this looks great :tada: . Sorry I overlooked this initially :).
Oh. I README
is recommended to read before use ;)
Good to know. I'll ask for the need next time, rather than code.
Hi Tomas once again 😳, in our ruleset.xml for PHP_CodeSniffer we apply some sniffs (like Generic.Commenting.DocComment), and then explicitly disable some of its rules (eg. Generic.Commenting.DocComment.ContentAfterOpen) by setting their severity to 0, so that we effectively use only part of the parent sniff. Is it possible to achieve something like this via the ECS configuration?