Skip to content

Change ruleset processing to be top-to-bottom instead of processing tags in groups #2197

Closed
@grappler

Description

@grappler

@jrfnl second point (Custom ruleset cannot overrule value in included ruleset) was not fixed when the issue #1821 was closed.

I have done a bit of more debugging. We have the following two rulesets.

<?xml version="1.0"?>
<ruleset name="Company-Ruleset">
	<rule ref="PHPCompatibility"/>
	<config name="testVersion" value="5.6-"/>
</ruleset>

The problem is that the config here does not override the testVersion defined in Company-Ruleset

<?xml version="1.0"?>
<ruleset name="Project-Ruleset">
	<rule ref="Company-Ruleset" />
	<config name="testVersion" value="7.1-"/>
</ruleset>

When running phpcs . -vvv you can see why the config is not being overwritten.

Processing ruleset project/phpcs.xml.dist
	=> set config value testVersion: 7.1-
	Processing rule "Company-Ruleset"
		=> Company-Ruleset/ruleset.xml
		* rule is referencing a standard using ruleset path; processing *
		Processing ruleseCompany-Ruleset/ruleset.xml
			=> set config value testVersion: 5.6-

What I realized I could override the config with another ruleset.

<?xml version="1.0"?>
<ruleset name="Project-Ruleset">
	<rule ref="Company-Ruleset" />
	<config name="testVersion" value="7.1-"/>
	<rule ref="config-override.xml"/>
</ruleset>

The config-override.xml looks like the following

<?xml version="1.0"?>
<ruleset>
	<config name="testVersion" value="7.1-"/>
</ruleset>

When running phpcs . -vvv now the output looks like the following.

Processing ruleset project/phpcs.xml.dist
	=> set config value testVersion: 7.1-
	Processing rule "Company-Ruleset"
		=> Company-Ruleset/ruleset.xml
		* rule is referencing a standard using ruleset path; processing *
		Processing ruleseCompany-Ruleset/ruleset.xml
			=> set config value testVersion: 5.6-
[...]
	Processing rule "config-override.xml"
		* rule is referencing a standard using ruleset path; processing *
		Processing ruleset config-override.xml
			=> set config value testVersion: 7.1-

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions