PHPCSStandards / PHP_CodeSniffer

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

allow remote ruleset (i.e https://some-domain.com/path/to/ruleset.xml) #515

Closed Asenar closed 4 months ago

Asenar commented 4 months ago

This feature will allow to include in our phpcs.xml.dist file remote ruleset, for example by adding the following in configuration:

<rule ref="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xml.dist" />

This feature will allow serveral company project to use a common base, either from their private repository, or from a public project

jrfnl commented 4 months ago

@Asenar Thank you for your interest in contributing to PHP_CodeSniffer.

This feature will allow several company project to use a common base, either from their private repository, or from a public project

I'm not sure I understand the need for this feature. After all, projects can already use a common base.

Typically, this is done by having a separate repo which is set up as an external coding standard for PHP CodeSniffer, which handles the dependencies and the ruleset.

The projects then add this external coding standard as a dependency and references the standard by name in their own ruleset.

A setup like that, also allows for versioning the ruleset instead of it being a moving target (like it would be with a URL).

An example of such a setup can be seen in this organisation.

There are plenty of other examples of such a setup around too.

Allowing for a URL also feels like it could open projects up to security risks if they would point to a URL for a standard which is not under their control.

Asenar commented 4 months ago

You right, this can be achieved by different ways too.

I was thinking to a particular case where I didn't wanted to add a new dependency via composer (it's a documentation repository that hadn't any other purpose than to be read, but we can do differently).

jrfnl commented 4 months ago

@Asenar Glad to hear you've found another working solution. In that case, can we close this ticket ?

Asenar commented 4 months ago

It's not ideal for me but yes I will find other way, we can close it :).

Thanks for that so quick answer !