teableio/teable

View on GitHub
packages/openapi/src/openapi-snippet/openapi-to-har.js

Summary

Maintainability
F
3 days
Test Coverage

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:
Severity: Minor
Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 6 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

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/
Severity: Minor
Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 6 hrs to fix

    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';
      }
    
    
    Severity: Minor
    Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 4 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 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) {
    Severity: Minor
    Found in packages/openapi/src/openapi-snippet/openapi-to-har.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 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 (
    Severity: Minor
    Found in packages/openapi/src/openapi-snippet/openapi-to-har.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 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}}`;
    Severity: Minor
    Found in packages/openapi/src/openapi-snippet/openapi-to-har.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

    Avoid deeply nested control flow statements.
    Open

              switch (authScheme) {
                case 'bearer':
                  oauthDef = secScheme;
                  break;
                case 'basic':
    Severity: Major
    Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if (typeof sample[key] !== 'string') {
                        value = JSON.stringify(sample[key]);
                      }
      Severity: Major
      Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (sample === undefined) return null;
        Severity: Major
        Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (secDefinition.in === 'header') {
                      apiKeyAuthDef = secDefinition;
                    }
          Severity: Major
          Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 45 mins to fix

            Function getParameterCollectionIn has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            const getParameterCollectionIn = function (openApi, path, method, location, values) {
            Severity: Minor
            Found in packages/openapi/src/openapi-snippet/openapi-to-har.js - About 35 mins to fix

              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;
              
              
              Severity: Minor
              Found in packages/openapi/src/openapi-snippet/openapi-to-har.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

              There are no issues that match your filters.

              Category
              Status