packages/js-sdk/src/http/response.ts
Function error
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
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;
- 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 error
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Consider simplifying this complex logical expression. Open
Open
} else if (name === 'EntityNotFound'
|| name === 'CollectionNotFound'
|| name === 'AppNotFound'
|| name === 'UserNotFound'
|| name === 'BlobNotFound'
Avoid too many return
statements within this function. Open
Open
return new InvalidQuerySyntaxError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new KinveyInternalErrorRetry(message, debug);
Avoid too many return
statements within this function. Open
Open
return new MissingConfigurationError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new WritesToCollectionDisallowedError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new InsufficientCredentialsError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new ServerError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new InvalidCredentialsError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new InsufficientCredentialsError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new IndirectCollectionAccessDisallowedError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new KinveyInternalErrorStop(message, debug);
Avoid too many return
statements within this function. Open
Open
return new IncompleteRequestBodyError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new ResultSetSizeExceededError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new InvalidIdentifierError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new UserAlreadyExistsError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new MissingRequestHeaderError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new NotFoundError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new JSONParseError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new BadRequestError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new CORSDisabledError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new NotFoundError(message, debug);
Avoid too many return
statements within this function. Open
Open
return null;
Avoid too many return
statements within this function. Open
Open
return new FeatureUnavailableError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new MissingQueryError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new StaleRequestError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new BLError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new MissingRequestParameterError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new ServerError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new DuplicateEndUsersError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new KinveyError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new ParameterValueOutOfRangeError(message, debug);
Avoid too many return
statements within this function. Open
Open
return new KinveyError();
Function constructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
constructor(config: HttpResponseConfig) {
this.statusCode = config.statusCode;
this.headers = new HttpHeaders(config.headers);
const contentType = this.headers.get('Content-Type') || '';
- 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"