The sniff in Drupal_Sniffs_NamingConventions_ValidGlobalSniff says, "global variables should start with a single underscore followed by the module and another underscore". This standard only applies to contrib modules and themes. Can we amend the sniff so it doesn't complain about globals like $user, $theme, and $conf in core modules?

Comments

klausi’s picture

Category: task » support
Status: Active » Fixed

There is a white list of core globals in NamingConventions/ValidGlobalSniff.php, feel free to create a bug report if a particular global is missing.

traviscarden’s picture

Title: Don't complain about global variable naming convention in core code » $language_interface missing from global variables whitelist
Category: support » bug
Status: Fixed » Needs review
StatusFileSize
new673 bytes

Ah! Thank you. Then the problem is that $language_interface is missing from the whitelist. Here's a patch.

arnested’s picture

Patch looks fine to me.

$language_interface is a Drupal 8-only global variable. Don't know whether that should be addressed in some special way?

klausi’s picture

Status: Needs review » Fixed

Committed #2: http://drupalcode.org/project/drupalcs.git/commit/fda9b1d

@arnested: I don't think that special casing is necessary. It only means that if there is a contrib module in D6 or D7 using global $language_interface then drupalcs will not throw an error. This is an unlikely edge case and acceptable.

Status: Fixed » Closed (fixed)

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