• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 25443604553

06 May 2026 03:05PM UTC coverage: 92.879% (-0.04%) from 92.915%
25443604553

push

github

web-flow
[pants_ng] Scaffolding for a pants_ng mode. (#23319)

In this mode the command line is parsed as an
NG invocation, and dispatched appropriately.

Of course at the moment there are no
implementations to dispatch to. That will follow.

This does expose a new option, `pants_ng` to users. 
There is a big warning not to set it, but we're not trying
to hide that we're working on a new thing, so I am
comfortable with this.

25 of 76 new or added lines in 9 files covered. (32.89%)

1294 existing lines in 76 files now uncovered.

92234 of 99306 relevant lines covered (92.88%)

4.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/python/pants/backend/project_info/count_loc.py
1
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from pants.core.goals.resolves import ExportableTool
6✔
4
from pants.core.util_rules.external_tool import TemplatedExternalTool, download_external_tool
6✔
5
from pants.engine.console import Console
6✔
6
from pants.engine.fs import MergeDigests, PathGlobs, SpecsPaths
6✔
7
from pants.engine.goal import Goal, GoalSubsystem
6✔
8
from pants.engine.intrinsics import merge_digests, path_globs_to_digest
6✔
9
from pants.engine.platform import Platform
6✔
10
from pants.engine.process import Process, execute_process_or_raise
6✔
11
from pants.engine.rules import collect_rules, concurrently, goal_rule, implicitly
6✔
12
from pants.engine.unions import UnionRule
6✔
13
from pants.option.option_types import ArgsListOption
6✔
14
from pants.util.logging import LogLevel
6✔
15
from pants.util.strutil import pluralize
6✔
16

17

18
class SuccinctCodeCounter(TemplatedExternalTool):
6✔
19
    options_scope = "scc"
6✔
20
    name = "SCC"
6✔
21
    help = "The Succinct Code Counter, aka `scc` (https://github.com/boyter/scc)."
6✔
22

23
    default_version = "3.0.0"
6✔
24
    default_known_versions = [
6✔
25
        "3.0.0|linux_arm64 |04f9e797b70a678833e49df5e744f95080dfb7f963c0cd34f5b5d4712d290f33|1768037",
26
        "3.0.0|linux_x86_64|13ca47ce00b5bd032f97f3af7aa8eb3c717b8972b404b155a378b09110e4aa0c|1948341",
27
        "3.0.0|macos_arm64 |846cb1b25025a0794d455719bc17cfb3f588576a58af1d95036f6c654e294f98|2006145",
28
        "3.0.0|macos_x86_64|9c3064e477ab36e16204ad34f649372034bca4df669615eff5de4aa05b2ddf1a|2048134",
29
    ]
30
    default_url_template = (
6✔
31
        "https://github.com/boyter/scc/releases/download/v{version}/scc-{version}-{platform}.zip"
32
    )
33
    default_url_platform_mapping = {
6✔
34
        "macos_arm64": "arm64-apple-darwin",
35
        "macos_x86_64": "x86_64-apple-darwin",
36
        "linux_arm64": "arm64-unknown-linux",
37
        "linux_x86_64": "x86_64-unknown-linux",
38
    }
39

40
    args = ArgsListOption(
6✔
41
        example="--no-cocomo",
42
        passthrough=True,
43
        extra_help="Refer to to https://github.com/boyter/scc.",
44
    )
45

46
    def generate_exe(self, _: Platform) -> str:
6✔
47
        return "./scc"
3✔
48

49

50
class CountLinesOfCodeSubsystem(GoalSubsystem):
6✔
51
    name = "count-loc"
6✔
52
    help = "Count lines of code."
6✔
53

54

55
class CountLinesOfCode(Goal):
6✔
56
    subsystem_cls = CountLinesOfCodeSubsystem
6✔
57
    environment_behavior = Goal.EnvironmentBehavior.LOCAL_ONLY
6✔
58

59

60
@goal_rule
6✔
61
async def count_loc(
6✔
62
    console: Console,
63
    succinct_code_counter: SuccinctCodeCounter,
64
    specs_paths: SpecsPaths,
65
    platform: Platform,
66
) -> CountLinesOfCode:
67
    if not specs_paths.files:
3✔
UNCOV
68
        return CountLinesOfCode(exit_code=0)
1✔
69

70
    specs_digest, scc_program = await concurrently(
3✔
71
        path_globs_to_digest(PathGlobs(globs=specs_paths.files)),
72
        download_external_tool(succinct_code_counter.get_request(platform)),
73
    )
74
    input_digest = await merge_digests(MergeDigests((scc_program.digest, specs_digest)))
3✔
75
    result = await execute_process_or_raise(
3✔
76
        **implicitly(
77
            Process(
78
                argv=(scc_program.exe, *succinct_code_counter.args),
79
                input_digest=input_digest,
80
                description=f"Count lines of code for {pluralize(len(specs_paths.files), 'file')}",
81
                level=LogLevel.DEBUG,
82
            )
83
        )
84
    )
85
    console.print_stdout(result.stdout.decode())
3✔
86
    return CountLinesOfCode(exit_code=0)
3✔
87

88

89
def rules():
6✔
90
    return (*collect_rules(), UnionRule(ExportableTool, SuccinctCodeCounter))
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc