jormaechea/open-api-mocker

View on GitHub

Showing 7 of 7 total issues

Function generate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

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);
Severity: Minor
Found in lib/response-generator/index.js - About 55 mins to fix

Function generateBySchema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

static generateBySchema(schemaResponse) {
 
const fakerExtension = schemaResponse['x-faker'];
if(fakerExtension) {
try {
Severity: Minor
Found in lib/response-generator/index.js - About 45 mins to fix

Function sendResponse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

sendResponse(req, res, body, statusCode, headers, responseMimeType = '') {
 
statusCode = statusCode || 200;
headers = headers || {};
 
 
Severity: Minor
Found in lib/mocker/express/server.js - About 35 mins to fix

Function validateRequestBody has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

validateRequestBody(requestBody) {
 
if(!this.requestBody)
return [];
 
 
Severity: Minor
Found in lib/paths/path.js - About 35 mins to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

constructor({
schemas,
responses,
parameters,
examples,
Severity: Minor
Found in lib/components/components.js and 1 other location - About 35 mins to fix
lib/components/parser.js on lines 43..53

Identical blocks of code found in 2 locations. Consider refactoring.
Open

return new Components({
schemas,
responses,
parameters,
examples,
Severity: Minor
Found in lib/components/parser.js and 1 other location - About 35 mins to fix
lib/components/components.js on lines 5..15

Function load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

load(schemaPath) {
 
this.schemaPath = path.isAbsolute(schemaPath) ? schemaPath : path.join(process.cwd(), schemaPath);
 
try {
Severity: Minor
Found in lib/schema-loaders/local-loader.js - About 25 mins to fix
Severity
Category
Status
Source
Language