Showing 153 of 352 total issues
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 gotEmitter
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
endpoint: string,
protocol: HttpProtocol = HttpProtocol.HTTPS,
port?: number,
method?: HttpMethod,
bufferSize?: number,
Function _run
has a Cognitive Complexity of 11 (exceeds 5 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);
- 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 _resolvePackageVersion
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function _resolvePackageVersion(logger, rushCommonFolder, { name, version }) {
if (!version) {
version = '*'; // If no version is specified, use the latest version
}
if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) {
- 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 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 _copyAndTrimNpmrcFile
has 29 lines of code (exceeds 25 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());
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 getHTMLMediaElementEntities
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getHTMLMediaElementEntities(el: HTMLAudioElement | HTMLVideoElement, conf: TrackingOptions): MediaEntities {
// In cases where the media does not have explicit id, we use the container id passed from the configuration.
const htmlId = el.id || conf.id;
const data: MediaElement = {
htmlId,
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 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"
Further reading
Function validateVendorParts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function validateVendorParts(parts: Array<string>): boolean {
if (parts[0] === '*' || parts[1] === '*') {
return false; // no wildcard in first or second part
}
if (parts.slice(2).length > 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 toSessionContextEntity
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
toSessionContextEntity(): MediaSessionStats {
return {
timePaused: this.pausedDuration > 0 ? this.round(this.pausedDuration) : undefined,
timePlayed: this.playbackDuration > 0 ? this.round(this.playbackDuration) : undefined,
timePlayedMuted: this.playbackDurationMuted > 0 ? this.round(this.playbackDurationMuted) : 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 updateAdStats
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private updateAdStats(log: Log) {
// only works with ad event types
if (log.eventType === undefined) {
return;
}
- 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 createCrossDomainParameterValue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function createCrossDomainParameterValue(
isExtendedFormat: boolean,
attributeConfiguration: ExtendedCrossDomainLinkerAttributes | undefined,
attributeValues: ExtendedCrossDomainLinkerValues & {
/* As `reason` might be a callback, we also need to pass the event to calculate the reason value. */
- 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 updateDurationStats
has 27 lines of code (exceeds 25 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) {
Function getInnerFormElements
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getInnerFormElements(trackingMarker: string, elt: HTMLFormElement) {
var innerElements: Array<ElementDataWrapper> = [];
Array.prototype.slice.call(innerElementTags).forEach((tagname: 'textarea' | 'input' | 'select') => {
let trackedChildren = Array.prototype.slice.call(elt.getElementsByTagName(tagname)).filter(function (child) {
return child.hasOwnProperty(trackingMarker);
Function getOptimizelyVisitorContexts
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getOptimizelyVisitorContexts() {
var visitor = getOptimizelyData('visitor');
if (visitor) {
var context: Visitor = {};
context.browser = visitor.browser;