airbnb/superset

View on GitHub
superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts

Summary

Maintainability
C
7 hrs
Test Coverage

Function getClientErrorObject has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getClientErrorObject(
  response:
    | SupersetClientResponse
    | TimeoutError
    | { response: Response }

    Function parseErrorJson has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    export function parseErrorJson(responseJson: JsonObject): ClientErrorObject {
      let error = { ...responseJson };
      // Backwards compatibility for old error renderers with the new error object
      if (error.errors && error.errors.length > 0) {
        error.error = error.description = error.errors[0].message;

    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 parseErrorJson has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function parseErrorJson(responseJson: JsonObject): ClientErrorObject {
      let error = { ...responseJson };
      // Backwards compatibility for old error renderers with the new error object
      if (error.errors && error.errors.length > 0) {
        error.error = error.description = error.errors[0].message;

      Function parseStringResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parseStringResponse(str: string): string {
        if (checkForHtml(str)) {
          for (const [code, message] of Object.entries(ERROR_CODE_LOOKUP)) {
            const regex = new RegExp(`${code}|${message}`, 'i');
            if (regex.test(str)) {

      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