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

Feature suggestion: allow for "standards" to be hidden #2760

Closed
jrfnl opened this issue Dec 12, 2019 · 3 comments · May be fixed by #2761
Closed

Feature suggestion: allow for "standards" to be hidden #2760

jrfnl opened this issue Dec 12, 2019 · 3 comments · May be fixed by #2761

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Dec 12, 2019

Use-case: sniffs in generic sniff collections - like the Generic set in PHPCS - can be freely used by other standards, but shouldn't ever be included in a custom ruleset like <rule ref="Generic"/> as they may (and often will, like Generic) contain sniffs which contradict each other.

For the build-in Generic standard, PHPCS makes a hard-coded exception and doesn't list it when someone calls up phpcs -i.

// Ignore the special "Generic" standard.
if ($includeGeneric === false && $filename === 'Generic') {
continue;
}

// Ignore the special "Generic" standard.
if ($includeGeneric === false && $filename === 'Generic') {
continue;
}

I'd like to propose making that a feature available to external standards as well.
For one, I imagine the SlevomatCodingStandard could use it, but I see some more use-cases in the future.

I envision this can most easily be done by adding a new attribute to the ruleset element in the xsd and adjusting the code for the -i option to respect the setting found there.

Something like list with the default being true.

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    name="Generic"
    list="false"
    xsi:noNamespaceSchemaLocation="../../../phpcs.xsd">

Implementation-wise, AFAICS this will be easiest to implement via the Standards::getInstalledStandardDetails() method and the Standards::getInstalledStandards() should then probably defer to that method instead of it being a stand-alone method.

Opinions ?

@gsherwood
Copy link
Member

Sounds like a pretty specialised feature, but not a bad one.

@jrfnl
Copy link
Contributor Author

jrfnl commented Feb 24, 2023

Thinking about this issue now, I have a feeling end-users might get confused if they don't see an expected standard when running phpcs -i, so hiding the standard(s) may not be the right action.

Possibly listing them as a separate category "Additional non-standard rulesets" or something like that ? (including Generic)
Or listing them with an * next to their name or something, might be better.

I'd love to see more input from end-users about what would be most helpful to them.

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#18

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2023
@github-project-automation github-project-automation bot moved this to Ready for Release in PHPCS v3 Development Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Release
Development

Successfully merging a pull request may close this issue.

2 participants