-
Notifications
You must be signed in to change notification settings - Fork 16
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
Consider creating a new "moodle-for-plugins" standard #92
Comments
|
Another option for this is to have an option set in the plugin's own <?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
<config name="moodle-type" value="plugin" />
</ruleset> This can be accessed within the relevant sniffs: public function process(File $file, $pointer) {
if ($file->config->getConfigData('moodle-type') === 'plugin') {
return;
}
// ... This has the benefit that the same standard sniffs can be used without doubling up. |
Yeah, both are valid points,
I think that having a (two) new standards is not much complex as far as they would include their parents and just enable/disable exceptional stuff. In the other side, making it via configuration can be, also, a very good solution and the tools using phpcs (CiBoT, moodle-plugin-ci, codechecker, ... ) just have to apply for it or no. Just to see the problem from another angle, not discarding anything of the above, I've the feeling that we should have a clear policy / process about how to manage the evolution of the moodle standard(s). And then, apply for it always. Instead, right now, we have a bunch of policies that are applied here and there and, although we try to do it "correctly", it's really tricky to decide between them:
So, ideally, we should find which of the above (or new) strategies we agree to apply, for which cases each, make it public and do not look back. I think that, long term, it's impossible to continue work-arrounding / delaying the new Sniffs (if they are objectively / un-opinionated part of the coding style) to apply to plugins. I know that it creates a lot of noise on everybody's plugins, but it's for a good reason. Then, there are the opinionated ones, that, maybe, are the trickier ones (for a current example, see #103). It's a good change, but it's not a must (or part of the coding style, or part of a future requirement of PHPUnit). Those are, surely the ones we should find a path for. Ciao :-) |
jsut to suggest an alternative. Instead of "moodle-for-plugins" we could instead
Basically the same idea, just different split and naming. |
@timhunt , They would all be under the If we were to add additional rulesets then they would be a part of the same package. Whatever we do we would need to create a We have a couple of options:
|
Thanks for continuing to think about this. Here is another thought: phpcs.xml is not the only way to specify the ruleset to use (I think - I could well be wrong). I think you can also specify it on the command line (https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). Could we specify moodle in the main phpcs.xml, but then get CiBoT to specify moodle-extra on the command-line when checking core changes. (You probably already thought of that, and it won't work for some reason. Also, it seem moodle-plugin-ci already just works, so that is fine.) |
You are correct, the options are (in descending order of precedence):
Source: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage Moodle already ships with a We also generate a That leaves An individual plugin can also just create their own version of any of these files however it will only be used if phcps was run from that directory.
I don't think we need to really. We already do specify Additionally our Ultimately I'm not sure what else we can actually do in that regard because of how phpcs picks up config files. |
Commented @ #91 maybe it would be nice to have a new standard, similar to the
moodle-extra
one for easier use by tools that are checking plugins and not core, namely CiBoT and moodle-plugin-ci.That way, each time that we introduce a new Sniff in the "moodle" standard, if it's not suitable for plugins, we just can disable it in the new
moodle-for-plugins
standard and done. Or modify any behaviour (error vs warning), or whatever.Right now, when those exceptions happen, we have to create issues like:
And set a custom configuration there, that is slow and hard.
Instead, if we create the new standard for plugins, everything will work automagically, the tools just will use that standard and done.
Disclaimer: the
moodle-for-plugins
name is not a proposal, just the concept, heh.The text was updated successfully, but these errors were encountered: