mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Recover from PyLint raising messages at character "-1"
Summary: Fixes T9257. For some messages, PyLint can raise at "character -1", which we don't allow since we don't consider it to make sense. Test Plan: - Added failing unit test from T9257. - Applied patch. - Test now passes. Reviewers: joshuaspence, chad Reviewed By: joshuaspence, chad Maniphest Tasks: T9257 Differential Revision: https://secure.phabricator.com/D13991
This commit is contained in:
parent
1d3266395f
commit
43f8e7eb71
3 changed files with 12 additions and 8 deletions
|
@ -130,10 +130,15 @@ final class ArcanistPyLintLinter extends ArcanistExternalLinter {
|
|||
continue;
|
||||
}
|
||||
|
||||
// NOTE: PyLint sometimes returns -1 as the character offset for a
|
||||
// message. If it does, treat it as 0. See T9257.
|
||||
$char = (int)$matches[1];
|
||||
$char = max(0, $char);
|
||||
|
||||
$message = id(new ArcanistLintMessage())
|
||||
->setPath($path)
|
||||
->setLine($matches[0])
|
||||
->setChar($matches[1])
|
||||
->setChar($char)
|
||||
->setCode($matches[2])
|
||||
->setSeverity($this->getLintMessageSeverity($matches[2]))
|
||||
->setName(ucwords(str_replace('-', ' ', $matches[3])))
|
||||
|
|
6
src/lint/linter/__tests__/pylint/negativechar.lint-test
Normal file
6
src/lint/linter/__tests__/pylint/negativechar.lint-test
Normal file
|
@ -0,0 +1,6 @@
|
|||
"""Docstring"""
|
||||
|
||||
"""
|
||||
Useless string """
|
||||
~~~~~~~~~~
|
||||
warning:4:0 See T9257.
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<languages>
|
||||
<lang>
|
||||
</languages>
|
||||
~~~~~~~~~~
|
||||
error:4:7
|
||||
error:5:1
|
Loading…
Reference in a new issue