aboutsummaryrefslogtreecommitdiffstats
path: root/Metrics/Metrics-Calculation/RealisticRunner/queries/github.vql
blob: eda5f0f1ed427e61f8687856de8a9b0a9bdf5e97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package queries
import epackage "sure.ghtorrent.github"

pattern directParent(a : Commit, b: Commit) {
	Commit.parents(a,b);
}

@Constraint(key={a}, severity="error", message="error")
pattern loopInParent(a: Commit){
 find directParent+(a,a);
}

pattern checkAction(i: Issue, e: IssueEvent, t: Action) {
	Issue.issueevent(i, e);
	IssueEvent.action(e, a);
	a == t;
}

pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
	Issue.issueevent(i, e);
	IssueEvent.user(e, u);
	IssueEvent.action(e, a);
	a == t;
}

pattern isReopen(i: Issue, e: IssueEvent) {
	Issue.issueevent(i, e);
	IssueEvent.action(e, a);
	a == Action::REOPENED;
}

pattern isClose(i: Issue, e: IssueEvent) {
	Issue.issueevent(i, e);
	IssueEvent.action(e, a);
	a == Action::CLOSED;
}

pattern isUnSubscribe(i: Issue, u: User, e: IssueEvent) {
	Issue.issueevent(i, e);
	IssueEvent.user(e, u);
	IssueEvent.action(e, a);
	a == Action::UNSUBSCRIBED;
}

pattern isSubscribe(i: Issue, u: User, e: IssueEvent) {
	Issue.issueevent(i, e);
	IssueEvent.user(e, u);
	IssueEvent.action(e, a);
	a == Action::SUBSCRIBED;
}


pattern pullRequestOfIssue(i: Issue, pr: PullRequest) {
	Issue.pullrequest(i, pr);
}

//@Constraint(key={i}, severity="error", message="error")
//pattern mergedIssueWithoutPr(i: Issue){
//	find checkAction(i, _, Action::MERGED);
//	neg find pullRequestOfIssue(i, _);
//}

@Constraint(key={i}, severity="error", message="error")
pattern consecutiveClosesWithoutReopen(i: Issue) {
	find checkAction(i, a1, Action::CLOSED);
	find checkAction(i, a2, Action::CLOSED);
	a1 != a2;
	neg find isReopen(i, _);
}


@Constraint(key={i}, severity="error", message="error")
pattern consecutiveReopensWithoutClose(i: Issue) {
	find checkAction(i, a1, Action::REOPENED);
	find checkAction(i, a2, Action::REOPENED);
	a1 != a2;
	neg find isClose(i, _);
}

//@Constraint(key={i, u}, severity="error", message="error")
//pattern consecutiveSubWithoutUnSub(i: Issue, u: User) {
//	find checkUserAction(i, u, a1, Action::SUBSCRIBED);
//	find checkUserAction(i, u, a2, Action::SUBSCRIBED);
//	a1 != a2;
//	neg find isUnSubscribe(i, u, _);
//}

@Constraint(key={i, u}, severity="error", message="error")
pattern consecutiveUnSubWithoutSub(i: Issue, u: User) {
	find checkUserAction(i, u, a1, Action::UNSUBSCRIBED);
	find checkUserAction(i, u, a2, Action::UNSUBSCRIBED);
	a1 != a2;
	neg find isSubscribe(i, u, _);
}

//pattern committer(c: Commit, u:User) {
//	Commit.committer(c, u);
//}
//
//pattern eventUser(e: IssueEvent, u:User){
//	IssueEvent.user(e, u);
//}
//
//@Constraint(key={c}, severity="error", message="error")
//pattern noCommitter(c: Commit) {
//	neg find committer(c, _);
//}
//
//@Constraint(key={e}, severity="error", message="error")
//pattern noUser(e: IssueEvent) {
//	neg find eventUser(e, _);
//}



//1. issue with MERGED but no PullRequest
//2. issue with 2 CLOSED events without a REOPENED event
//3. issue with 2 REOPENED events without a CLOSED event
//4. user-issue pair with 2 SUBSCRIBED events without an UNSUBSCRIBED event
//5. user-issue pair with 2 UNSUBSCRIBED events without a SUBSCRIBED event
//6. User MERGED/CLOSED/REOPENED issue without being a projectMember of the Project (Not possible under this condition)