Every line in a .info file is marked with this invalid message:

Line 6: use quotes around a string literal array index, this is not only a style issue, but a known performance problem
regions[help] = Help

Thanks for confusing me and cluttering my DEV box.

Comments

Anonymous’s picture

It appears the coder review module is incorrectly parsing .info files as PHP. The code to resolve this issue actually exists in the module, but for some reason it is commented out (coder_review.module, lines 1203 - 1217):

function _coder_review_read_and_parse_file(&$coder_args) {
  $is_php_file = 1;
  $regex = '/(' . implode('|', array_merge(array('module'), $coder_args['#php_extensions'])) . ')$/';
  if (!preg_match($regex, $coder_args['#filename'])) {
    $is_php_file = 0;
  /*
    // If this isn't a php file, then don't try to parse it.
    if ((($filepath = realpath($coder_args['#filename'])) && file_exists($filepath))) {
      $full_lines = file($filepath);
      if ($full_lines[0] != '<?php') {
        foreach ($full_lines as $lineno => $line) {
          if (($line = trim($line, "\r\n")) != '') {
            $all_lines[$lineno] = $line;
          }
        }
        $coder_args['#all_lines'] = $all_lines;
        return 1;
      }
    }
  */
  }

I've got the same problems and a pre-commit hook is preventing me from committing my changes. For now, I have un-commented lines 1203 - 1217 and updated the git index so the file is excluded from my commits:

git update-index --assume-unchanged coder_review/coder_review.module

douggreen’s picture

hrm, those lines of code are already commented out in the 7.x-1.x and 7.x-2.x versions.I believe that the project page says that the recommended version is the 7.x-1.x dev version, not the 7.x-1.0 version. But I see how using a dev version is confusing. I'll likely create a 7.x-1.1 version as soon as I create the 7.x-2.1 version, probably a month from now.

I'm going to leave this open because as part of the 7.x-2.x upgrade I want to make info file parsing better.

fonant’s picture

The problem is fixed if you un-comment those lines. Using the 7.x-1.x-dev version doesn't help.

douggreen’s picture

Status: Active » Closed (fixed)

Ok, thanks. The commit http://drupalcode.org/project/coder.git/commit/97a71302 that broke it, I believe was done so that js files could use the coder rules engine. I think that the best solution here is a js exception, rather than to assume all files are PHP. We already have a variable to define #php_extensions, which should cover all known PHP extensions. If there are other non PHP code files that need to be tokenize "like" PHP, we'll need exceptions for them too.

We are really talking about the lexical phase here, not the parse phase. So treating "js" like "php" is fine with me .... internally to the code we should call the variable in_code rather than in_php. But changing the usages of php in all of coder's code is a bit more than I want to do right now. I added a code comment to this affect.

See http://drupalcode.org/project/coder.git/commit/97744fb

stella’s picture

That looks better alright. I hadn't realised that change had broken .info file reviews. I like the addition of the $ext checks.