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

Commits:

2 changed files:

Changes:

  • python/mozlint/mozlint/cli.py
    ... ... @@ -10,6 +10,30 @@ from pathlib import Path
    10 10
     from mozlint.errors import NoValidLinter
    
    11 11
     from mozlint.formatters import all_formatters
    
    12 12
     
    
    13
    +# We (the Tor Project) do not use all of Mozilla's linters.
    
    14
    +# Below is a list of linters we do not use,
    
    15
    +# these will be skipped when running `./mach lint` commands.
    
    16
    +INACTIVE_LINTERS = [
    
    17
    +    "android-api-lint",
    
    18
    +    "android-checkstyle",
    
    19
    +    "android-format",
    
    20
    +    "android-javadoc",
    
    21
    +    "android-lint",
    
    22
    +    "android-test",
    
    23
    +    "clippy",
    
    24
    +    "codespell",
    
    25
    +    "condprof-addons",
    
    26
    +    "file-perm",
    
    27
    +    "ignorefile",
    
    28
    +    "license",
    
    29
    +    "lintpref",
    
    30
    +    "perfdocs",
    
    31
    +    "rejected-words",
    
    32
    +    "rst",
    
    33
    +    "updatebot",
    
    34
    +    "wpt",
    
    35
    +]
    
    36
    +
    
    13 37
     
    
    14 38
     class MozlintParser(ArgumentParser):
    
    15 39
         arguments = [
    
    ... ... @@ -276,6 +300,9 @@ def find_linters(config_paths, linters=None):
    276 300
     
    
    277 301
                 name = name.rsplit(".", 1)[0]
    
    278 302
     
    
    303
    +            if not linters and name in INACTIVE_LINTERS:
    
    304
    +                continue
    
    305
    +
    
    279 306
                 if linters and name not in linters:
    
    280 307
                     continue
    
    281 308
     
    
    ... ... @@ -341,10 +368,14 @@ def run(
    341 368
     
    
    342 369
         if list_linters:
    
    343 370
             lint_paths = find_linters(lintargs["config_paths"], linters)
    
    344
    -        linters = [
    
    371
    +        formatted_linters = [
    
    345 372
                 os.path.splitext(os.path.basename(l))[0] for l in lint_paths["lint_paths"]
    
    346 373
             ]
    
    347
    -        print("\n".join(sorted(linters)))
    
    374
    +        print("\n".join(sorted(formatted_linters)))
    
    375
    +
    
    376
    +        if not linters:
    
    377
    +            print("\nINACTIVE -- ".join(sorted(["", *INACTIVE_LINTERS])).strip())
    
    378
    +
    
    348 379
             print(
    
    349 380
                 "\nNote that clang-tidy checks are not run as part of this "
    
    350 381
                 "command, but using the static-analysis command."
    

  • tools/torbrowser/tb-dev
    ... ... @@ -309,35 +309,10 @@ def lint_changed_files(args):
    309 309
             for f in get_changed_files(get_upstream_basis_commit("HEAD"))
    
    310 310
             if os.path.isfile(f)  # Not deleted
    
    311 311
         ]
    
    312
    -    command_base = ["./mach", "lint"]
    
    313
    -    lint_process = subprocess.run(
    
    314
    -        [*command_base, "--list"], text=True, stdout=subprocess.PIPE, check=True
    
    315
    -    )
    
    316
    -
    
    317
    -    linters = []
    
    318
    -    for line in lint_process.stdout.split("\n"):
    
    319
    -        if not line:
    
    320
    -            continue
    
    321
    -        if line.startswith("Note that clang-tidy"):
    
    322
    -            # Note at end
    
    323
    -            continue
    
    324
    -        if line == "license":
    
    325
    -            # don't lint the license
    
    326
    -            continue
    
    327
    -        if line.startswith("android-"):
    
    328
    -            continue
    
    329
    -        # lint everything else
    
    330
    -        linters.append("-l")
    
    331
    -        linters.append(line)
    
    332
    -
    
    333
    -    if not linters:
    
    334
    -        raise Exception("No linters found")
    
    335
    -
    
    336
    -    if args.fix:
    
    337
    -        command_base.append("--fix")
    
    338 312
         # We add --warnings since clang only reports whitespace issues as warnings.
    
    339
    -    lint_process = subprocess.run(
    
    340
    -        [*command_base, "--warnings", *linters, *file_list], check=False
    
    313
    +    subprocess.run(
    
    314
    +        ["./mach", "lint", "--warnings", "soft", *args.lintargs, *file_list],
    
    315
    +        check=False,
    
    341 316
         )
    
    342 317
     
    
    343 318
     
    
    ... ... @@ -663,9 +638,10 @@ for name, details in {
    663 638
         "lint-changed-files": {
    
    664 639
             "func": lint_changed_files,
    
    665 640
             "args": {
    
    666
    -            "--fix": {
    
    667
    -                "help": "whether to fix the files",
    
    668
    -                "action": "store_true",
    
    641
    +            "lintargs": {
    
    642
    +                "help": "argument to pass to ./mach lint",
    
    643
    +                "metavar": "-- lint-arg",
    
    644
    +                "nargs": "*",
    
    669 645
                 },
    
    670 646
             },
    
    671 647
         },