-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpriority.js
43 lines (35 loc) · 1.09 KB
/
priority.js
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
import semver from "semver";
export function calculate_priority_score(dep) {
let priority_score = 0;
let priority_reasons = [];
// version change
let type_of_change = version_change(dep);
if (type_of_change == "major") {
priority_score += 10;
priority_reasons.push("MAJOR version change");
} else if (type_of_change == "minor") {
priority_score += 3;
priority_reasons.push("MINOR version change");
} else if (type_of_change == "patch") {
priority_score += 1;
priority_reasons.push("PATCH version change");
}
// RUSTSEC
if (dep.vulnerabilities) {
priority_score += 30;
priority_reasons.push("RUSTSEC vulnerability associated");
}
if (dep.warnings) {
priority_score += 20;
priority_reasons.push("RUSTSEC warning associated");
}
//
return { priority_score, priority_reasons };
}
export function version_change(dep) {
let version = dep.version;
let new_version = dep.update.versions[dep.update.versions.length - 1];
// rust has the tendency to lie when
let type_change = semver.diff(version, new_version);
return type_change;
}