Bug 1736559 - [lint] Fix codespell silently fixing files, r=linter-reviewers,sylvestre
authorAndrew Halberstadt <ahal@mozilla.com>
Tue, 19 Oct 2021 19:11:09 +0000
changeset 596395 f42752e51c9c5986e9e36d7f522298d32aa8984d
parent 596394 82473ffd65381541a12d2b9eaa8c64455e2f4065
child 596396 bd985949aa5cc7941e944ac33ec9ea51b6584100
push id38896
push userabutkovits@mozilla.com
push dateTue, 19 Oct 2021 21:51:00 +0000
treeherdermozilla-central@e9071741b84c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinter-reviewers, sylvestre
bugs1736559
milestone95.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1736559 - [lint] Fix codespell silently fixing files, r=linter-reviewers,sylvestre We have a check in the 'CodespellProcess' class to ignore errors that are fixing single letter camelCase errors (since these tend to be used frequently. Unfortunately, when using '--fix', these errors are fixed regardless as the fixing happens with the codespell process. Since we increment the 'fix' variable after the check happens, we don't even report that anything was 'fixed'. Ideally we would find a way to prevent these types of errors from being fixed, but for now this at will at least ensure that the user is notified that something was modified. Differential Revision: https://phabricator.services.mozilla.com/D128885
tools/lint/spell/__init__.py
--- a/tools/lint/spell/__init__.py
+++ b/tools/lint/spell/__init__.py
@@ -50,23 +50,24 @@ class CodespellProcess(LintProcess):
         try:
             match = CODESPELL_FORMAT_REGEX.match(line)
             abspath, line, typo, correct = match.groups()
         except AttributeError:
             if "FIXED: " not in line:
                 print("Unable to match regex against output: {}".format(line))
             return
 
+        if CodespellProcess._fix:
+            CodespellProcess.fixed += 1
+
         # Ignore false positive like aParent (which would be fixed to apparent)
         # See https://github.com/lucasdemarchi/codespell/issues/314
         m = re.match(r"^[a-z][A-Z][a-z]*", typo)
         if m:
             return
-        if CodespellProcess._fix:
-            CodespellProcess.fixed += 1
         res = {
             "path": abspath,
             "message": typo.strip() + " ==> " + correct,
             "level": "error",
             "lineno": line,
         }
         results.append(result.from_config(self.config, **res))