Showing 153 of 352 total issues
Function enqueueRequest
has 39 lines of code (exceeds 25 allowed). Consider refactoring. 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 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 flush
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const flush = (): void => {
const bufferCopy = buffer;
buffer = [];
if (bufferCopy.length === 0) {
return;
Function trackingOptionsParser
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function trackingOptionsParser(id: string, trackingOptions?: MediaTrackingOptions): TrackingOptions {
const defaults: TrackingOptions = {
id: id,
captureEvents: DefaultEvents,
progress: {
Function setXhrCallbacks
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setXhrCallbacks(xhr: XMLHttpRequest, numberToSend: number, batch: EventBatch) {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
clearTimeout(xhrTimeout);
if (isSuccessfulRequest(xhr.status)) {
Function globalContexts
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function globalContexts(): GlobalContexts {
let globalPrimitives: Array<ContextPrimitive> = [];
let conditionalProviders: Array<ConditionalContextProvider> = [];
/**
- 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 findMediaElementChild
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function findMediaElementChild(el: Element): SearchResult {
for (let tag of Object.keys(TAG)) {
let elem = el.getElementsByTagName(tag);
if (elem.length === 1) {
if (isAudioElement(elem[0])) return { el: elem[0] };
- 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 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 getYouTubeEntities
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getYouTubeEntities(player: YT.Player, urlParameters: UrlParameters, eventData?: EventData): MediaEntities {
const spherical: YT.SphericalProperties = player.getSphericalProperties();
const playerStates: Record<number, boolean> = {
[YT.PlayerState.BUFFERING]: false,
[YT.PlayerState.CUED]: false,
Function getOptimizelyStateContexts
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getOptimizelyStateContexts() {
var experimentIds = [];
var experiments = getOptimizelyData('experiments');
if (experiments) {
for (var key in experiments) {
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,
Consider simplifying this complex logical expression. Open
if (
plugins.optimizely &&
(optimizelySummary ||
optimizelyExperiments ||
optimizelyStates ||
Function processClick
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processClick(tracker: BrowserTracker, sourceElement: Element, context?: DynamicContext | null) {
let parentElement, tag, elementId, elementClasses, elementTarget, elementContent;
while (
(parentElement = sourceElement.parentElement) !== null &&
Function _run
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _run() {
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
// Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
// appropriate binary inside the rush package to run
const scriptName = path.basename(scriptPath);
Function track
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function track(
pb: PayloadBuilder,
context?: Array<SelfDescribingJson> | null,
timestamp?: Timestamp | null
): Payload {
Function enableMediaTracking
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function enableMediaTracking(args: { id: string; options?: MediaTrackingOptions }) {
const conf: TrackingOptions = trackingOptionsParser(args.id, args.options);
// Some events have additional effects/need to perform checks before running mediaPlayerEvent
const eventsWithOtherFunctions: Record<string, Function> = {
Function enableMediaTracking
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function enableMediaTracking(args: { id: string; options?: MediaTrackingOptions }) {
const conf: TrackingOptions = trackingOptionsParser(args.id, args.options);
// Some events have additional effects/need to perform checks before running mediaPlayerEvent
const eventsWithOtherFunctions: Record<string, Function> = {
- 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"