-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Bug: "colors" can not be overruled from within a secondary ruleset #2395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Along the same lines, an |
Loosely related to #2041 |
The config has been specifically designed to not allow this style of overriding, so the primary rulesets have the final say, not the rulesets they are including. This is how I think it should be. If my project has a config that says I want colours, I want colours. If including a 3rd-party ruleset is able to turn off that setting, there is no point in me even having the ability to set it in my project's ruleset. The CLI overrides were added in because they should have the absolute final say as the developer is individually setting those. |
Maybe I used the wrong terminology, but in the example I posted in the original issue report, the However, instead of the setting from the |
Well that's not how it is supposed to work at all. I'll have a look at it when I get a chance. |
Appreciated! Edit: easy way to test/reproduce the issue - just add the above |
I can't replicate this issue. Arg The code is quite simple too: PHP_CodeSniffer/src/Config.php Lines 705 to 720 in 0b44f1c
If colours are turned on first (as they should be in this case) a var is set so that turning off colours is ignored. I added some debug code in to ensure it is working as intended, and it is for me. Are you maybe seeing things process in a different order to me? |
Sounds like you have replicated the issue: no-colors is set second, but is ignored. |
Oh, I get you now. Sorry. Is this the issue: #2197 Edit: What I meant was - is this is the solution? Line by line parsing should fix this, but it's targeting 4.0 |
It's similar and definitely closely related. In my view, it would be most logical for all included standards/rulesets to be processed first in the order in which they are found in a custom ruleset. And then for the top-level configuration to be processed after that, i.e.: <ruleset name="Test">
<arg name="no-colors"/>
<config name="testVersion" value="7.1-"/>
<rule ref="PHPCompatibility"/>
<rule ref="phpcs.xml.dist"/>
</ruleset> So, given the above example, the most logical processing order IMO would be:
Leaving this for As a temporary solution for now, I've just created a Windows |
I'll close this issue in favour of the other one. It's linked now anyway. I prototyped the line-by-line change for the other issue, but didn't commit it due to the potential BC break, so it's an easy win. But if you have another idea or how to fix this processing issue, post over there and we'll figure out a good way. |
FYI: the reason why this is such a pain (aside from the issues with overruling the Being able to just set it in a |
We're currently discussing a completely different solution to this problem in the livestream for PHPCS 4.0 (see PHPCSStandards/PHP_CodeSniffer#924) or join the livestream at: https://whereby.com/phpcs The new solution can be seen here: PHPCSStandards/PHP_CodeSniffer#1005 |
Given the following primary ruleset saved as
phpcs.xml.dist
:... and this secondary ruleset saved as
phpcs.xml
:The
no-colors
setting has no effect.Overruling the setting from the command-line using
phpcs --no-colors
does work.The text was updated successfully, but these errors were encountered: