Showing 17 of 17 total issues
Function globFilesMatches
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
const globFilesMatches = (baseDir, filesPattern, excludedFolder = DEFAULT_EXCLUDED_FOLDER) => (
new Promise((resolve, reject) => {
if (!baseDir || !filesPattern) {
const error = new Error('baseDir and filePath are required');
return reject(error);
- 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 expressJSDocSwagger
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const expressJSDocSwagger = app => (userOptions = {}, userSwagger = {}) => {
const events = swaggerEvents(swaggerEventsOptions(userOptions));
const { instance } = events;
let swaggerObject = {};
Function parsePath
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const parsePath = (path, state) => {
if (!path.description || !path.tags) return {};
const [method, endpoint] = path.description.split(' ');
// if jsdoc comment does not contain structure <Method> - <Endpoint> is not valid path
const lowerCaseMethod = method.toLowerCase();
Function globFilesMatches
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
new Promise((resolve, reject) => {
if (!baseDir || !filesPattern) {
const error = new Error('baseDir and filePath are required');
return reject(error);
}
Function pathValues
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const pathValues = tags => {
const examplesValues = getTagsInfo(tags, 'example');
const examples = examplesGenerator(examplesValues);
const summary = getTagInfo(tags, 'summary');
Function refSchema
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const refSchema = value => {
// support * @return {array<Song|Album>} 200 - fetch Home Content response
if (value && value.type === 'UnionType') {
const items = [];
value.elements.forEach(el => {
- 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 parseSchema
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const parseSchema = (schema, options = {}) => {
const typedef = getTagInfo(schema.tags, 'typedef');
const propertyValues = getTagsInfo(schema.tags, 'property');
const requiredProperties = getRequiredProperties(propertyValues);
const [descriptionValue, enumValues, jsonOptions] = formatDescription(schema.description);
Function parseParameter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const parseParameter = param => {
const [name, inOption, ...extraOptions] = param.name.split('.');
if (!name || !inOption || inOption === FORM_TYPE) {
return defaultParseParameter;
}
Function formatProperties
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const formatProperties = (properties, options = {}) => {
if (!properties || !Array.isArray(properties)) return {};
return properties.reduce((acum, property) => {
const name = getPropertyName(property);
const isRequired = property.name.includes(REQUIRED);
Function formatProperties
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const formatProperties = (properties, options = {}) => {
if (!properties || !Array.isArray(properties)) return {};
return properties.reduce((acum, property) => {
const name = getPropertyName(property);
const isRequired = property.name.includes(REQUIRED);
- 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 getSchema
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const getSchema = (entity, message) => (type, enumValues = [], jsonOptions = {}) => {
if (!type) {
return errorMessage(`Entity: ${entity} could not be parsed. Value: "${message}" is wrong`);
}
const nameType = type.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
Function formatResponses
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const formatResponses = (values, examples) => values.reduce((acc, value) => {
const [status, description, contentType] = mapDescription(value.description);
if (!STATUS_CODES[status]) {
errorMessage(`Status ${status} is not valid to create a response`);
return {};
- 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 formatDescription
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const formatDescription = description => {
const descriptionTypes = mapDescription(description);
const descriptionValue = descriptionTypes.filter(value => (
!value.includes(ENUM_IDENTIFIER) && !value.includes(JSON_IDENTIFIER)
)).join(DESCRIPTION_DIVIDER);
- 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 combineSchema
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const combineSchema = elements => {
let schema = {};
if (!elements || elements.length === 0) return schema;
// Check if 'null' is part of the listed types and remove it from the array
- 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 too many return
statements within this function. Open
return isPrimitive ? { type: nameValue } : { $ref: `${REF_ROUTE}${nameValue}` };
Avoid too many return
statements within this function. Open
return resolve(filteredFiles);
Avoid too many return
statements within this function. Open
return reject(error);