[pkgsite-metrics] internal/worker: addSource information to results

2 views
Skip to first unread message

Markus Kusano (Gerrit)

unread,
12:19 PM (10 hours ago) 12:19 PM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Markus Kusano has uploaded the change for review

Commit message

internal/worker: addSource information to results

This fixes 2 issues:

(1) Source information was not added if, e.g., the analyzer exited with
a non-zero exit code.

(2) Diagnostic URLs were not created for analysis runs not using
/tmp/modules to store code.
Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95

Change diff

diff --git a/internal/worker/analysis.go b/internal/worker/analysis.go
index ef78440..fa6cbf5 100644
--- a/internal/worker/analysis.go
+++ b/internal/worker/analysis.go
@@ -203,7 +203,10 @@
defer derrors.Cleanup(&err, func() error { return os.RemoveAll(modDir) })

jsonTree, err := s.scanInternal(ctx, req, localBinaryPath, modDir)
+ row.Diagnostics = analysis.JSONTreeToDiagnostics(jsonTree)
+ err = errors.Join(err, addSource(ctx, row.Diagnostics, 1))
if err != nil {
+ log.Warnf(ctx, "doScan or addSource failed: %v", err)
return err
}
hasGoMod = fileExists(filepath.Join(modDir, "go.mod")) // for precise error breakdown
@@ -213,8 +216,7 @@
}
row.Version = info.Version
row.CommitTime = info.Time
- row.Diagnostics = analysis.JSONTreeToDiagnostics(jsonTree)
- return addSource(ctx, row.Diagnostics, 1)
+ return nil
})
if err != nil {
// The errors are classified as to explicitly make a distinction
@@ -337,6 +339,14 @@
// position.
continue
}
+ if d.Position == "-" {
+ // Entries without a file position
+ continue
+ }
+ if strings.HasPrefix(d.Position, "/root/.cache/go-build/") {
+ // TODO: how do we read contents of go-build cache?
+ continue
+ }

file, line, _, err := parsePosition(d.Position)
if err != nil {
@@ -385,8 +395,7 @@
// sourceURL creates a URL showing the code corresponding to
// position pos and highlighting line.
func sourceURL(pos string, line int) (string, error) {
- // Trim /tmp/modules/ from the position string.
- relPos := strings.TrimPrefix(pos, modulesDir+"/")
+ relPos := strings.TrimPrefix(strings.TrimPrefix(pos, "/root/go/pkg/mod/"), modulesDir+"/")
if relPos == pos {
return "", errors.New("unexpected prefix")
}

Change information

Files:
  • M internal/worker/analysis.go
Change size: S
Delta: 1 file changed, 13 insertions(+), 4 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: pkgsite-metrics
Gerrit-Branch: master
Gerrit-Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95
Gerrit-Change-Number: 708377
Gerrit-PatchSet: 1
Gerrit-Owner: Markus Kusano <kus...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Markus Kusano (Gerrit)

unread,
12:28 PM (10 hours ago) 12:28 PM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Markus Kusano voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pkgsite-metrics
Gerrit-Branch: master
Gerrit-Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95
Gerrit-Change-Number: 708377
Gerrit-PatchSet: 1
Gerrit-Owner: Markus Kusano <kus...@google.com>
Gerrit-Reviewer: Markus Kusano <kus...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 16:28:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Markus Kusano (Gerrit)

unread,
12:51 PM (10 hours ago) 12:51 PM
to goph...@pubsubhelper.golang.org, Ethan Lee, Go LUCI, golang-co...@googlegroups.com
Attention needed from Ethan Lee

Markus Kusano voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Lee
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pkgsite-metrics
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95
    Gerrit-Change-Number: 708377
    Gerrit-PatchSet: 1
    Gerrit-Owner: Markus Kusano <kus...@google.com>
    Gerrit-Reviewer: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Markus Kusano <kus...@google.com>
    Gerrit-Attention: Ethan Lee <etha...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 16:51:32 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Ethan Lee (Gerrit)

    unread,
    2:14 PM (8 hours ago) 2:14 PM
    to Markus Kusano, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Markus Kusano

    Ethan Lee voted and added 1 comment

    Votes added by Ethan Lee

    Code-Review+2

    1 comment

    File internal/worker/analysis.go
    Line 347, Patchset 1 (Latest): // TODO: how do we read contents of go-build cache?
    Ethan Lee . unresolved

    nit: why would we want to do this?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Markus Kusano
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pkgsite-metrics
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95
    Gerrit-Change-Number: 708377
    Gerrit-PatchSet: 1
    Gerrit-Owner: Markus Kusano <kus...@google.com>
    Gerrit-Reviewer: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Markus Kusano <kus...@google.com>
    Gerrit-Attention: Markus Kusano <kus...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 18:14:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Markus Kusano (Gerrit)

    unread,
    2:15 PM (8 hours ago) 2:15 PM
    to goph...@pubsubhelper.golang.org, Ethan Lee, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Ethan Lee

    Markus Kusano voted and added 1 comment

    Votes added by Markus Kusano

    Commit-Queue+1

    1 comment

    File internal/worker/analysis.go
    Line 347, Patchset 1 (Latest): // TODO: how do we read contents of go-build cache?
    Ethan Lee . unresolved

    nit: why would we want to do this?

    Markus Kusano

    I'm not sure what these files are or what they represent

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ethan Lee
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pkgsite-metrics
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib273e3d3174bc6aaff1620bb8f9f0dd120a3df95
    Gerrit-Change-Number: 708377
    Gerrit-PatchSet: 1
    Gerrit-Owner: Markus Kusano <kus...@google.com>
    Gerrit-Reviewer: Ethan Lee <etha...@google.com>
    Gerrit-Reviewer: Markus Kusano <kus...@google.com>
    Gerrit-Attention: Ethan Lee <etha...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 18:15:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Ethan Lee <etha...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages