Coder should not check camelCase for class methods
dvinegla - June 16, 2008 - 07:49
| Project: | Coder |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | douggreen |
| Status: | closed |
Description
pathauto.test
*
severity: normalLine 32: do not use mixed case (camelCase), use lower case and _
function setUp() {
*
severity: normalLine 52: do not use mixed case (camelCase), use lower case and _
function testPathAuto() {

#1
I think it should even be more general.
Since most object-oriented coding standards recommends the use of camelCase naming (setSomething, getSomething), this exception should be added.
João
#2
Putting my money where my mouth is...
The only complication to this solution is that class methods must explicitly be declared public (or protected or private).
That's the only way I could find of distinguishing class methods from Drupal functions. The simpletest examples should probably be changed to include the 'public' visibility declaration.
João
#3
I tend to agree with this idea: class methods look much nicer in camelCase.
#4
I'd like to have a better check, that knows if you're in a class or not, similar to how coder knows what function you're in. Thus the check will be to ignore camelCase while in a class.
#5
This patch is pretty broken, but I didn't want to lose the work, so here it is...
#6
This patch wasn't as broken as I thought, the main problem was in the simpletests themself (it was catching a spacing error). In another commit, I fixed the simpletest error reporting, which made this easier to detect. Still, as I'm hoping that this will get rid of the camelCase false positives in classes, this patch could use some additional testing.
#7
Patch needs to be re-rolled. Can't get it to apply to 6.x-1.x or 6.x-2.x branches.
#8
Here's a re-rolled patch with some corrections too. It wasn't reviewing for camelCase usage when the line wasn't in a class. It passes all the tests present.
Cheers,
Stella
#9
I applied to the 6.x-2.x branch (of 2008-10-23) and although it applied cleanly, it didn't work at all.. All the camelCases are still being reported..
Also, the "#filename-not" now being inserted in the 6.x-2.x branch seems not to work also..
João
#10
jcnventura: you will need to clear your Drupal cache. I'm not sure the Devel block one will do it, it's probably best to run update.php to be sure.
#11
The patch in #8 was defective as it was lacking a continue inside the class regex handling section.
I have corrected that simple bug and I am including a patch that applies to the current 6.x-1.x-dev. I have tested that it is working properly.
João
#12
Patch works as advertised.
#13
Committed for the 6.x-2.x and 7.x branches, along with tests.
#14
Automatically closed -- issue fixed for 2 weeks with no activity.