BRIKEV/express-jsdoc-swagger

View on GitHub

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);
Severity: Minor
Found in consumers/globFilesMatches.js - About 2 hrs 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 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 = {};

Severity: Minor
Found in index.js - About 1 hr to fix

    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();
    Severity: Minor
    Found in transforms/paths/index.js - About 1 hr to fix

      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);
          }
      Severity: Minor
      Found in consumers/globFilesMatches.js - About 1 hr to fix

        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');
        Severity: Minor
        Found in transforms/paths/index.js - About 1 hr to fix

          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 => {
          Severity: Minor
          Found in transforms/utils/refSchema.js - About 1 hr 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 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);
          Severity: Minor
          Found in transforms/components/index.js - About 1 hr to fix

            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;
              }
            Severity: Minor
            Found in transforms/paths/parameters.js - About 1 hr to fix

              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);
              Severity: Minor
              Found in transforms/components/index.js - About 1 hr to fix

                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);
                Severity: Minor
                Found in transforms/components/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 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;
                Severity: Minor
                Found in transforms/paths/schema.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 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 {};
                Severity: Minor
                Found in transforms/paths/responses.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 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);
                Severity: Minor
                Found in transforms/utils/formatDescription.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 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
                Severity: Minor
                Found in transforms/utils/combineSchema.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

                Avoid too many return statements within this function.
                Open

                  return isPrimitive ? { type: nameValue } : { $ref: `${REF_ROUTE}${nameValue}` };
                Severity: Major
                Found in transforms/utils/refSchema.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return resolve(filteredFiles);
                  Severity: Major
                  Found in consumers/globFilesMatches.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return reject(error);
                    Severity: Major
                    Found in consumers/globFilesMatches.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language