-
Notifications
You must be signed in to change notification settings - Fork 72
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
Issue with MoodleInternal Sniff (MoodleInternalGlobalState) #175
Comments
Thanks @keevan ! Yeah, that seems to be a bug in the calculations of global state (side-effects) changes. For sure that BTW, note that multiple In fact, I've verified that converting them to multiple individual statements, then the check works ok. In any case, that's a good case, I'll investigate why the checker it detecting them as side-effects (incorrectly, I'd say). Ciao :-) |
Aha, confirmed, the problem is that, both for NAMESPACE and USE tokens, we use the That makes the next token to be "cache_store" (the second value in the USE statement after the first comma) and obviously that is a side effect (something @ global scope that shouldn't be there). I think it's easy to fix, will try it along the day. |
Thanks Eloy, Yes I know it's a current coding style violation but appears in many places currently :-) I had tested that workaround/fix in a couple of places already, and can confirm it works fine:
Thanks for the fast response. Looking forward to the update 👍 |
Yeah, yeah. To fix it in Moodle is easy, just make individual And, still, we don't have a proper namespaces/uses sniff in codechecker that will reveal more current issues in codebase (I'll be working on it soon, recently did some related work with unit-tests namespaces that will reuse for namespaces in general). What I want to fix here (in the codechecker) is just the exact case that you commented, aka: "At all effects, comma-separated Thanks! |
No matter that comma-separated use statements are a violation of the coding style (see Namespaces section), they, for sure, don't constitute a side-effect at all, so the MOODLE_INTERNAL check should be immune to them. This fix just enables comma-separated to be properly processed, covered with tests. Fixes moodlehq#175
Have created #176 that should fix the problems with comma-separated |
This is easier to demonstrate with an example:
https://github.com/moodle/moodle/blob/master/cache/classes/administration_helper.php
In the current version of this checker, you will get a warning on the line with:
Removing this line will remove this problematic warning, however, it will cause an error to appear near its place, namely on the following line:
.. which I believe is incorrect. The current definitions are as follows (as per MDLSITE-5967)
I do not believe the usage of the
use
statement here should be treated as a side-effect according to the above definition.The text was updated successfully, but these errors were encountered: