prebid/Prebid.js

View on GitHub
modules/xeBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

Function buildRequests has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function buildRequests(validBidRequests, bidderRequest) {
  const { refererInfo = {}, gdprConsent = {}, uspConsent } = bidderRequest;
  const requests = validBidRequests.map(req => {
    const request = {};
    request.bidId = req.bidId;
Severity: Major
Found in modules/xeBidAdapter.js - About 2 hrs to fix

    Function requests has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const requests = validBidRequests.map(req => {
        const request = {};
        request.bidId = req.bidId;
        request.banner = deepAccess(req, 'mediaTypes.banner');
        // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
    Severity: Major
    Found in modules/xeBidAdapter.js - About 2 hrs to fix

      Function buildRequests has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildRequests(validBidRequests, bidderRequest) {
        const { refererInfo = {}, gdprConsent = {}, uspConsent } = bidderRequest;
        const requests = validBidRequests.map(req => {
          const request = {};
          request.bidId = req.bidId;
      Severity: Minor
      Found in modules/xeBidAdapter.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 getUserSyncs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function getUserSyncs(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') {
        const syncs = [];
        const pixels = deepAccess(serverResponses, '0.body.data.0.ext.pixels');
      
        if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled) && isArray(pixels) && pixels.length !== 0) {
      Severity: Minor
      Found in modules/xeBidAdapter.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

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

      function isBidRequestValid(req) {
        if (req && typeof req.params !== 'object') {
          logError('Params is not defined or is incorrect in the bidder settings');
          return false;
        }
      Severity: Minor
      Found in modules/xeBidAdapter.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      function getUserSyncs(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') {
        const syncs = [];
        const pixels = deepAccess(serverResponses, '0.body.data.0.ext.pixels');
      
        if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled) && isArray(pixels) && pixels.length !== 0) {
      Severity: Major
      Found in modules/xeBidAdapter.js and 2 other locations - About 1 day to fix
      modules/iqxBidAdapter.js on lines 150..171
      modules/lm_kiviadsBidAdapter.js on lines 158..179

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 288.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      function isBidRequestValid(req) {
        if (req && typeof req.params !== 'object') {
          logError('Params is not defined or is incorrect in the bidder settings');
          return false;
        }
      Severity: Major
      Found in modules/xeBidAdapter.js and 2 other locations - About 4 hrs to fix
      modules/iqxBidAdapter.js on lines 17..34
      modules/lm_kiviadsBidAdapter.js on lines 25..42

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 127.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

      function interpretResponse(serverResponse, { bidderRequest }) {
        const response = [];
        if (!isArray(deepAccess(serverResponse, 'body.data'))) {
          return response;
        }
      Severity: Major
      Found in modules/xeBidAdapter.js and 2 other locations - About 4 hrs to fix
      modules/iqxBidAdapter.js on lines 125..141
      modules/lm_kiviadsBidAdapter.js on lines 133..149

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 121.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

      export function getBidFloor(bid) {
        if (!isFn(bid.getFloor)) {
          return null;
        }
      
      
      Severity: Major
      Found in modules/xeBidAdapter.js and 2 other locations - About 3 hrs to fix
      modules/iqxBidAdapter.js on lines 179..195
      modules/lm_kiviadsBidAdapter.js on lines 187..203

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 114.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status