Page MenuHomePhabricator

Support linters where linter names aren't known ahead of time
Closed, ResolvedPublic

Description

At the moment, Arcanist linters work by defining a lint map like so:

public function getLintNameMap() {
  return array(
    self::VSA_WARNING => pht('Build Warning'),
    self::VSA_ERROR => pht('Build Error'),
  );
}

The problem is that this requires the PHP code to know about all possible lint names ahead of time. In my case, the linter codes are coming from an external utility, and there's no way to know all possible linter codes ahead of time (people might add or remove them in that external tool at any time).

I'd like to override getLintMessageName on ArcanistLinter to bypass this map, but I can't because it's marked as final.

Event Timeline

hach-que closed this task as Resolved.EditedJul 1 2016, 12:55 AM
hach-que claimed this task.

I managed to work around this for now by just doing this manually:

$message = id(new ArcanistLintMessage())
  ->setPath($this->getActivePath())
  ->setLine(idx($lint, 'line', 0))
  ->setChar(idx($lint, 'column', 0))
  ->setCode('VSA-'.idx($lint, 'name', 'No Name'))
  ->setSeverity($severity)
  ->setName(idx($lint, 'name', 'No Name'))
  ->setDescription(idx($lint, 'desc', 'No Description'))
  ->setOriginalText(null)
  ->setReplacementText(null);

return $this->addLintMessage($message);

which is possibly the correct solution anyway.