prebid/Prebid.js

View on GitHub
src/storageManager.js

Summary

Maintainability
D
1 day
Test Coverage

Function newStorageManager has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
Open

export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = isActivityAllowed} = {}) {
  function isValid(cb, storageType) {
    let mod = moduleName;
    const curBidder = config.getCurrentBidder();
    if (curBidder && moduleType === MODULE_TYPE_BIDDER && adapterManager.aliasRegistry[curBidder] === moduleName) {
Severity: Minor
Found in src/storageManager.js - About 1 day 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 setCookie has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  const setCookie = function (key, value, expires, sameSite, domain, done) {
Severity: Minor
Found in src/storageManager.js - About 45 mins to fix

    Function getStorageManager has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getStorageManager({moduleType, moduleName, bidderCode} = {}) {
      function err() {
        throw new Error(`Invalid invocation for getStorageManager: must set either bidderCode, or moduleType + moduleName`)
      }
      if (bidderCode) {
    Severity: Minor
    Found in src/storageManager.js - About 35 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

    Function storageAllowedRule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export function storageAllowedRule(params, bs = bidderSettings) {
      if (params[ACTIVITY_PARAM_COMPONENT_TYPE] !== MODULE_TYPE_BIDDER) return;
      let allow = bs.get(params[ACTIVITY_PARAM_ADAPTER_CODE], 'storageAllowed');
      if (!allow || allow === true) {
        allow = !!allow
    Severity: Minor
    Found in src/storageManager.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