jormaechea/open-api-mocker

View on GitHub

Showing 5 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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language