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

pantsbuild / pants / 23177125175

17 Mar 2026 03:32AM UTC coverage: 52.677% (-40.3%) from 92.932%
23177125175

Pull #23177

github

web-flow
Merge 1824dfbf4 into 0b9fdfb0e
Pull Request #23177: Bump the gha-deps group across 1 directory with 4 updates

31687 of 60153 relevant lines covered (52.68%)

1.05 hits per line

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

97.56
/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
2✔
4
from pants.core.util_rules.external_tool import TemplatedExternalTool, download_external_tool
2✔
5
from pants.engine.console import Console
2✔
6
from pants.engine.fs import MergeDigests, PathGlobs, SpecsPaths
2✔
7
from pants.engine.goal import Goal, GoalSubsystem
2✔
8
from pants.engine.intrinsics import merge_digests, path_globs_to_digest
2✔
9
from pants.engine.platform import Platform
2✔
10
from pants.engine.process import Process, execute_process_or_raise
2✔
11
from pants.engine.rules import collect_rules, concurrently, goal_rule, implicitly
2✔
12
from pants.engine.unions import UnionRule
2✔
13
from pants.option.option_types import ArgsListOption
2✔
14
from pants.util.logging import LogLevel
2✔
15
from pants.util.strutil import pluralize
2✔
16

17

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

23
    default_version = "3.0.0"
2✔
24
    default_known_versions = [
2✔
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 = (
2✔
31
        "https://github.com/boyter/scc/releases/download/v{version}/scc-{version}-{platform}.zip"
32
    )
33
    default_url_platform_mapping = {
2✔
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(
2✔
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:
2✔
47
        return "./scc"
2✔
48

49

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

54

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

59

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

70
    specs_digest, scc_program = await concurrently(
2✔
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)))
2✔
75
    result = await execute_process_or_raise(
2✔
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())
2✔
86
    return CountLinesOfCode(exit_code=0)
2✔
87

88

89
def rules():
2✔
90
    return (*collect_rules(), UnionRule(ExportableTool, SuccinctCodeCounter))
2✔
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