prebid/Prebid.js

View on GitHub
modules/tcfControl.js

Summary

Maintainability
C
1 day
Test Coverage

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');

Severity: Minor
Found in modules/tcfControl.js - About 4 hrs to fix

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';
Severity: Minor
Found in modules/tcfControl.js - About 2 hrs to fix

    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');
      }
    Severity: Minor
    Found in modules/tcfControl.js - About 1 hr to fix

    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');
      }
    Severity: Minor
    Found in modules/tcfControl.js - About 1 hr to fix

      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');
      
      
      Severity: Minor
      Found in modules/tcfControl.js - About 1 hr to fix

        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) {
        Severity: Minor
        Found in modules/tcfControl.js - About 55 mins to fix

        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]})`);
                    }
        Severity: Major
        Found in modules/tcfControl.js - About 45 mins to fix

          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)) {
          Severity: Minor
          Found in modules/tcfControl.js - About 25 mins to fix

          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

          There are no issues that match your filters.

          Category
          Status