This article here: Writing .info files (Drupal 7.x) suggests how project names should be written. You'll want to take a look at the 'Properties' section. The very first sub-section called 'name (Required)' mentions:

name (Required)

The displayed name of your module. Since module names are proper names, it should be capitalized as a proper name (e.g., "Really Neat Widget", not "really neat widget" or "Really neat widget"), and it should be a human-readable name (not really_neat_widget). This name will appear on the Modules page.

(I emphasized the part that dictates how module/theme names should be written.)

Coder should check this and suggest it so hat people start being aware of the existence of this coding standard. I mean, there are so many modules out there that 'violate' this rule (some might even argue that it is a suggestion rather than a rule/standard).

There should -of course- be exceptions for when 3rd party projects/services like 'jQuery' for example and acronyms like 'CCK' or 'HTML' or 'JSON' or 'UI' are used as parts of the name. For example 'jQuery Update' should respect the capitalization that the respective 3rd party author has chosen for their project.

Note: The standard for long has been to use Sentence case for module/theme names (same as UI elements like widget labels for example). This has changed to suggest that we use Proper Name Case from now on. For more information regarding this decision, see: #1346158: Decide on coding standard for capitalization of module names [policy, no patch]

PS: We still use Sentence case for all core modules, this issue was filed against D8 core to correct this, but it is not clear yet if we will only make the change for D8 or if we will also backport to D7/D6: #1430452: Use Proper Name Case for core modules

Comments

klonos’s picture

I don't know if this would be possible at all (I am sure it would be tricky though)...

If a reviewed project's name is found to 'violate' the capitalization standard, then a check should run against all project's files (like the README & INSTALL files) for occurrences of the wrong string and suggest that it is changed there as well. Possible candidates should be any commends and help text within code that include the project's name.

klonos’s picture

...project names like 'ImageCache' -that use camel-casing- fall under the same category where not only the first letter of the first word is capitalized. It should be 'Imagecache' or if that name simply seems too ugly, 'Image cache' then. I think that names like 'ImageAPI' should be allowed though, since the 'API' part is an acronym (if not, then perhaps it could be 'Image API' instead).

In cases such as 'CSS Injector' -where the acronym is at the start of its name-, there should be no other capitalization in the rest of the words comprising the project's name. IOW it should be 'CSS injector'.

cweagans’s picture

Actually, this is completely doable.

Get the project name from the .info file -> $project_name
$new_project_name = strtolower($project_name);
$new_project_name = ucfirst($project_name);
if ($new_project_name != $project_name) {
// Throw a warning. there might be a problem.
}

Don't make it perfect. Just make it work for 80% of the cases.

Another exception: jQuery update. jQuery should be capitalized as I just wrote it.

klonos’s picture

That's a really nice start Cameron! Thanx.

In order to cover the rest 19% of the cases:

- $project_name should be broken down to a words list/array.
- loop through each word in this list and check it against a list of allowed exceptions (that will need to be kept up to date).
- if the 1st word is not in the exception list, then ucfirst it.
- if the rest of the words are not in the exception list, then strtolower them.
- put/concatenate the separate words back to a single $new_project_name (this can of course be done inside the loop as we go).

...then compare & throw warning.

Now, these are quite a few things to do with a project name and that might already be compliant to our standards in the first place. So, why waste CPU power in such cases? To avoid unnecessary checks, it might be a good idea to do an initial check like so:

- check if only the first letter of the name is upper case and the rest or it lower.
- if not, *only then* run it through our sanitizer process/check.

Well, that leaves us with the rest of the 1% of cases which might be:

- incorrect non-capitalization of words ("cck" instead of "CCK", "jquery" instead of "jQuery" etc.). These will pass the only-first-letter-of-the-first-word rule, but still are not correctly capitalized. We will already have the list of how these are properly capitalized in our sanitizer's exceptions list, so why not check that too?
- things we didn't think of ;)

