@keptn/pitometer-grader-threshold
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -20,2 +20,3 @@ /** | ||
setOptions(options: pitometer.IOptions): void; | ||
getContext(): string; | ||
private evaluate; | ||
@@ -22,0 +23,0 @@ grade(id: string, results: pitometer.ISourceResult[], { thresholds, metricScore, ignoreEmpty }: { |
@@ -22,18 +22,6 @@ "use strict"; | ||
} | ||
getContext() { | ||
return this.context; | ||
} | ||
evaluate(result, { thresholds, metricScore, ignoreEmpty }) { | ||
if ((typeof (result) === 'boolean') || !result.value) { | ||
if (ignoreEmpty) { | ||
return false; | ||
} | ||
return { | ||
score: 0, | ||
violations: [ | ||
{ | ||
key: typeof (result) === 'boolean' ? '' : result.key, | ||
value: false, | ||
breach: 'The indicator returned no value for the current key', | ||
}, | ||
], | ||
}; | ||
} | ||
let score = metricScore; | ||
@@ -84,9 +72,2 @@ const violations = []; | ||
grade(id, results, { thresholds, metricScore, ignoreEmpty }) { | ||
if (!results) { | ||
return { | ||
id, | ||
score: 0, | ||
violations: [{ breach: 'The indicator returned no values' }], | ||
}; | ||
} | ||
const grades = []; | ||
@@ -96,4 +77,2 @@ const violations = []; | ||
const grade = this.evaluate(result, { thresholds, metricScore, ignoreEmpty }); | ||
if (grade === false) | ||
return false; | ||
violations.push(...grade.violations); | ||
@@ -110,5 +89,17 @@ grades.push({ | ||
return (!acc || elm.score < acc.score) ? elm : acc; | ||
return acc; | ||
// tslint:disable-next-line: align | ||
}, null); | ||
return { id, violations, score: reduced ? reduced.score : metricScore }; | ||
let score = 0; | ||
if (reduced) { | ||
score = reduced.score; | ||
} | ||
else if (ignoreEmpty) { | ||
score = metricScore; | ||
} | ||
else { | ||
violations.push({ | ||
breach: 'The indicator returned no values', | ||
}); | ||
} | ||
return { id, violations, score }; | ||
} | ||
@@ -115,0 +106,0 @@ } |
{ | ||
"name": "@keptn/pitometer-grader-threshold", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -9,3 +9,3 @@ "main": "./dist/index.js", | ||
"build": "npx tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Testing...\" && nyc --reporter=text nyc mocha && nyc report" | ||
}, | ||
@@ -16,8 +16,36 @@ "keywords": [], | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^11.13.2", | ||
"chai": "^4.2.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1", | ||
"pitometer": "file:../pitometer", | ||
"source-map-support": "^0.5.12", | ||
"ts-node": "^8.1.0", | ||
"tslint": "^5.15.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"typescript": "^3.4.2" | ||
}, | ||
"nyc": { | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"src/server.ts", | ||
"src/**/*.spec.ts" | ||
], | ||
"extension": [ | ||
".ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
], | ||
"reporter": [ | ||
"html", | ||
"cobertura" | ||
], | ||
"sourceMap": true, | ||
"instrument": true | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
92531
34
755
1
12
0
1