Take in account abnormalityScore to calculate category score

This commit is contained in:
Gaël Métais
2014-12-22 23:11:25 +01:00
parent c994638168
commit c8ba9ef99a
3 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -31,8 +31,8 @@
"jQueryVersion": {
"label": "jQuery version",
"policies": {
"jQueryVersion": 1,
"jQueryDifferentVersions": 5
"jQueryVersion": 5,
"jQueryDifferentVersions": 0.1
}
},
"cssSyntaxError": {
+3 -2
View File
@@ -28,7 +28,8 @@ var ScoreCalculator = function() {
weight = profile.categories[categoryName].policies[policyName];
if (data.rules[policyName]) {
sum += data.rules[policyName].score * weight;
var policyScore = data.rules[policyName].score + data.rules[policyName].abnormalityScore;
sum += policyScore * weight;
} else {
// Max value if rule is not here
sum += 100 * weight;
@@ -42,7 +43,7 @@ var ScoreCalculator = function() {
if (totalWeight === 0) {
categoryResult.categoryScore = 100;
} else {
categoryResult.categoryScore = Math.round(sum / totalWeight);
categoryResult.categoryScore = Math.round(Math.max(sum, 0) / totalWeight);
}
categoryResult.rules = rules;
+3 -3
View File
@@ -1,9 +1,9 @@
{
"globalScore": 69,
"globalScore": 57,
"categories": {
"category1": {
"label": "Category 1",
"categoryScore": 87,
"categoryScore": 83,
"rules": [
"metric1",
"metric2",
@@ -13,7 +13,7 @@
},
"category2": {
"label": "Category 2",
"categoryScore": 31,
"categoryScore": 0,
"rules": [
"metric5",
"metric6",