1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Recognize error codes from Flake8 extensions

Summary:
Flake8 extensions are allowed to use their own letter-prefixed codes. For
example, the flake8-debugger extension emits 'T002'-tagged messages.

This change relaxes getLintCodeFromLinterConfigurationKey() to also recognize
extension codes. Otherwise, attempting to configure message severities for
e.g. 'T002' would result in an exception.

Messages from extensions continue to default to ERROR severity, as they did
before this change.

Test Plan:
Successfully reduced the severity of 'T002' to a warning via .arclint:

    "severity": {
        "T002": "warning"
    }

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15810
This commit is contained in:
Jon Parise 2016-04-27 13:48:46 -07:00
parent a2ab38df78
commit 9b07d1c480

View file

@ -91,12 +91,13 @@ final class ArcanistFlake8Linter extends ArcanistExternalLinter {
} else {
// "E": PEP8 Error
// "F": PyFlakes Error
// or: Flake8 Extension Message
return ArcanistLintSeverity::SEVERITY_ERROR;
}
}
protected function getLintCodeFromLinterConfigurationKey($code) {
if (!preg_match('/^(E|W|C|F)\d+$/', $code)) {
if (!preg_match('/^[A-Z]\d+$/', $code)) {
throw new Exception(
pht(
'Unrecognized lint message code "%s". Expected a valid flake8 '.