Closed (fixed)
Project:
Coder
Version:
7.x-1.x-dev
Component:
Coder Upgrade
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Apr 2008 at 15:19 UTC
Updated:
2 Jan 2014 at 23:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
douggreen commentedI'm bumping this to the 6.x version since 5.x is feature frozen.
I'd like to have coder start giving patch files. The patch file won't be able to fix 100% of the problems, but even if it fixes 50%, it would be worth it. This should be do-able using preg_replace(), and writing rules that have replacement regex's.
Comment #2
joachim commentedHere is a small proof of concept patch (on 6, because that's what I have working right now).
It looks only at the 'Control statements should have one space between the control keyword and opening parenthesis' rule, ie, putting a space between "if(condition)".
The approach I take is that each rule in hook_reviews() may define a #patch item which is itself an array of the first two parameters to give to preg_replace to act on the offending line, like this:
The first obvious problem is that several problems can occur on one line, and so this makes making a patch out of these changes pretty much impossible. So rather than build up a patch file from line numbers, I think the approach ought to be to gradually build an fixed copy of the file, and then either output it plain (some users may want to work on their own code and not be comfortable with patch files), or output a patch (by diffing with the original).
And there I leave it for someone else to take further :D
Comment #3
ezra-g commentedThanks for your patch. We already have the coder_format script which seems like it serves the same purpose. Can you clarify how your patch differs from coder_format ?
Comment #4
ezra-g commentedComment #5
joachim commentedI had no idea that existed. It's certainly not advertized ;)
It's also not terribly friendly: it just gives me a notice saying my file has been processed: no idea what has been changed or why.
So I guess the difference here would be that the approach outlined above works within the UI and on the rules defined in coder.module.
Comment #6
solotandem commentedIn the 7.x version, Coder Upgrade will: 1) clean up all the formatting items (like the coder_format script), 2) rewrite the file with the changes, and 3) create a patch file.
Comment #7
mlncn commentedI can confirm that 7.x creates a patch file, but this patch file could be a lot more useful. Currently it is not relative, so that no matter where it is applied (for instance in a fresh download of the 6.x module to be downloaded in sites/default/modules) the patch tries to apply against the already upgraded module (for instance using the absolute path /home/ben/code/dgd7/drupal/sites/default/files/coder_upgrade/new/submitagain/submitagain.info). Would it be possible to create a patch file that would work relative to the module's directory? (The sort that could be attached to an issue queue?)
Thanks!
Comment #8
solotandem commentedThe Coder Upgrade patch file no longer includes the extra portions of the path, hopefully allowing the patch to be submitted in an issue queue.
Try it out in 7.x-1.0-beta5.
Comment #9
stella commentedComment #10
solotandem commented