moodlehq / moodle-local_codechecker

A Moodle local plugin providing a simple web UI to run the MoodleCS coding style checks with PHP_CodeSniffer.
63 stars 72 forks source link

Not possible to disable this rule moodle.PHPUnit.TestCaseNames.Missing #171

Closed gthomas2 closed 2 years ago

gthomas2 commented 2 years ago

If I add the following:

phpcs:disable moodle.PHPUnit.TestCaseNames.Missing

I still get the error showing up:

moodle.PHPUnit.TestCaseNames.Missing

Use case for not wanting this sniff:

I have an abstract class with all my tests in it. The abstract class will test according to the value of a constant set on the class. I have two sub classes of the abstract class which have different constants to make the tests behave differently. There is no need for me to have test methods in the sub classes.

stronk7 commented 2 years ago

Aha,

surely the problem is that the moodle.PHPUnit.TestCaseNames.Missing is assigned to line 0 ... and that's before the // phpcs:disable moodle.PHPUnit.TestCaseNames.Missing can do its magic.

Will try to imagine if there is a better way to assign to it another line, although it's not guaranteed that such a line will exist always...

stronk7 commented 2 years ago

Does it work for you if you addd it to the very first line, aka:

<?php // phpcs:disable moodle.PHPUnit.TestCaseNames.Missing

It seems to be doing the trick here and I'm not sure that finding alternative lines to report it is going to work always.

gthomas2 commented 2 years ago

Thanks for the fast response and suggestion. If I add it to line 0 I'll get this instead though : Line 3 of the opening comment must start "// Moodle is free software: you can redistribute it and/or modify

stronk7 commented 2 years ago

Aha,

I did not have the BoilerplateComment sniff in the file I tested the phphcs:disable above, well spotted!

Ok, I'm going to try if this can be solved by any of:

Will comment here once I get any of them working... ciao :-)

stronk7 commented 2 years ago

172 has been created and it addresses the 2 points above:

Unless I'm wrong, that should fix this problem completely (and the phpcs comment can be put in any line).

Ciao :-)

gthomas2 commented 2 years ago

Thanks so much for the super fast fix of this issue. Impressive!