MCPcopy Create free account
hub / github.com/bufbuild/buf / newExternalGitLabCodeQualityIssue

Function newExternalGitLabCodeQualityIssue

private/bufpkg/bufanalysis/print.go:371–407  ·  view source on GitHub ↗

newExternalGitLabCodeQualityIssue returns an externalGitLabCodeQualityIssue for the specified FileAnnotation.

(f FileAnnotation)

Source from the content-addressed store, hash-verified

369// newExternalGitLabCodeQualityIssue returns an externalGitLabCodeQualityIssue for the
370// specified FileAnnotation.
371func newExternalGitLabCodeQualityIssue(f FileAnnotation) (*externalGitLabCodeQualityIssue, error) {
372 path := ""
373 if f.FileInfo() != nil {
374 // GitLab Code Quality Issues strictly require the path to be a relative path based on
375 // the repository. This will need to be enforced by the user.
376 path = f.FileInfo().ExternalPath()
377 }
378 gitLabCodeQualityIssue := externalGitLabCodeQualityIssue{
379 Description: f.Message(),
380 CheckName: f.Type(),
381 Location: externalGitLabCodeQualityIssueLocation{
382 Path: path,
383 Positions: externalGitLabCodeQualityIssueLocationPositions{
384 Begin: externalGitLabCodeQualityIssueLocationPosition{
385 Line: f.StartLine(),
386 Column: f.StartColumn(),
387 },
388 End: externalGitLabCodeQualityIssueLocationPosition{
389 Line: f.EndLine(),
390 Column: f.EndColumn(),
391 },
392 },
393 },
394 Severity: "minor",
395 }
396 gitLabCodeQualityIssueContent, err := json.Marshal(gitLabCodeQualityIssue)
397 if err != nil {
398 return nil, err
399 }
400 // We use the hash of the GitLab Code Quality issues content, minus the hash itself.
401 hash, err := shake256.NewDigestForContent(bytes.NewReader(gitLabCodeQualityIssueContent))
402 if err != nil {
403 return nil, err
404 }
405 gitLabCodeQualityIssue.Fingerprint = hex.EncodeToString(hash.Value())
406 return &gitLabCodeQualityIssue, nil
407}
408
409func printEachAnnotationOnNewLine(
410 writer io.Writer,

Callers 1

printAsGitLabCodeQualityFunction · 0.85

Calls 11

NewDigestForContentFunction · 0.92
FileInfoMethod · 0.65
ExternalPathMethod · 0.65
MessageMethod · 0.65
TypeMethod · 0.65
StartLineMethod · 0.65
StartColumnMethod · 0.65
EndLineMethod · 0.65
EndColumnMethod · 0.65
MarshalMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…