Page MenuHomePhabricator

Make it easier to parse external linter versions
Needs ReviewPublic

Authored by joshuaspence on May 20 2019, 1:57 AM.
Tags
None
Referenced Files
F19327953: D20526.id48952.diff
Thu, Dec 25, 4:23 PM
F19062704: D20526.id48953.diff
Nov 29 2025, 4:34 PM
F18875272: D20526.id.diff
Nov 5 2025, 5:11 PM
F18869215: D20526.diff
Nov 4 2025, 10:27 AM
F18858896: D20526.id48952.diff
Nov 1 2025, 11:19 PM
F18818477: D20526.diff
Oct 22 2025, 12:34 AM
F18777613: D20526.id48952.diff
Oct 11 2025, 3:54 AM
F18741902: D20526.id.diff
Oct 2 2025, 4:31 PM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Summary

Currently pretty much every external linter has copy-pasted the following code (with minor variations):

public function getVersion() {
  list($stdout) = execx('%C --version', $this->getExecutableCommand());

  $matches = null;
  if (!preg_match('/^v(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
    return null;
  }

  return $matches['version'];
}

We can reduce the boilerplate code here by providing a simpler interface consisting of getVersionFlags and parseVersionOutput, similar to getMandatoryFlags and parseLinterOutput. This change also makes it possible for me to proxy the getVersion method in [[https://github.com/freelancer/flarc/blob/master/src/lint/linter/ArcanistDockerContainerLinterProxy.php | ArcanistDockerContainerLinterProxy]].

Test Plan

Installed a bunch of the external linters and ran unit tests.

Diff Detail

Repository
rARC Arcanist
Branch
lint2
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 22903
Build 31420: Run Core Tests
Build 31419: arc lint + arc unit

Event Timeline

src/lint/linter/ArcanistExternalLinter.php
401

I'm open to suggestions for a better name for this method.

408

I'm open to suggestions for a better name for this method.

Semi-related thought: the current behavior of getVersion (return a string if successful, false if unable to determine the version or null if no version exists) is rather awkward and I feel like we should throw some sort of ArcanistUnableToDetermineLinterVersionException instead of returning false.

Implement parseVersionOutput in ArcanistExternalLinter so that it can be called from within another instance of ArcanistExternalLinter