libraries/browser-tracker-core/src/tracker/out_queue.ts
Function OutQueueManager
has a Cognitive Complexity of 193 (exceeds 5 allowed). Consider refactoring. Open
Open
export function OutQueueManager(
id: string,
sharedSate: SharedState,
useLocalStorage: boolean,
eventMethod: string | boolean,
- 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 OutQueueManager
has 408 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function OutQueueManager(
id: string,
sharedSate: SharedState,
useLocalStorage: boolean,
eventMethod: string | boolean,
File out_queue.ts
has 445 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { attemptWriteLocalStorage, isString } from '../helpers';
import { SharedState } from '../state';
import { localStorageAccessible } from '../detectors';
import { LOG, Payload } from '@snowplow/tracker-core';
import { PAYLOAD_DATA_SCHEMA } from './schemata';
Function executeQueue
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function executeQueue(sync: boolean = false) {
// Failsafe in case there is some way for a bad value like "null" to end up in the outQueue
while (outQueue.length && typeof outQueue[0] !== 'string' && typeof outQueue[0] !== 'object') {
outQueue.shift();
}
Function OutQueueManager
has 20 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
id: string,
sharedSate: SharedState,
useLocalStorage: boolean,
eventMethod: string | boolean,
postPath: string,
Function enqueueRequest
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function enqueueRequest(request: Payload, url: string) {
configCollectorUrl = url + path;
const eventTooBigWarning = (bytes: number, maxBytes: number) =>
LOG.warn('Event (' + bytes + 'B) too big, max is ' + maxBytes);
Function setXhrCallbacks
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function setXhrCallbacks(xhr: XMLHttpRequest, numberToSend: number, batch: EventBatch) {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
clearTimeout(xhrTimeout);
if (isSuccessfulRequest(xhr.status)) {