Skip to content
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

3.x: <autoload> file not loaded when custom ruleset includes only category or sniff #1582

Closed
jrfnl opened this issue Jul 29, 2017 · 3 comments

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Jul 29, 2017

While debugging issue #1581, I also came across another bug in the autoloader.

When a custom ruleset does not include a complete external standard, but includes a category or an individual sniff from a standard, and the external standard has defined the <autoload> directive in the ruleset, the autoload file is not included.

This can be tested using the WordPress Coding Standards develop branch in combination with this custom ruleset:

<?xml version="1.0"?>
<ruleset name="Test">
	<rule ref="WordPress.Arrays"/>
</ruleset>

The autoload file in that case provides class aliases to sort out PHPCS cross-version compatibility and as that file is not loaded, the aliases are not in place.

@ht-bs
Copy link
Contributor

ht-bs commented Aug 7, 2017

I ran into this problem too. Adding the entry into my own ruleset would be a really ugly path-specific dependency. Another solution would be great.

@gsherwood
Copy link
Member

gsherwood commented Aug 27, 2017

I'm not sure if this is an easy change.

When you're including a specific sniff or category of sniffs, you aren't asking for anything in the ruleset.xml to be processed, so I'm not sure if I can just load up the ruleset and look for autoloaders.

Having said that, it makes sense in this case because the sniffs only work with the autoloader. I'm just not sure if the custom standard that includes the specific sniff should be defining the autoloader or if PHPCS should be going into a ruleset.xml it finds to try and find it.

This gets a lot more complicated if the standard you are pulling a sniff from includes other whole standards and their autoloaders, and so doesn't define one itself. I'm not really sure if PHPCS should keep looking through rulesets to find all autoloaders.

@gsherwood
Copy link
Member

Closing as there hasn't been any movement on this and I still think this far more complicated than the specific use case here. Needs a lot more thought and a probable rethink of rulesets, which isn't on the todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants