-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdevAnalysis.py
54 lines (45 loc) · 1.62 KB
/
devAnalysis.py
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
import os
import csv
from configuration import Configuration
def devAnalysis(
authorInfoDict: set, batchIdx: int, devs: set, coreDevs: set, config: Configuration
):
# select experienced developers
experiencedDevs = [
login
for login, author in authorInfoDict.items()
if author["experienced"] == True
]
# filter by developers present in list of aliased developers by commit
numberActiveExperiencedDevs = len(devs.intersection(set(experiencedDevs)))
# calculate bus factor
busFactor = (len(devs) - len(coreDevs)) / len(devs)
# calculate TFC
commitCount = sum(
[author["commitCount"] for login, author in authorInfoDict.items()]
)
sponsoredCommitCount = sum(
[
author["commitCount"]
for login, author in authorInfoDict.items()
if author["sponsored"] == True
]
)
experiencedCommitCount = sum(
[
author["commitCount"]
for login, author in authorInfoDict.items()
if author["experienced"] == True
]
)
sponsoredTFC = sponsoredCommitCount / commitCount * 100
experiencedTFC = experiencedCommitCount / commitCount * 100
print("Writing developer analysis results")
with open(
os.path.join(config.resultsPath, f"results_{batchIdx}.csv"), "a", newline=""
) as f:
w = csv.writer(f, delimiter=",")
w.writerow(["NumberActiveExperiencedDevs", numberActiveExperiencedDevs])
w.writerow(["BusFactorNumber", busFactor])
w.writerow(["SponsoredTFC", sponsoredTFC])
w.writerow(["ExperiencedTFC", experiencedTFC])