Closed (won't fix)
Project:
Coder
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2009 at 20:19 UTC
Updated:
16 Jan 2016 at 18:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
matason commentedI'll look into this and provide a patch, I'll also check for other false positive hook matches for functions that start with "_" which raises the question, I know it's probably highly unlikely but what if someone creates a module called "_my_modulename"?
Comment #2
joachim commentedI've not looked at the code for this module, but the way to ccover for this would be to grab the module's root name from its filename or the system table and search for ROOTNAME_HOOKNAME. Then you're covered for that.
I wrote some hooksniffing regexps for module_builder which you might want to look at :)
Comment #3
joachim commentedSo having had a chat about this on IRC, I see the current code says this:
It seems to me we could abstract some of this.
Otherwise, every single data key in hook_reviews that looks for a hook is reimplementing the same regexp, bar a hook name.
So instead:
Whatever uses hook_review then has to build a regexp like:
Comment #4
matason commentedThis patch makes '#type' => 'hook' available for use in implementations of hook_reviews() enabling simpler and more accurate sniffing for API hooks. This is useful when you need to test for obsolete hooks and can be done like this:
Comment #5
joachim commentedPatch is good.
But was missing any actual implementation to try it.
So I have changed the hook_access check to use this new thingy instead, and run trackerlite through a coder review.
Success:
function _trackerlite_myrecent_access($account) {
not picked up.
Added this to my code
funtion trackerlite_access() {
and this IS picked up.
Here's an updated patch.
I think however this needs some documentation on how to use it in a hook_reviews file.
In particular, it's important to say whether you need to give the #value as 'access' (which is the case) or 'hook_access' (which isn't, but one could suppose it is).
However, the place for this says:
// @TODO : document hook_reviews()
so that's another issue really -- #598600: // @TODO : document hook_reviews() in fact. We can't add to documentation that doesn't exist at all yet.
Comment #6
matason commentedYes, good points, thanks joachim.
We can remove '#function-not' => '^\w+_node_access$', too, this is only used for regex type reviews.
Comment #7
salvisThis patch doesn't apply anymore.
I'm also getting false positives on functions like MODULE_add_user()
Comment #8
joachim commentedHmmm that shouldn't happen, as it's using the module name to build the hook name.
Can you check what it's building in your case with this line:
Comment #9
salvisI can't find this line in the beta2 code.
Comment #10
joachim commentedThat line is in the patch.
Comment #11
salvisAh, I haven't been able to apply the patch to beta2. Are you sure it still applies?
I haven't tried it with HEAD, but the patch is from last October, well before beta2.
Comment #12
joachim commentedSorry; my mistake, I completely misread your earlier comment :/ -- I thought you meant you were getting false positives even with the patch. Doh!
I haven't time to reroll this at the moment, but it's not a very big patch, so unless things have changed massively shouldn't be too much work :)
Comment #13
mgiffordPossible duplication from the D6 version relating to hook_access #223892: Parameters to hook_access() have changed in D6
Comment #14
mgiffordJust updating the patch in #5.
Comment #15
frank ralf commentedGot another false positive with "Statistics Advanced" module, probably due to the fact that this internal function doesn't start with an underscore:
Will try the above patch.
EDIT
Adding an underscore to the function name doesn't amend this.
Comment #16
klausiCoder 7.x-1.x is frozen now and will not receive any updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.