mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-04 03:52:31 +03:00
Not considering an issue as having activity if closed recently (#1531)
- The person who opened the issue can close it, so an issue closing does not indicate activity by a maintainer.
This commit is contained in:
parent
16c0d375d6
commit
7a6eb2812a
@ -83,16 +83,12 @@ func IsMaintained(c *checker.CheckRequest) checker.CheckResult {
|
||||
commitsWithinThreshold+issuesUpdatedWithinThreshold, activityPerWeek*lookBackDays/daysInOneWeek)
|
||||
}
|
||||
|
||||
// hasActivityByCollaboratorOrHigher returns true if there is activity by an owner/collaborator/member since the
|
||||
// threshold.
|
||||
// hasActivityByCollaboratorOrHigher returns true if the issue was created or commented on by an
|
||||
// owner/collaborator/member since the threshold.
|
||||
func hasActivityByCollaboratorOrHigher(issue *clients.Issue, threshold time.Time) bool {
|
||||
if issue == nil {
|
||||
return false
|
||||
}
|
||||
if issue.ClosedAt != nil && issue.ClosedAt.After(threshold) {
|
||||
// To close an issue, one must have sufficient permission in a repository, typically a collaborator or higher.
|
||||
return true
|
||||
}
|
||||
if isCollaboratorOrHigher(issue.AuthorAssociation) && issue.CreatedAt != nil && issue.CreatedAt.After(threshold) {
|
||||
// The creator of the issue is a collaborator or higher.
|
||||
return true
|
||||
|
@ -34,7 +34,6 @@ func TestMaintained(t *testing.T) {
|
||||
t.Parallel()
|
||||
threeHundredDaysAgo := time.Now().AddDate(0, 0, -300)
|
||||
twoHundredDaysAgo := time.Now().AddDate(0, 0, -200)
|
||||
oneHundredDaysAgo := time.Now().AddDate(0, 0, -100)
|
||||
fiveDaysAgo := time.Now().AddDate(0, 0, -5)
|
||||
oneDayAgo := time.Now().AddDate(0, 0, -1)
|
||||
ownerAssociation := clients.RepoAssociationOwner
|
||||
@ -262,46 +261,6 @@ func TestMaintained(t *testing.T) {
|
||||
Score: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "old issues closed long ago",
|
||||
isarchived: false,
|
||||
commits: []clients.Commit{},
|
||||
issues: []clients.Issue{
|
||||
{
|
||||
CreatedAt: &threeHundredDaysAgo,
|
||||
AuthorAssociation: &noneAssociation,
|
||||
ClosedAt: &twoHundredDaysAgo,
|
||||
},
|
||||
{
|
||||
CreatedAt: &twoHundredDaysAgo,
|
||||
AuthorAssociation: &noneAssociation,
|
||||
ClosedAt: &oneHundredDaysAgo,
|
||||
},
|
||||
},
|
||||
expected: checker.CheckResult{
|
||||
Score: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "new issues closed recently",
|
||||
isarchived: false,
|
||||
commits: []clients.Commit{},
|
||||
issues: []clients.Issue{
|
||||
{
|
||||
CreatedAt: &fiveDaysAgo,
|
||||
AuthorAssociation: &noneAssociation,
|
||||
ClosedAt: &oneDayAgo,
|
||||
},
|
||||
{
|
||||
CreatedAt: &oneDayAgo,
|
||||
AuthorAssociation: &noneAssociation,
|
||||
ClosedAt: &oneDayAgo,
|
||||
},
|
||||
},
|
||||
expected: checker.CheckResult{
|
||||
Score: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -90,7 +90,6 @@ type graphqlData struct {
|
||||
Url *string
|
||||
AuthorAssociation *string
|
||||
CreatedAt *time.Time
|
||||
ClosedAt *time.Time
|
||||
Comments struct {
|
||||
Nodes []struct {
|
||||
AuthorAssociation *string
|
||||
@ -230,7 +229,6 @@ func issuesFrom(data *graphqlData) []clients.Issue {
|
||||
copyStringPtr(issue.Url, &tmpIssue.URI)
|
||||
copyRepoAssociationPtr(getRepoAssociation(issue.AuthorAssociation), &tmpIssue.AuthorAssociation)
|
||||
copyTimePtr(issue.CreatedAt, &tmpIssue.CreatedAt)
|
||||
copyTimePtr(issue.ClosedAt, &tmpIssue.ClosedAt)
|
||||
for _, comment := range issue.Comments.Nodes {
|
||||
var tmpComment clients.IssueComment
|
||||
copyRepoAssociationPtr(getRepoAssociation(comment.AuthorAssociation), &tmpComment.AuthorAssociation)
|
||||
|
@ -20,7 +20,6 @@ import "time"
|
||||
type Issue struct {
|
||||
URI *string
|
||||
CreatedAt *time.Time
|
||||
ClosedAt *time.Time
|
||||
AuthorAssociation *RepoAssociation
|
||||
Comments []IssueComment
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user