[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-128.0esr-14.0-2] 2 commits: Bug 42728: Modify ./mach lint to skip unused linters

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Wed Jul 31 15:08:42 UTC 2024



Pier Angelo Vendrame pushed to branch tor-browser-128.0esr-14.0-2 at The Tor Project / Applications / Tor Browser


Commits:
632c5e7c by Beatriz Rizental at 2024-07-31T15:05:11+00:00
Bug 42728: Modify ./mach lint to skip unused linters

- - - - -
67de9f05 by Beatriz Rizental at 2024-07-31T15:05:11+00:00
fixup! Bug 41803: Add some developer tools for working on tor-browser

- - - - -


2 changed files:

- python/mozlint/mozlint/cli.py
- tools/torbrowser/tb-dev


Changes:

=====================================
python/mozlint/mozlint/cli.py
=====================================
@@ -10,6 +10,30 @@ from pathlib import Path
 from mozlint.errors import NoValidLinter
 from mozlint.formatters import all_formatters
 
+# We (the Tor Project) do not use all of Mozilla's linters.
+# Below is a list of linters we do not use,
+# these will be skipped when running `./mach lint` commands.
+INACTIVE_LINTERS = [
+    "android-api-lint",
+    "android-checkstyle",
+    "android-format",
+    "android-javadoc",
+    "android-lint",
+    "android-test",
+    "clippy",
+    "codespell",
+    "condprof-addons",
+    "file-perm",
+    "ignorefile",
+    "license",
+    "lintpref",
+    "perfdocs",
+    "rejected-words",
+    "rst",
+    "updatebot",
+    "wpt",
+]
+
 
 class MozlintParser(ArgumentParser):
     arguments = [
@@ -276,6 +300,9 @@ def find_linters(config_paths, linters=None):
 
             name = name.rsplit(".", 1)[0]
 
+            if not linters and name in INACTIVE_LINTERS:
+                continue
+
             if linters and name not in linters:
                 continue
 
@@ -341,10 +368,14 @@ def run(
 
     if list_linters:
         lint_paths = find_linters(lintargs["config_paths"], linters)
-        linters = [
+        formatted_linters = [
             os.path.splitext(os.path.basename(l))[0] for l in lint_paths["lint_paths"]
         ]
-        print("\n".join(sorted(linters)))
+        print("\n".join(sorted(formatted_linters)))
+
+        if not linters:
+            print("\nINACTIVE -- ".join(sorted(["", *INACTIVE_LINTERS])).strip())
+
         print(
             "\nNote that clang-tidy checks are not run as part of this "
             "command, but using the static-analysis command."


=====================================
tools/torbrowser/tb-dev
=====================================
@@ -309,35 +309,10 @@ def lint_changed_files(args):
         for f in get_changed_files(get_upstream_basis_commit("HEAD"))
         if os.path.isfile(f)  # Not deleted
     ]
-    command_base = ["./mach", "lint"]
-    lint_process = subprocess.run(
-        [*command_base, "--list"], text=True, stdout=subprocess.PIPE, check=True
-    )
-
-    linters = []
-    for line in lint_process.stdout.split("\n"):
-        if not line:
-            continue
-        if line.startswith("Note that clang-tidy"):
-            # Note at end
-            continue
-        if line == "license":
-            # don't lint the license
-            continue
-        if line.startswith("android-"):
-            continue
-        # lint everything else
-        linters.append("-l")
-        linters.append(line)
-
-    if not linters:
-        raise Exception("No linters found")
-
-    if args.fix:
-        command_base.append("--fix")
     # We add --warnings since clang only reports whitespace issues as warnings.
-    lint_process = subprocess.run(
-        [*command_base, "--warnings", *linters, *file_list], check=False
+    subprocess.run(
+        ["./mach", "lint", "--warnings", "soft", *args.lintargs, *file_list],
+        check=False,
     )
 
 
@@ -663,9 +638,10 @@ for name, details in {
     "lint-changed-files": {
         "func": lint_changed_files,
         "args": {
-            "--fix": {
-                "help": "whether to fix the files",
-                "action": "store_true",
+            "lintargs": {
+                "help": "argument to pass to ./mach lint",
+                "metavar": "-- lint-arg",
+                "nargs": "*",
             },
         },
     },



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/646ee32d1547c1cf6d18535a833968dc943bdf0d...67de9f05894fd4606d5b79ae11cb65f864128323

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/646ee32d1547c1cf6d18535a833968dc943bdf0d...67de9f05894fd4606d5b79ae11cb65f864128323
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240731/ccd0c544/attachment-0001.htm>


More information about the tor-commits mailing list