Function getHeadersArray
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
const getHeadersArray = function (openApi, path, method) {
const headers = [];
const pathObj = openApi.paths[path][method];
// 'accept' header:
- Read upRead up
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
File openapi-to-har.js
has 470 lines of code (exceeds 300 allowed). Consider refactoring. Open
/* eslint-disable */
/**
* Translates given OpenAPI document to an array of HTTP Archive (HAR) 1.2 Request Object.
* See more:
* - http://swagger.io/specification/
Function createHarParameterObjects
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
const createHarParameterObjects = function ({ name, in: location, style, explode }, value) {
if (!name || !location || typeof value === 'undefined') {
throw 'Required parameters missing';
}
- Read upRead up
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 parseParametersToQuery
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const parseParametersToQuery = function (openApi, parameters, location, values) {
/** @type {Object.<string, HarParameterObject[]>} */
const queryStrings = {};
for (let i in parameters) {
- Read upRead up
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 getPayloads
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const getPayloads = function (openApi, path, method) {
if (typeof openApi.paths[path][method].parameters !== 'undefined') {
for (let i in openApi.paths[path][method].parameters) {
const param = openApi.paths[path][method].parameters[i];
if (
- Read upRead up
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 getParameterValues
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const getParameterValues = function (openApi, param, location, values) {
let value = 'SOME_' + (param.type || param.schema.type || param.schema.anyOf[0].type).toUpperCase() + '_VALUE';
if (location === 'path') {
// then default to the original place holder value (e.b. '{id}')
value = `{${param.name}}`;
- Read upRead up
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
Avoid deeply nested control flow statements. Open
switch (authScheme) {
case 'bearer':
oauthDef = secScheme;
break;
case 'basic':
Avoid deeply nested control flow statements. Open
if (typeof sample[key] !== 'string') {
value = JSON.stringify(sample[key]);
}
Avoid deeply nested control flow statements. Open
if (sample === undefined) return null;
Avoid deeply nested control flow statements. Open
if (secDefinition.in === 'header') {
apiKeyAuthDef = secDefinition;
}
Function getParameterCollectionIn
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
const getParameterCollectionIn = function (openApi, path, method, location, values) {
Function getBaseUrl
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const getBaseUrl = function (openApi, path, method) {
if (openApi.paths[path][method].servers) return openApi.paths[path][method].servers[0].url;
if (openApi.paths[path].servers) return openApi.paths[path].servers[0].url;
if (openApi.servers) return openApi.servers[0].url;
- Read upRead up
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"