Skip to content

Commit

Permalink
Bus factor change
Browse files Browse the repository at this point in the history
  • Loading branch information
fu351 committed Dec 14, 2023
1 parent 96447e7 commit 6a4d725
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
17 changes: 15 additions & 2 deletions metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.calculate_net_score = exports.calculate_dependencies = exports.calculate
//Metric 1
function calculate_bus_factor(contributor_commits) {
return __awaiter(this, void 0, void 0, function () {
var key_contributor, total_contributors, bus_factor_min, total_commits, i, avg, min_commit, i;
var key_contributor, total_contributors, bus_factor_min, total_commits, max, i, avg, min_commit, i;
return __generator(this, function (_a) {
if (!contributor_commits) {
return [2 /*return*/, 0];
Expand All @@ -55,12 +55,25 @@ function calculate_bus_factor(contributor_commits) {
bus_factor_min = total_contributors;
}
total_commits = 0;
max = 0;
//find average num of commits per contributor
for (i = 0; i < total_contributors; i++) {
total_commits += contributor_commits[i];
if (contributor_commits[i] > max) {
max = contributor_commits[i];
}
}
avg = total_commits / total_contributors;
min_commit = avg;
min_commit = 50;
if (max > 500) {
min_commit = 100;
}
if (max > 1000) {
min_commit = 300;
}
if (max > 5000) {
min_commit = avg;
}
//find key contributor
for (i = 0; i < total_contributors; i++) {
if (contributor_commits[i] >= min_commit) {
Expand Down
15 changes: 14 additions & 1 deletion metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ export async function calculate_bus_factor(contributor_commits: number[]) {
bus_factor_min = total_contributors;
}
let total_commits = 0;
let max = 0;
//find average num of commits per contributor
for (let i = 0; i < total_contributors; i++) {
total_commits += contributor_commits[i];
if (contributor_commits[i] > max) {
max = contributor_commits[i];
}
}

const avg = total_commits / total_contributors;
const min_commit = avg;
let min_commit = 50;
if (max > 500) {
min_commit = 100;
}
if (max > 1000) {
min_commit = 300;
}
if (max > 5000) {
min_commit = avg;
}
//find key contributor
for (let i = 0; i < total_contributors; i++) {
if (contributor_commits[i] >= min_commit) {
Expand Down

0 comments on commit 6a4d725

Please sign in to comment.