Function generate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
static generate(schemaResponse, preferredExampleName) {
if((typeof schemaResponse.example !== 'undefined' && !schemaResponse['x-faker']) ||
(schemaResponse.examples && Object.values(schemaResponse.examples).length)) {
const bestExample = this.getBestExample(schemaResponse, preferredExampleName);
Function generateBySchema
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
static generateBySchema(schemaResponse) {
const fakerExtension = schemaResponse['x-faker'];
if(fakerExtension) {
try {
Function sendResponse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
sendResponse(req, res, body, statusCode, headers, responseMimeType = '') {
statusCode = statusCode || 200;
headers = headers || {};
Function validateRequestBody
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
validateRequestBody(requestBody) {
if(!this.requestBody)
return [];
Function load
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
load(schemaPath) {
this.schemaPath = path.isAbsolute(schemaPath) ? schemaPath : path.join(process.cwd(), schemaPath);
try {