Kinvey/js-sdk

View on GitHub
packages/js-sdk/src/http/response.ts

Summary

Maintainability
F
3 days
Test Coverage

Function error has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

  get error() {
    if (!this.isSuccess()) {
      if (isPlainObject(this.data)) {
        const message = this.data.message || this.data.description;
        const name = this.data.name || this.data.error;
Severity: Minor
Found in packages/js-sdk/src/http/response.ts - About 5 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 error has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  get error() {
    if (!this.isSuccess()) {
      if (isPlainObject(this.data)) {
        const message = this.data.message || this.data.description;
        const name = this.data.name || this.data.error;
Severity: Major
Found in packages/js-sdk/src/http/response.ts - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            } else if (name === 'EntityNotFound'
              || name === 'CollectionNotFound'
              || name === 'AppNotFound'
              || name === 'UserNotFound'
              || name === 'BlobNotFound'
    Severity: Major
    Found in packages/js-sdk/src/http/response.ts - About 40 mins to fix

      Avoid too many return statements within this function.
      Open

                return new InvalidQuerySyntaxError(message, debug);
      Severity: Major
      Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return new KinveyInternalErrorRetry(message, debug);
        Severity: Major
        Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return new MissingConfigurationError(message, debug);
          Severity: Major
          Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return new WritesToCollectionDisallowedError(message, debug);
            Severity: Major
            Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                        return new InsufficientCredentialsError(message, debug);
              Severity: Major
              Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return new ServerError(message, debug);
                Severity: Major
                Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return new InvalidCredentialsError(message, debug);
                  Severity: Major
                  Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return new InsufficientCredentialsError(message, debug);
                    Severity: Major
                    Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                return new IndirectCollectionAccessDisallowedError(message, debug);
                      Severity: Major
                      Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                  return new KinveyInternalErrorStop(message, debug);
                        Severity: Major
                        Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                    return new IncompleteRequestBodyError(message, debug);
                          Severity: Major
                          Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                      return new ResultSetSizeExceededError(message, debug);
                            Severity: Major
                            Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                        return new InvalidIdentifierError(message, debug);
                              Severity: Major
                              Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                          return new UserAlreadyExistsError(message, debug);
                                Severity: Major
                                Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                            return new MissingRequestHeaderError(message, debug);
                                  Severity: Major
                                  Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                              return new NotFoundError(message, debug);
                                    Severity: Major
                                    Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                return new JSONParseError(message, debug);
                                      Severity: Major
                                      Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                  return new BadRequestError(message, debug);
                                        Severity: Major
                                        Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                    return new CORSDisabledError(message, debug);
                                          Severity: Major
                                          Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                      return new NotFoundError(message, debug);
                                            Severity: Major
                                            Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return null;
                                              Severity: Major
                                              Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                          return new FeatureUnavailableError(message, debug);
                                                Severity: Major
                                                Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                            return new MissingQueryError(message, debug);
                                                  Severity: Major
                                                  Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                              return new StaleRequestError(message, debug);
                                                    Severity: Major
                                                    Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                return new BLError(message, debug);
                                                      Severity: Major
                                                      Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                  return new MissingRequestParameterError(message, debug);
                                                        Severity: Major
                                                        Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                    return new ServerError(message, debug);
                                                          Severity: Major
                                                          Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                      return new DuplicateEndUsersError(message, debug);
                                                            Severity: Major
                                                            Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                      return new KinveyError(message, debug);
                                                              Severity: Major
                                                              Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                          return new ParameterValueOutOfRangeError(message, debug);
                                                                Severity: Major
                                                                Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                        return new KinveyError();
                                                                  Severity: Major
                                                                  Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix

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

                                                                      constructor(config: HttpResponseConfig) {
                                                                        this.statusCode = config.statusCode;
                                                                        this.headers = new HttpHeaders(config.headers);
                                                                    
                                                                        const contentType = this.headers.get('Content-Type') || '';
                                                                    Severity: Minor
                                                                    Found in packages/js-sdk/src/http/response.ts - About 25 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