Showing 145 of 325 total issues
Function isRuleSet
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function isRuleSet(input: unknown): input is Record<string, unknown> {
const ruleSet = input as Record<string, unknown>;
let ruleCount = 0;
if (input != null && typeof input === 'object' && !Array.isArray(input)) {
if (Object.prototype.hasOwnProperty.call(ruleSet, 'accept')) {
- 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 newCookieStorage
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function newCookieStorage(): AsyncCookieStorage {
let cache: Record<string, Cookie> = {};
function getOrInitCookie(name: string): Cookie {
if (!cache[name]) {
Function WebVitalsPlugin
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function WebVitalsPlugin(pluginOptions: WebVitalsPluginOptions = defaultPluginOptions): BrowserPlugin {
const webVitalsObject: Record<string, unknown> = {};
const options = { ...defaultPluginOptions, ...pluginOptions };
let trackerId: string;
let webVitalsScript: HTMLScriptElement | undefined;
Function logger
has 38 lines of code (exceeds 25 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 {
Function jsonInterceptor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function jsonInterceptor(encodeBase64: boolean): JsonProcessor {
const log = (jsonType: string, data: SelfDescribingJson) => {
const schemaParts = getSchemaParts(data['schema']);
debug(colours.event(), 'Event', [
'%c%s%c%s%c%s\n%o',
Function updateForThisEvent
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
updateForThisEvent(
eventType: MediaEventType,
player: MediaPlayer,
ad?: MediaAdUpdate,
adBreak?: MediaPlayerAdBreakUpdate
- 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 executeRequest
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function executeRequest(request: EmitterRequest): Promise<RequestResult> {
const fetchRequest = request.toRequest();
if (fetchRequest === undefined) {
throw new Error('Empty batch');
}
Function FocalMeterPlugin
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function FocalMeterPlugin(): BrowserPlugin {
let LOG: Logger;
let lastUserId: string | undefined | null;
let trackerId: string;
Function update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
update(
trackEvent: (event: EventWithContext) => void,
mediaEvent?: MediaEvent,
customEvent?: SelfDescribingJson,
player?: MediaPlayerUpdate,
Function FocalMeterPlugin
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function FocalMeterPlugin(): BrowserPlugin {
let LOG: Logger;
let lastUserId: string | undefined | null;
let trackerId: string;
- 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 payloadBuilder
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function payloadBuilder(): PayloadBuilder {
const dict: Payload = {},
allJson: EventJson = [],
jsonForProcessing: EventJson = [],
contextEntitiesForProcessing: SelfDescribingJson[] = [];
- 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 WebVitalsPlugin
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function WebVitalsPlugin(pluginOptions: WebVitalsPluginOptions = defaultPluginOptions): BrowserPlugin {
const webVitalsObject: Record<string, unknown> = {};
const options = { ...defaultPluginOptions, ...pluginOptions };
let trackerId: string;
let webVitalsScript: HTMLScriptElement | undefined;
- 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 newEmitterEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function newEmitterEvent(eventStorePayload: EventStorePayload): EmitterEvent {
let querystring: string | null = null;
let postBody: Record<string, unknown> | null = null;
let byteCountGET: number | null = null;
let byteCountPOST: number | null = 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"
Further reading
Function activateBrowserPlugin
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
activateBrowserPlugin: (tracker) => {
trackerId = tracker.id;
_trackers[trackerId] = tracker;
function sendWebVitals() {
Function continueFlush
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function continueFlush() {
await callIdService();
const request = newEmitterRequestWithConfig();
const eventStoreIterator = eventStore.iterator();
Function base64encode
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function base64encode(data: string): string {
// discuss at: http://phpjs.org/functions/base64_encode/
// original by: Tyler Akins (http://rumkin.com)
// improved by: Bayron Guevara
// improved by: Thunder.m
Function enableGeolocationContext
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function enableGeolocationContext(trackers: Array<string> = Object.keys(_trackers)) {
const navigatorAlias = navigator;
trackers.forEach((t) => {
//Mark as enabled
Function matchSchemaAgainstRuleSet
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function matchSchemaAgainstRuleSet(ruleSet: RuleSet, schema: string): boolean {
let rejectCount = 0;
let acceptCount = 0;
const acceptRules = ruleSet['accept'];
if (Array.isArray(acceptRules)) {
Function buildYouTubeEntity
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function buildYouTubeEntity(conf: TrackingOptions): SelfDescribingJson<YouTubeEntity> | null {
const { player, urlParameters = {} } = conf;
if (!player) return null;
Function DebuggerPlugin
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function DebuggerPlugin(logLevel: LOG_LEVEL = LOG_LEVEL.debug): BrowserPlugin {
let LOG: Logger;
let tracker: BrowserTracker;
let eventColour: string;
- 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"