diff --git a/src/lint/linter/ArcanistPyFlakesLinter.php b/src/lint/linter/ArcanistPyFlakesLinter.php index e8a37a79..6f73ecf4 100644 --- a/src/lint/linter/ArcanistPyFlakesLinter.php +++ b/src/lint/linter/ArcanistPyFlakesLinter.php @@ -1,88 +1,93 @@ getExecutableCommand()); $matches = array(); - if (preg_match('/^(?P\d+\.\d+\.\d+)$/', $stdout, $matches)) { + $pattern = '/^(?P\d+\.\d+\.\d+)( Python.*)?$/'; + if (preg_match($pattern, $stdout, $matches)) { return $matches['version']; } else { return false; } } public function getInstallInstructions() { return pht('Install pyflakes with `%s`.', 'pip install pyflakes'); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { $lines = phutil_split_lines($stdout, false); $messages = array(); foreach ($lines as $line) { $matches = null; - if (!preg_match('/^(.*?):(\d+): (.*)$/', $line, $matches)) { + $pattern = '/^(?.*?):(?\d+):(?\d*) (?.*)$/'; + if (!preg_match($pattern, $line, $matches)) { continue; } foreach ($matches as $key => $match) { $matches[$key] = trim($match); } $severity = ArcanistLintSeverity::SEVERITY_WARNING; - $description = $matches[3]; + $description = $matches['message']; $error_regexp = '/(^undefined|^duplicate|before assignment$)/'; if (preg_match($error_regexp, $description)) { $severity = ArcanistLintSeverity::SEVERITY_ERROR; } $message = new ArcanistLintMessage(); $message->setPath($path); - $message->setLine($matches[2]); + $message->setLine($matches['line']); + if ($matches['column'] != '') { + $message->setChar($matches['column']); + } $message->setCode($this->getLinterName()); $message->setName($this->getLinterName()); $message->setDescription($description); $message->setSeverity($severity); $messages[] = $message; } return $messages; } protected function canCustomizeLintSeverities() { return false; } } diff --git a/src/lint/linter/__tests__/pyflakes/pyflakes.lint-test b/src/lint/linter/__tests__/pyflakes/pyflakes.lint-test index 58765cd4..35d0afea 100644 --- a/src/lint/linter/__tests__/pyflakes/pyflakes.lint-test +++ b/src/lint/linter/__tests__/pyflakes/pyflakes.lint-test @@ -1,7 +1,7 @@ import sys, os x += 1 ~~~~~~~~~~ -warning:1:0 -warning:1:0 -error:3:0 +warning:1: +warning:1: +error:3: