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

jcnventura - August 8, 2008 - 19:55
Title:Coder should not check camelCase in .test files» Coder should not check camelCase for class methods

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

jcnventura - August 8, 2008 - 21:01
Status:active» needs review

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

AttachmentSize
coder_class_methods.patch 842 bytes

#3

fonant - September 17, 2008 - 12:39

I tend to agree with this idea: class methods look much nicer in camelCase.

#4

douggreen - September 20, 2008 - 12:39
Status:needs review» needs work

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

douggreen - September 20, 2008 - 13:10
Assigned to:Anonymous» douggreen

This patch is pretty broken, but I didn't want to lose the work, so here it is...

AttachmentSize
271028.patch 5.66 KB

#6

douggreen - September 20, 2008 - 15:42
Status:needs work» needs review

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.

AttachmentSize
271028.patch 5.67 KB

#7

stella - September 28, 2008 - 12:59
Status:needs review» needs work

Patch needs to be re-rolled. Can't get it to apply to 6.x-1.x or 6.x-2.x branches.

#8

stella - October 23, 2008 - 10:47
Status:needs work» needs review

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

AttachmentSize
coder_271028.patch 5.76 KB

#9

jcnventura - October 27, 2008 - 11:38
Status:needs review» needs work

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

stella - October 27, 2008 - 12:21
Status:needs work» needs review

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

jcnventura - March 17, 2009 - 21:59
Status:needs review» reviewed & tested by the community

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

AttachmentSize
coder_no_class_camelcase.patch 3.1 KB

#12

Wim Leers - March 21, 2009 - 20:06

Patch works as advertised.

#13

stella - May 20, 2009 - 13:02
Version:6.x-1.x-dev» 6.x-2.x-dev
Status:reviewed & tested by the community» fixed

Committed for the 6.x-2.x and 7.x branches, along with tests.

#14

System Message - June 3, 2009 - 13:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.