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

pantsbuild / pants / 24637157883

19 Apr 2026 07:23PM UTC coverage: 52.377% (-40.5%) from 92.924%
24637157883

Pull #23274

github

web-flow
Merge b54f275c2 into 0283af69e
Pull Request #23274: rust: upgrade to v1.95.0

31658 of 60443 relevant lines covered (52.38%)

1.05 hits per line

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

0.0
/src/python/pants/backend/go/lint/vet/rules.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
×
5

6
import os.path
×
7
from dataclasses import dataclass
×
8
from typing import Any
×
9

10
from pants.backend.go.lint.vet.skip_field import SkipGoVetField
×
11
from pants.backend.go.lint.vet.subsystem import GoVetSubsystem
×
12
from pants.backend.go.target_types import GoPackageSourcesField
×
13
from pants.backend.go.util_rules.go_mod import (
×
14
    GoModInfoRequest,
15
    OwningGoModRequest,
16
    determine_go_mod_info,
17
    find_owning_go_mod,
18
)
19
from pants.backend.go.util_rules.sdk import GoSdkProcess
×
20
from pants.core.goals.lint import LintResult, LintTargetsRequest
×
21
from pants.core.util_rules.partitions import PartitionerType
×
22
from pants.core.util_rules.source_files import SourceFilesRequest, determine_source_files
×
23
from pants.engine.fs import MergeDigests
×
24
from pants.engine.internals.selectors import concurrently
×
25
from pants.engine.intrinsics import execute_process, merge_digests
×
26
from pants.engine.rules import collect_rules, implicitly, rule
×
27
from pants.engine.target import FieldSet, Target
×
28
from pants.util.logging import LogLevel
×
29
from pants.util.strutil import pluralize
×
30

31

32
@dataclass(frozen=True)
×
33
class GoVetFieldSet(FieldSet):
×
34
    required_fields = (GoPackageSourcesField,)
×
35

36
    sources: GoPackageSourcesField
×
37

38
    @classmethod
×
39
    def opt_out(cls, tgt: Target) -> bool:
×
40
        return tgt.get(SkipGoVetField).value
×
41

42

43
class GoVetRequest(LintTargetsRequest):
×
44
    field_set_type = GoVetFieldSet
×
45
    tool_subsystem = GoVetSubsystem  # type: ignore[assignment]
×
46
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
47

48

49
@rule(level=LogLevel.DEBUG)
×
50
async def run_go_vet(request: GoVetRequest.Batch[GoVetFieldSet, Any]) -> LintResult:
×
51
    source_files = await determine_source_files(
×
52
        SourceFilesRequest(field_set.sources for field_set in request.elements)
53
    )
54

55
    owning_go_mods = await concurrently(
×
56
        find_owning_go_mod(OwningGoModRequest(field_set.address), **implicitly())
57
        for field_set in request.elements
58
    )
59
    owning_go_mod_addresses = {x.address for x in owning_go_mods}
×
60
    go_mod_infos = await concurrently(
×
61
        determine_go_mod_info(GoModInfoRequest(address)) for address in owning_go_mod_addresses
62
    )
63

64
    input_digest = await merge_digests(
×
65
        MergeDigests([source_files.snapshot.digest, *(info.digest for info in set(go_mod_infos))])
66
    )
67
    package_dirs = sorted({os.path.dirname(f) for f in source_files.snapshot.files})
×
68
    process_result = await execute_process(
×
69
        **implicitly(
70
            GoSdkProcess(
71
                ("vet", *(f"./{p}" for p in package_dirs)),
72
                input_digest=input_digest,
73
                description=f"Run `go vet` on {pluralize(len(source_files.snapshot.files), 'file')}.",
74
            )
75
        )
76
    )
77
    return LintResult.create(request, process_result)
×
78

79

80
def rules():
×
81
    return (
×
82
        *collect_rules(),
83
        *GoVetRequest.rules(),
84
    )
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