@@ -65,14 +65,6 @@ module.exports = async ({ github, context, core }) => {
65
65
username : username ,
66
66
per_page : 1
67
67
} ) ;
68
-
69
- console . log ( ">>> is_username_only_contribution_on_GH: " , {
70
- username : username ,
71
- events : events ,
72
- events_length : events . length ,
73
- result : events . length === 0 ,
74
- } ) ;
75
-
76
68
return events . length === 0 ;
77
69
} ) ( ) ;
78
70
const WasAuthorRecentlyCreated = ( ( ) => {
@@ -87,15 +79,28 @@ module.exports = async ({ github, context, core }) => {
87
79
} ) ( ) ;
88
80
89
81
const isTitleOrBodyTooShort = ( ( ) => {
82
+
83
+ if ( context . eventName === 'workflow_dispatch' ) // issues or pull_request
84
+ return false ;
85
+
90
86
const payload = context . payload ;
91
87
const title = payload . issue ?. title || payload . pull_request ?. title || "" ;
92
88
const body = payload . issue ?. body || payload . pull_request ?. body || "" ;
93
- return title . length < 20 || body . length < 20 ;
94
- } ) ( ) ;
95
89
96
- console . log ( ">>> DEBUG" , context )
90
+ const threshold = 20 ;
91
+ return title . length < threshold
92
+ || body . length < threshold ;
93
+ } ) ( ) ;
97
94
98
95
const checks = [
96
+ new Check ( {
97
+ predicate : ( ) => ! WasAuthorRecentlyCreated ,
98
+ reason : "Author account was recently created"
99
+ } ) ,
100
+ new Check ( {
101
+ predicate : ( ) => ! isAuthorOnlyContributionOnGH ,
102
+ reason : "Author first contribution to any GitHub project"
103
+ } ) ,
99
104
new Check ( {
100
105
predicate : ( ) => user . followers !== 0 && user . following !== 0 ,
101
106
reason : "Author has no relationships"
@@ -105,16 +110,15 @@ module.exports = async ({ github, context, core }) => {
105
110
reason : "Author has no public repo/gist"
106
111
} ) ,
107
112
new Check ( {
108
- predicate : ( ) => ! WasAuthorRecentlyCreated ,
109
- reason : "Account is less than an hour old"
110
- } ) ,
111
- new Check ( {
112
- predicate : ( ) => ! isAuthorOnlyContributionOnGH ,
113
- reason : "First contribution to any GitHub project"
113
+ predicate : ( ) => isTitleOrBodyTooShort ,
114
+ reason : "Issue/PR title or body too short"
114
115
} ) ,
115
116
] ;
116
117
117
- // IDEA: use weight instead of booleans
118
+ // IDEA: mandatory checks -> if any fails, then reject
119
+ // for other checks
120
+ // then use a weights/factors instead of booleans,
121
+ // compute a confidence score to check against a threshold => if below, then reject
118
122
const failed_checks = checks . filter ( check => ! check . pass ( ) ) ;
119
123
120
124
const threshold = 0 ;
0 commit comments