Skip to content

Commit

Permalink
⚠️ Removing the pass field from result (#1853)
Browse files Browse the repository at this point in the history
    - Removing the pass field from result
    - #1393

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed May 2, 2022
1 parent 44ad5f5 commit 38ccb98
Show file tree
Hide file tree
Showing 23 changed files with 1 addition and 151 deletions.
14 changes: 0 additions & 14 deletions checker/check_result.go
Expand Up @@ -82,7 +82,6 @@ type CheckResult struct {
Name string
Details []string
Confidence int
Pass bool

// UPGRADEv2: New structure. Omitting unchanged Name field
// for simplicity.
Expand Down Expand Up @@ -153,15 +152,10 @@ func NormalizeReason(reason string, score int) string {
// the check runs without runtime errors and we want to assign a
// specific score.
func CreateResultWithScore(name, reason string, score int) CheckResult {
pass := true
if score < migrationThresholdPassValue {
pass = false
}
return CheckResult{
Name: name,
// Old structure.
Confidence: MaxResultScore,
Pass: pass,
// New structure.
Version: 2,
Error: nil,
Expand All @@ -176,16 +170,10 @@ func CreateResultWithScore(name, reason string, score int) CheckResult {
// multiple tests and we want to assign a score proportional
// the the number of tests that succeeded.
func CreateProportionalScoreResult(name, reason string, b, t int) CheckResult {
pass := true
score := CreateProportionalScore(b, t)
if score < migrationThresholdPassValue {
pass = false
}
return CheckResult{
Name: name,
// Old structure.
Confidence: MaxResultConfidence,
Pass: pass,
// New structure.
Version: 2,
Error: nil,
Expand Down Expand Up @@ -216,7 +204,6 @@ func CreateInconclusiveResult(name, reason string) CheckResult {
Name: name,
// Old structure.
Confidence: 0,
Pass: false,
// New structure.
Version: 2,
Score: InconclusiveResultScore,
Expand All @@ -230,7 +217,6 @@ func CreateRuntimeErrorResult(name string, e error) CheckResult {
Name: name,
// Old structure.
Confidence: 0,
Pass: false,
// New structure.
Version: 2,
Error: e,
Expand Down
5 changes: 0 additions & 5 deletions checks/binary_artifact_test.go
Expand Up @@ -42,7 +42,6 @@ func TestBinaryArtifacts(t *testing.T) {
err: nil,
expected: checker.CheckResult{
Score: 9,
Pass: true,
},
},
{
Expand All @@ -51,7 +50,6 @@ func TestBinaryArtifacts(t *testing.T) {
err: nil,
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
}
Expand Down Expand Up @@ -89,9 +87,6 @@ func TestBinaryArtifacts(t *testing.T) {
if result.Score != tt.expected.Score {
t.Errorf("BinaryArtifacts: %v, expected %v for tests %v", result.Score, tt.expected.Score, tt.name)
}
if result.Pass != tt.expected.Pass {
t.Errorf("BinaryArtifacts: %v, expected %v for tests %v", result.Pass, tt.expected.Pass, tt.name)
}

ctrl.Finish()
})
Expand Down
6 changes: 0 additions & 6 deletions checks/code_review_test.go
Expand Up @@ -88,7 +88,6 @@ func TestCodereview(t *testing.T) {
},
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
{
Expand All @@ -112,7 +111,6 @@ func TestCodereview(t *testing.T) {
},
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
{
Expand All @@ -136,7 +134,6 @@ func TestCodereview(t *testing.T) {
},
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
{
Expand Down Expand Up @@ -217,9 +214,6 @@ func TestCodereview(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
4 changes: 0 additions & 4 deletions checks/contributors_test.go
Expand Up @@ -134,7 +134,6 @@ func TestContributors(t *testing.T) {
},
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
{
Expand Down Expand Up @@ -185,9 +184,6 @@ func TestContributors(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
3 changes: 0 additions & 3 deletions checks/maintained_test.go
Expand Up @@ -355,9 +355,6 @@ func Test_Maintained(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
10 changes: 1 addition & 9 deletions checks/sast_test.go
Expand Up @@ -53,7 +53,7 @@ func TestSAST(t *testing.T) {
commits: []clients.Commit{},
searchresult: clients.SearchResponse{},
checkRuns: []clients.CheckRun{},
expected: checker.CheckResult{Score: -1, Pass: false},
expected: checker.CheckResult{Score: -1},
},
{
name: "Successful SAST checker should return success status",
Expand All @@ -76,7 +76,6 @@ func TestSAST(t *testing.T) {
},
expected: checker.CheckResult{
Score: 10,
Pass: true,
},
},
{
Expand Down Expand Up @@ -116,7 +115,6 @@ func TestSAST(t *testing.T) {
},
expected: checker.CheckResult{
Score: 7,
Pass: false,
},
},
{
Expand Down Expand Up @@ -153,7 +151,6 @@ func TestSAST(t *testing.T) {
},
expected: checker.CheckResult{
Score: 0,
Pass: false,
},
},
{
Expand All @@ -175,7 +172,6 @@ func TestSAST(t *testing.T) {
},
expected: checker.CheckResult{
Score: 0,
Pass: false,
},
},
{
Expand All @@ -198,7 +194,6 @@ func TestSAST(t *testing.T) {
},
expected: checker.CheckResult{
Score: 0,
Pass: false,
},
},
}
Expand Down Expand Up @@ -232,9 +227,6 @@ func TestSAST(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
15 changes: 0 additions & 15 deletions checks/signed_releases_test.go
Expand Up @@ -39,7 +39,6 @@ func TestSignedRelease(t *testing.T) {
{
name: "NoReleases",
expected: checker.CheckResult{
Pass: false,
Score: -1,
},
},
Expand All @@ -54,7 +53,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: false,
Score: -1,
},
},
Expand All @@ -74,7 +72,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: false,
Score: 0,
},
},
Expand All @@ -94,7 +91,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand All @@ -114,7 +110,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand All @@ -134,7 +129,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand All @@ -154,7 +148,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand All @@ -178,7 +171,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand Down Expand Up @@ -217,7 +209,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
Expand Down Expand Up @@ -252,7 +243,6 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: false,
Score: 5,
},
},
Expand Down Expand Up @@ -351,15 +341,13 @@ func TestSignedRelease(t *testing.T) {
},
},
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
},
{
name: "Error getting releases",
err: errors.New("Error getting releases"),
expected: checker.CheckResult{
Pass: false,
Score: -1,
Error: errors.New("Error getting releases"),
},
Expand Down Expand Up @@ -400,9 +388,6 @@ func TestSignedRelease(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
7 changes: 0 additions & 7 deletions checks/webhook_test.go
Expand Up @@ -40,7 +40,6 @@ func TestWebhooks(t *testing.T) {
name: "No Webhooks",
uri: "github.com/owner/repo",
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
err: nil,
Expand All @@ -50,7 +49,6 @@ func TestWebhooks(t *testing.T) {
name: "With Webhooks and secret set",
uri: "github.com/owner/repo",
expected: checker.CheckResult{
Pass: true,
Score: 10,
},
err: nil,
Expand All @@ -65,7 +63,6 @@ func TestWebhooks(t *testing.T) {
name: "With Webhooks and no secret set",
uri: "github.com/owner/repo",
expected: checker.CheckResult{
Pass: false,
Score: 0,
},
err: nil,
Expand All @@ -80,7 +77,6 @@ func TestWebhooks(t *testing.T) {
name: "With 2 Webhooks with and whitout secrets configured",
uri: "github.com/owner/repo",
expected: checker.CheckResult{
Pass: false,
Score: 5,
},
err: nil,
Expand Down Expand Up @@ -133,9 +129,6 @@ func TestWebhooks(t *testing.T) {
if res.Score != tt.expected.Score {
t.Errorf("Expected score %d, got %d for %v", tt.expected.Score, res.Score, tt.name)
}
if res.Pass != tt.expected.Pass {
t.Errorf("Expected pass %t, got %t for %v", tt.expected.Pass, res.Pass, tt.name)
}
ctrl.Finish()
})
}
Expand Down
1 change: 0 additions & 1 deletion cron/format/json.go
Expand Up @@ -97,7 +97,6 @@ func AsJSON(r *pkg.ScorecardResult, showDetails bool, logLevel log.Level, writer
for _, checkResult := range r.Checks {
tmpResult := jsonCheckResult{
Name: checkResult.Name,
Pass: checkResult.Pass,
Confidence: checkResult.Confidence,
}
if showDetails {
Expand Down
4 changes: 0 additions & 4 deletions e2e/binary_artifacts_test.go
Expand Up @@ -86,7 +86,6 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() {
result := checks.BinaryArtifacts(&req)
// UPGRADEv2: to remove.
// Old version.
Expect(result.Pass).Should(BeFalse())
// New version.
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
Expect(repoClient.Close()).Should(BeNil())
Expand Down Expand Up @@ -114,9 +113,6 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() {
NumberOfDebug: 0,
}
result := checks.BinaryArtifacts(&req)
// UPGRADEv2: to remove.
// Old version.
Expect(result.Pass).Should(BeFalse())
// New version.
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
Expect(repoClient.Close()).Should(BeNil())
Expand Down

0 comments on commit 38ccb98

Please sign in to comment.