PS: I kinda like something like $sanitized_project_name or $suggested_project_name better in order to be more descriptive than simply "new".

cweagans’s picture

I'm not super concerned with catching all the cases, and really disinterested in the idea of having/maintaining a list of exceptions - something that would require ongoing work (new additions every time somebody else comes up with an exception). I think that, in this case, just run through a really simple check like I described and throw a warning saying that there "MIGHT" be something wrong with their module name and that it might be worth looking at the code standards for module naming.

That being said, there's probably nothing really wrong with doing a more thorough check, as long as there's not a list of exceptions to maintain.

stella’s picture

Other than in the security reviews, we try to minimise all false positives, so don't see a solution to this as we need to be able to support "jQuery update" etc.

klonos’s picture

Yes, I know that there are acceptable exceptions to the standard and these cases were discussed previously in this issue. We seem to agree though that maintaining a complete list of these specific exceptions would not be something possible or -to put it nicely- something worth the trouble. We see no other possible *generic* way to deal with all of them either. We do seem to agree though that *it would be nice* to have a simple check for the generic case where the naming standard seems to be *possibly* broken. In such cases, we could simply through a message that would also link to the standards page. That would probably (and hopefully) be enough to lead to most such cases being "self-healed". Right now, it seems we have no other way to "evangelize" the proper way of naming projects and there seems to be this bad habit/tendency for people to name them however they see fit/nice/cool or however "it's done in other projects" - despite the standard being available and quite clear about it.

Michelle’s picture

-1 to checking or even having this rule at all. I realize that coding standards are important to have readable code but dictating how people write the names of their modules is ridiculous. This is one I refuse to follow and I think the rule should simply be dropped. Outside of one line in the .info file, the human readable name isn't even code so why should it be a coding standard?

Michelle Cox (not Michelle cox)

klonos’s picture

Point taken Michelle, but this issue is about using Coder in order to "enforce" a policy that is already in place. Perhaps you need to see this from this perspective and also file a new issue about removing that policy from drupal coding standards. If that issue got accepted and fixed, then I'd be happy to close this one as "won't fix".

I'm sure you understand, since Drupal is someone else's "baby", its coding standards a "baby" of a lot of other people and this issue "my baby" ;)

Michelle’s picture

I don't actually know where you file issues against coding standards.... Suggestions?

Edit: I asked on IRC and found where to put it: #1346158: Decide on coding standard for capitalization of module names [policy, no patch]

Michelle

jhodgdon’s picture

That issue #1346158: Decide on coding standard for capitalization of module names [policy, no patch] is still being discussed. This issue should definitely not be acted upon until the coding standard has been decided on. My opinion is that whatever is adopted should only apply to Drupal 8 and beyond though, so probably this shouldn't be checked for D6/7.

klonos’s picture

Category: task » feature
Status: Active » Postponed

...the standard has changed. This feature request still stands, but now the "correct capitalization" that we should check for is Proper Name Case for module & theme names. Setting to "postponed" (till we have a 8.x branch for Coder) because it seems that not even core modules will change their case till after D8.

...I will update the issue's summary as soon as Writing .info files (Drupal 7.x) get updated.

jhodgdon’s picture

The page on info files has been updated to the current standard.

klonos’s picture

Thanx for the heads-up Jennifer. I've updated the issue's summary. Please take a look to make sure I didn't miss anything.

jhodgdon’s picture

It looks fine to me. I did just now update the standard to include a note on acronyms and trade names, as you suggested on the other issue.

klonos’s picture

Thanx ;)

mgifford’s picture

Issue tags: +D8 upgrade path, +D8

Tagging.

mgifford’s picture

Issue summary: View changes

...the standard has changed to suggest that we use Proper Name Case instead of the old Sentence case for module/theme names. See http://drupal.org/node/1346158

klausi’s picture

Status: Postponed » Closed (won't fix)

Coder 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.