Closed (fixed)
Project:
Coder
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Jan 2007 at 14:54 UTC
Updated:
16 May 2007 at 00:09 UTC
What I'd love is the ability to do a scan for coding standards across all of core.
But at the very least, it'd be rad if we could scan all the .inc files and stuff included in the module file.
Comments
Comment #1
douggreen commentedI restricted the example.com/coder review to just the .module files because scanning lots of files at once can take a page a long time.
You can, of course, enable all of the core modules on example.com/admin/settings/coder and then example.com/coder will scan all of the .module files.
I could add an option to the settings page to scan additional file types (.inc), but let the user name others as well. I could also work at actually detecting the require and include files and read them, regardless of extension - however, many of these includes are dynamically generated, and attempting to figure them out will be problematic.
What I'd like to do is move some of these options from the settings page to the coder page. I'd like the selected reviews to be a selection at the top of every coder review page. And if we add your include option, that too should probably be an option at the top of every page.
Comment #2
webchickWhat I had pictured is another menu callback, like coder/all or coder/core... which would grep through all files in a defined extension list (.profile, .php, .module, .install) and check them over for coding standards violations. This would take a REALLY long time, though, and might run into PHP timeout issues. I'm thinking maybe a button you click on this page that starts the process, and then it does a little bit every cron run, similar to how the search indexing stuff works... with a big report at the end. This would require storage somewhere though. Hrm.
Comment #3
webchickHere's a separate "coder_all.module" that does this: http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/webchick/code...
A couple observations:
1. This code:
...had to be copied/pasted from coder_page(). Probably makes sense to make this an API function... coder_active_reviews() ?
2. I originally had this as a sub-path of coder (coder/all), but the problem is that you're forced to load the original ?q=coder page in order to get there (assuming you use the navigation menu), which locks up for 30 seconds or so. Does it make sense to make the ?q=coder page just a "jump off" page with links/tabs to:
- Scan all active modules
- Scan all modules
- Scan all of core
?
3. I coded this as a secondary module because I wasn't sure a) how much overhead it would represent and b) how long it would take to do the scan. Turns out, neither of them are very bad. You've done a really good job of making it really easy to make custom scanners based on coder module. And in a clean core installation, anyway, the scan took pretty much as long as it does the module-only scan. Not sure what's up with that.
So. Should I re-roll this as a patch for coder module (and at the same time take care of 1 and 2), or keep it as a separate module?
Comment #4
douggreen commentedI'd like to see better options, on the actual coder page. I like the idea of coder, coder/all, coder/active, coder/core. I think example.com/coder could really be the settings page that allows you to select the modules (all core, all active, select list) and choose the reviews.
Comment #5
douggreen commentedI've made some significant UI improvements that:
(1) Puts a settings form at the top of all output pages
(2) Adds some AJAX/jquery to select modules
(3) Implements coder/all and coder/core
(4) Displays the results in collapsible/collapsed fieldsets. Include files are collapsed within the parent module. Only modules with warnings are uncollapsed.
These changes are currently in the HEAD branch. Once I get some confirmation from users that this is stable, I'll move it to the DRUPAL-5 branch and make a new release from there. These changes will not be ported to DRUPAL-4-7.
Comment #6
douggreen commentedComment #7
douggreen commentedI should have set this to fixed. Please test with HEAD and let me know what you think :)
Comment #8
douggreen commentedI've added an "experimental" cache option that dramatically improves performance when many files where most of them have not changed. As this is "experimental" still, the default is "off", so to test this you will need to enable it on the admin/settings/coder page.
Comment #9
douggreen commentedI just ran it on a D5 core. If I do say so myself, this is really looking cool! The color coded warnings are nice. And the new experimental cache is great. I'm anxious to get your feedback and make a release of all the new stuff!
Comment #10
webchickI know!! I've just been swamped with work stuff, and want to make sure I have time to look it over thoroughly. :( I'll try over my lunch break today. :D
Comment #11
webchickActually, I don't see coder/all in HEAD. So opening this back up. Looks like the internals of do_coder_reviews have changed, so my poor module doesn't work anymore either. ;(
Comment #12
douggreen commentedActually, I used coder/active and coder/core. I was wrong when above when I said these features were in HEAD. They're actually in DRUPAL-5, but I think you know this from now from some of the other issues entered last night. Can we close this one back up?
Comment #13
webchickNo, because this feature request is about the ability to scan ALL files (every one. includes, themes, etc.) from the root of the Drupal install.
I've reworded the issue title so this is a bit more clear.
Comment #14
douggreen commentedOk, I think I get it. "core" is a special case. When selecting "core" you'd like to also scan the "includes" directory and the ".php" files in the root. I think you'd also like to scan everything in "themes" but I'm postponing that a little based on wanting to add support for themes.
I don't want to start at the root and just look for all php files (.theme, .engine, .inc, .php, .module) because it would end up traversing and getting more than we want (sites needs to be excluded, people put modules in the core modules directory, I think that at one time the 3rd party xmltemplate had to be downloaded and installed in the themes/engines directory).
So this is why it seems like a "special" case to me. When "core" do what I said above in the second line. I see the value in it, but would like to consider if it needs to be generalized any.
I'd like to add support for themes too. But it's an entirely different feature request. I don't think it's going to be too difficult, but does have some special cases, such as including more files. What do we do about the engine? And stuff like that. Maybe adding support for themes is the next "big" feature to add. Se should probably create a new issue for that.
Comment #15
webchickNo, it should just scan _ALL_ PHP files in a given Drupal installation. So I can do a complete, site-wide check for code standards violations, security problems, etc. Has nothing to do with core vs. not core. If I downloaded just a version of core, then I could get it to scan core, but if I have a site from a client, I could scan the whole thing from there too.
If this is a "won't fix" because of the theme stuff, that's cool; I'll try and fix up coder_all module, since it works for my needs. :)
Comment #16
douggreen commentedSorry for the multi-part, numbered, indented response... maybe a little too formal, but it's what came out while I was writing/thinking about this.
What you're trying to do actually doesn't make sense to me.
Two possible action items:
To fix coder_all:
Comment #17
webchickYes, I do have a fast computer and access to php.ini where I can raise the timeout. ;)
But sure, let's start with "I want to be able to code scan all of core (which includes the /includes files, installation profiles, .install files, and default themes) for coding standards violations." I can work with that. :) That would just involve changing the coder/core to scan all of these files,not just core modules.
Does that sound acceptable or not?
Comment #18
douggreen commentedSelect "core" now reviews the top level php and the includes directory. I'm leaving this open because I think I can add themes pretty easily, and when I do that, I want to be sure to get the core themes and engines.
Comment #19
douggreen commentedcoder/all (the new "all" tab) is "core" + every module + every theme. I believe that all that is missing is theme engine support. BTW, coder/core already does all core files + every core module + every core theme (as of the first theme support).
Comment #20
douggreen commentedI added an access setting for coder/all (that you will need to grant permissions to), mainly so it can't be run on my demo site as it's a resource hog.
Comment #21
douggreen commentedDoing some issue housekeeping, ... I think this has been completed for some time
Comment #22
(not verified) commented