From 9b07d1c480f447fea5f0cd9adeb2e7fc838778cc Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 27 Apr 2016 13:48:46 -0700 Subject: [PATCH] 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 --- src/lint/linter/ArcanistFlake8Linter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php index bd45082d..6f93ef8c 100644 --- a/src/lint/linter/ArcanistFlake8Linter.php +++ b/src/lint/linter/ArcanistFlake8Linter.php @@ -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 '.