newExternalGitLabCodeQualityIssue returns an externalGitLabCodeQualityIssue for the specified FileAnnotation.
(f FileAnnotation)
| 369 | // newExternalGitLabCodeQualityIssue returns an externalGitLabCodeQualityIssue for the |
| 370 | // specified FileAnnotation. |
| 371 | func 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 | |
| 409 | func printEachAnnotationOnNewLine( |
| 410 | writer io.Writer, |
no test coverage detected
searching dependent graphs…