]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Recognize error codes from Flake8 extensions
authorJon Parise <jon@pinterest.com>
Wed, 27 Apr 2016 20:48:46 +0000 (13:48 -0700)
committerJon Parise <jon@pinterest.com>
Wed, 27 Apr 2016 22:11:46 +0000 (15:11 -0700)
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

src/lint/linter/ArcanistFlake8Linter.php

index bd45082dc8cd94684829878a3937d5957297bfed..6f93ef8c0d8d5528dd62a3d7b3459d0a27684be8 100644 (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 '.