mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-11 08:55:27 +03:00
Fix lint issues: goerr113 linter (#491)
Co-authored-by: Azeem Shaikh <azeemshaikh38@gmail.com>
This commit is contained in:
parent
0c636b0f5f
commit
2e7a71fbf2
@ -23,7 +23,7 @@ linters:
|
|||||||
- gocyclo
|
- gocyclo
|
||||||
- godot
|
- godot
|
||||||
- godox
|
- godox
|
||||||
# - goerr113
|
- goerr113
|
||||||
- gofmt
|
- gofmt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- goheader
|
- goheader
|
||||||
|
@ -18,6 +18,8 @@ import "errors"
|
|||||||
|
|
||||||
const MaxResultConfidence = 10
|
const MaxResultConfidence = 10
|
||||||
|
|
||||||
|
var ErrorDemoninatorZero = errors.New("internal error: denominator is 0")
|
||||||
|
|
||||||
type CheckResult struct {
|
type CheckResult struct {
|
||||||
Error error `json:"-"`
|
Error error `json:"-"`
|
||||||
Name string
|
Name string
|
||||||
@ -65,7 +67,7 @@ func MakeRetryResult(name string, err error) CheckResult {
|
|||||||
func MakeProportionalResult(name string, numerator int, denominator int,
|
func MakeProportionalResult(name string, numerator int, denominator int,
|
||||||
threshold float32) CheckResult {
|
threshold float32) CheckResult {
|
||||||
if denominator == 0 {
|
if denominator == 0 {
|
||||||
return MakeInconclusiveResult(name, errors.New("internal error: denominator is 0"))
|
return MakeInconclusiveResult(name, ErrorDemoninatorZero)
|
||||||
}
|
}
|
||||||
if numerator == 0 {
|
if numerator == 0 {
|
||||||
return CheckResult{
|
return CheckResult{
|
||||||
|
@ -24,6 +24,8 @@ import (
|
|||||||
|
|
||||||
const codeReviewStr = "Code-Review"
|
const codeReviewStr = "Code-Review"
|
||||||
|
|
||||||
|
var ErrorNoReviews = errors.New("no reviews found")
|
||||||
|
|
||||||
//nolint:gochecknoinits
|
//nolint:gochecknoinits
|
||||||
func init() {
|
func init() {
|
||||||
registerCheck(codeReviewStr, DoesCodeReview)
|
registerCheck(codeReviewStr, DoesCodeReview)
|
||||||
@ -147,7 +149,7 @@ func ProwCodeReview(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if totalReviewed == 0 {
|
if totalReviewed == 0 {
|
||||||
return checker.MakeInconclusiveResult(codeReviewStr, errors.New("no reviews found"))
|
return checker.MakeInconclusiveResult(codeReviewStr, ErrorNoReviews)
|
||||||
}
|
}
|
||||||
c.Logf("prow code reviews found")
|
c.Logf("prow code reviews found")
|
||||||
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, totalMerged, .75)
|
||||||
@ -187,7 +189,7 @@ func CommitMessageHints(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if totalReviewed == 0 {
|
if totalReviewed == 0 {
|
||||||
return checker.MakeInconclusiveResult(codeReviewStr, errors.New("no reviews found"))
|
return checker.MakeInconclusiveResult(codeReviewStr, ErrorNoReviews)
|
||||||
}
|
}
|
||||||
c.Logf("code reviews found")
|
c.Logf("code reviews found")
|
||||||
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, total, .75)
|
return checker.MakeProportionalResult(codeReviewStr, totalReviewed, total, .75)
|
||||||
|
@ -23,7 +23,11 @@ import (
|
|||||||
|
|
||||||
const sastStr = "SAST"
|
const sastStr = "SAST"
|
||||||
|
|
||||||
var sastTools map[string]bool = map[string]bool{"github-code-scanning": true, "sonarcloud": true}
|
var (
|
||||||
|
sastTools map[string]bool = map[string]bool{"github-code-scanning": true, "sonarcloud": true}
|
||||||
|
ErrorNoChecks = errors.New("no check runs found")
|
||||||
|
ErrorNoMerges = errors.New("no merges found")
|
||||||
|
)
|
||||||
|
|
||||||
//nolint:gochecknoinits
|
//nolint:gochecknoinits
|
||||||
func init() {
|
func init() {
|
||||||
@ -58,7 +62,7 @@ func SASTToolInCheckRuns(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
return checker.MakeRetryResult(sastStr, err)
|
return checker.MakeRetryResult(sastStr, err)
|
||||||
}
|
}
|
||||||
if crs == nil {
|
if crs == nil {
|
||||||
return checker.MakeInconclusiveResult(sastStr, errors.New("no check runs found"))
|
return checker.MakeInconclusiveResult(sastStr, ErrorNoChecks)
|
||||||
}
|
}
|
||||||
for _, cr := range crs.CheckRuns {
|
for _, cr := range crs.CheckRuns {
|
||||||
if cr.GetStatus() != "completed" {
|
if cr.GetStatus() != "completed" {
|
||||||
@ -75,7 +79,7 @@ func SASTToolInCheckRuns(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if totalTested == 0 {
|
if totalTested == 0 {
|
||||||
return checker.MakeInconclusiveResult(sastStr, errors.New("no merges found"))
|
return checker.MakeInconclusiveResult(sastStr, ErrorNoMerges)
|
||||||
}
|
}
|
||||||
return checker.MakeProportionalResult(sastStr, totalTested, totalMerged, .75)
|
return checker.MakeProportionalResult(sastStr, totalTested, totalMerged, .75)
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ const (
|
|||||||
releaseLookBackDays = 5
|
releaseLookBackDays = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrorNoReleases = errors.New("no releases found")
|
||||||
|
|
||||||
//nolint:gochecknoinits
|
//nolint:gochecknoinits
|
||||||
func init() {
|
func init() {
|
||||||
registerCheck(signedReleasesStr, SignedReleases)
|
registerCheck(signedReleasesStr, SignedReleases)
|
||||||
@ -76,7 +78,7 @@ func SignedReleases(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
|
|
||||||
if totalReleases == 0 {
|
if totalReleases == 0 {
|
||||||
c.Logf("no releases found")
|
c.Logf("no releases found")
|
||||||
return checker.MakeInconclusiveResult(signedReleasesStr, errors.New("no releases found"))
|
return checker.MakeInconclusiveResult(signedReleasesStr, ErrorNoReleases)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Logf("found signed artifacts for %d out of %d releases", totalSigned, totalReleases)
|
c.Logf("found signed artifacts for %d out of %d releases", totalSigned, totalReleases)
|
||||||
|
@ -26,6 +26,8 @@ const (
|
|||||||
tagLookBack = 5
|
tagLookBack = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrorNoTags = errors.New("no signed tags found")
|
||||||
|
|
||||||
//nolint:gochecknoinits
|
//nolint:gochecknoinits
|
||||||
func init() {
|
func init() {
|
||||||
registerCheck(signedTagsStr, SignedTags)
|
registerCheck(signedTagsStr, SignedTags)
|
||||||
@ -75,7 +77,7 @@ func SignedTags(c *checker.CheckRequest) checker.CheckResult {
|
|||||||
|
|
||||||
if totalTags == 0 {
|
if totalTags == 0 {
|
||||||
c.Logf("no tags found")
|
c.Logf("no tags found")
|
||||||
return checker.MakeInconclusiveResult(signedTagsStr, errors.New("no signed tags found"))
|
return checker.MakeInconclusiveResult(signedTagsStr, ErrorNoTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Logf("found %d out of %d verified tags", totalSigned, totalTags)
|
c.Logf("found %d out of %d verified tags", totalSigned, totalTags)
|
||||||
|
Loading…
Reference in New Issue
Block a user