File Request.js
has 618 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Created by AlexanderC on 6/10/15.
*/
'use strict';
Request
has 59 functions (exceeds 20 allowed). Consider refactoring. Open
export class Request {
/**
* @param {Action} action
* @param {Object} payload
* @param {String} method
Function _createAws4SignedRequest
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createAws4SignedRequest(url, httpMethod, payload, headers, callback) {
let parsedUrl = urlParse(url, qs);
let apiHost = parsedUrl.hostname;
let apiPath = parsedUrl.pathname ? parsedUrl.pathname : '/';
Function _send
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
_send(callback = () => {}) {
let logService = this.action.resource.log;
let requestEvent = {
service: 'deep-resource',
resourceType: 'Browser',
Function _send
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_send(callback = () => {}) {
let logService = this.action.resource.log;
let requestEvent = {
service: 'deep-resource',
resourceType: 'Browser',
- 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 _sendThroughApi
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_sendThroughApi(callback = () => {}) {
let endpoint = this.action.source.api;
let headers = {};
let sendRequestFunc = (request) => {
Function _loadResponseFromCache
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_loadResponseFromCache(driver, key, callback) {
driver.has(key, (err, has) => {
if(err) {
callback(new CachedRequestException(`Error to check if has in cache key ${key}`));
return;
Function _createAws4SignedRequest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_createAws4SignedRequest(url, httpMethod, payload, headers, callback) {
let parsedUrl = urlParse(url, qs);
let apiHost = parsedUrl.hostname;
let apiPath = parsedUrl.pathname ? parsedUrl.pathname : '/';
- 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 _saveResponseToCache
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_saveResponseToCache(response, callback = () => {}) {
if (!this.isCached || this.async || (this.cacheTtl === Request.TTL_INVALIDATE) || response.isError) {
callback(null, response);
return;
}
Function _loadSecurityCredentials
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_loadSecurityCredentials(callback) {
let securityService = this._action.resource.security;
if (!securityService) {
callback(new MissingSecurityServiceException(), null);
- 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"