Showing 153 of 352 total issues
Function executeQueue
has 105 lines of code (exceeds 25 allowed). Consider refactoring. 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 trackerCore
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
export function trackerCore(configuration: CoreConfiguration = {}): TrackerCore {
function newCore(base64: boolean, corePlugins: Array<CorePlugin>, callback?: (PayloadData: PayloadBuilder) => void) {
const pluginContextsHelper: PluginContexts = pluginContexts(corePlugins),
globalContextsHelper: GlobalContexts = globalContexts();
- 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 gotEmitter
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export function gotEmitter(
endpoint: string,
protocol: HttpProtocol = HttpProtocol.HTTPS,
port?: number,
method?: HttpMethod,
- 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 BrowserFeaturesPlugin
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
export function BrowserFeaturesPlugin(): BrowserPlugin {
return {
activateBrowserPlugin: (tracker: BrowserTracker) => {
const navigatorAlias = navigator;
// General plugin detection
- 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 DebuggerPlugin
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function DebuggerPlugin(logLevel: LOG_LEVEL = LOG_LEVEL.debug): BrowserPlugin {
let LOG: Logger;
let tracker: BrowserTracker;
let eventColour: string;
Function addPlugin
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addPlugin(parameterArray: Array<unknown>, trackerIdentifiers: Array<string>) {
function postScriptHandler(scriptSrc: string) {
if (Object.prototype.hasOwnProperty.call(pendingPlugins, scriptSrc)) {
windowAlias.clearTimeout(pendingPlugins[scriptSrc].timeout);
delete pendingPlugins[scriptSrc];
Function gotEmitter
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function gotEmitter(
endpoint: string,
protocol: HttpProtocol = HttpProtocol.HTTPS,
port?: number,
method?: HttpMethod,
Function updateDurationStats
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private updateDurationStats(log: Log) {
// if ad was playing until now and it was a linear ad, don't add the duration stats
let wasPlayingAd = this.lastAdUpdateAt !== undefined;
const shouldCountStats = (!wasPlayingAd || !log.linearAd) ?? true;
if (!shouldCountStats) {
- 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 logger
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function logger(logLevel: LOG_LEVEL = LOG_LEVEL.warn): Logger {
function setLogLevel(level: LOG_LEVEL) {
if (LOG_LEVEL[level]) {
logLevel = level;
} else {
- 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 getBrowserDataPlugin
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getBrowserDataPlugin() {
const anonymizeOr = (value?: string | number | null) => (configAnonymousTracking ? null : value);
const anonymizeSessionOr = (value?: string | number | null) =>
configAnonymousSessionTracking ? value : anonymizeOr(value);
Function OutQueueManager
has 20 arguments (exceeds 4 allowed). Consider refactoring. Open
id: string,
sharedSate: SharedState,
useLocalStorage: boolean,
eventMethod: string | boolean,
postPath: string,
File index.ts
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright (c) 2022 Snowplow Analytics Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Function _copyAndTrimNpmrcFile
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
logger.info(` --> "${targetNpmrcPath}"`);
let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
- 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 trackingOptionsParser
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
export function trackingOptionsParser(id: string | YT.Player, conf?: MediaTrackingOptions): TrackingOptions {
const player = typeof id === 'string' ? undefined : id;
const elementId = typeof id === 'string' ? id : id.getIframe().id;
const defaultBoundaries = [10, 25, 50, 75];
const defaultUpdateRate = 500;
- 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 beforeTrack
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
beforeTrack: (payloadBuilder: PayloadBuilder) => {
const existingSession = getSnowplowCookieValue('ses'),
idCookie = loadDomainUserIdCookie();
const isFirstEventInSession = eventIndexFromIdCookie(idCookie) === 0;
Function GaCookiesPlugin
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function GaCookiesPlugin(pluginOptions: GACookiesPluginOptions = defaultPluginOptions): BrowserPlugin {
return {
contexts: () => {
const contexts: SelfDescribingJson<Record<string, unknown>>[] = [];
const { ga4, ga4MeasurementId, ua, cookiePrefix } = { ...defaultPluginOptions, ...pluginOptions };
Function createSharedState
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export function createSharedState(): SharedState {
const sharedState = new SharedState(),
documentAlias = document,
windowAlias = window;
- 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 payloadJsonProcessor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function payloadJsonProcessor(encodeBase64: boolean): JsonProcessor {
return (
payloadBuilder: PayloadBuilder,
jsonForProcessing: EventJson,
contextEntitiesForProcessing: SelfDescribingJson[]
Function constructNavigationTimingContext
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function constructNavigationTimingContext(
performanceNavigationTimingInstance: PerformanceNavigationTimingContext
) {
const performanceNavigationKeys = [
'entryType',
Function contexts
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
contexts: () => {
const contexts: SelfDescribingJson<Record<string, unknown>>[] = [];
const { ga4, ga4MeasurementId, ua, cookiePrefix } = { ...defaultPluginOptions, ...pluginOptions };
const GA_USER_COOKIE = '_ga';
const GA4_MEASUREMENT_ID_PREFIX = 'G-';