Showing 145 of 325 total issues
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 globalContexts
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function globalContexts(): GlobalContexts {
let globalPrimitives: Array<ContextPrimitive> = [];
let conditionalProviders: Array<ConditionalContextProvider> = [];
let namedPrimitives: Record<string, ContextPrimitive> = {};
let namedConditionalProviders: Record<string, ConditionalContextProvider> = {};
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 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 compareProvider
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function compareProvider(
a: ConditionalContextProvider | ContextPrimitive,
b: ConditionalContextProvider | ContextPrimitive
): boolean {
if (isConditionalContextProvider(a)) {
- 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);
File index.ts
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { EventStore, newInMemoryEventStore } from '../event_store';
import { Payload } from '../payload';
import { EmitterRequest, newEmitterRequest } from './emitter_request';
import { EmitterEvent, newEmitterEvent } from './emitter_event';
import { newEventStorePayload } from '../event_store_payload';
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 waitForElement
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export function waitForElement(config: StringConfig, callback: (element: ElementConfig) => void) {
const { el, err } = findMediaElement(config.video);
if (err) {
LOG.info(`${err}. Waiting for element to be added to the DOM.`);
}
- 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 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 newCookie
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function newCookie(name: string): Cookie {
let flushTimer: ReturnType<typeof setTimeout> | undefined;
let lastSetValueArgs: Parameters<typeof setValue> | undefined;
let cacheExpireAt: Date | undefined;
let flushed = true;
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-';
File api.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
File index.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Function parseIdCookie
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseIdCookie(
id: string | undefined,
domainUserId: string,
memorizedSessionId: string,
memorizedVisitCount: number
Function createSharedState
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createSharedState(): SharedState {
const sharedState = new SharedState(),
documentAlias = document,
windowAlias = window;