Function getGvlid
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
export function getGvlid(moduleType, moduleName, fallbackFn) {
if (moduleName) {
// Check user defined GVL Mapping in pbjs.setConfig()
const gvlMapping = config.getConfig('gvlMapping');
- 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
File tcfControl.js
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* This module gives publishers extra set of features to enforce individual purposes of TCF v2
*/
import {deepAccess, logError, logWarn} from '../src/utils.js';
Function setEnforcementConfig
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function setEnforcementConfig(config) {
let rules = deepAccess(config, 'gdpr.rules');
if (!rules) {
logWarn('TCF2: enforcing P1 and P2 by default');
}
- 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 setEnforcementConfig
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setEnforcementConfig(config) {
let rules = deepAccess(config, 'gdpr.rules');
if (!rules) {
logWarn('TCF2: enforcing P1 and P2 by default');
}
Function getGvlid
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getGvlid(moduleType, moduleName, fallbackFn) {
if (moduleName) {
// Check user defined GVL Mapping in pbjs.setConfig()
const gvlMapping = config.getConfig('gvlMapping');
Function transmitEidsRule
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const transmitEidsRule = exceptPrebidModules((() => {
// Transmit EID special case:
// by default, legal basis or vendor exceptions for any purpose between 2 and 10
// (but disregarding enforcePurpose and enforceVendor config) is enough to allow EIDs through
function check2to10Consent(consentData, modName, gvlId) {
- 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
Avoid deeply nested control flow statements. Open
if (modules.hasOwnProperty(type)) {
gvlid = modules[type];
if (type !== moduleType) {
logWarn(`Multiple GVL IDs found for module '${moduleName}'; using the ${type} module's ID (${gvlid}) instead of the ${moduleType}'s ID (${modules[moduleType]})`);
}
Function validateRules
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function validateRules(rule, consentData, currentModule, gvlId) {
const ruleOptions = CONFIGURABLE_RULES[rule.purpose];
// return 'true' if vendor present in 'vendorExceptions'
if ((rule.vendorExceptions || []).includes(currentModule)) {
- 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"