prebid/Prebid.js

View on GitHub
modules/brightcomBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

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

function buildRequests(bidReqs, bidderRequest) {
  try {
    let referrer = '';
    if (bidderRequest && bidderRequest.refererInfo) {
      referrer = bidderRequest.refererInfo.page;
Severity: Major
Found in modules/brightcomBidAdapter.js - About 3 hrs to fix

    File brightcomBidAdapter.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
      _each,
      isArray,
      getWindowTop,
      getUniqueIdentifierStr,
    Severity: Minor
    Found in modules/brightcomBidAdapter.js - About 2 hrs to fix

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

      function buildRequests(bidReqs, bidderRequest) {
        try {
          let referrer = '';
          if (bidderRequest && bidderRequest.refererInfo) {
            referrer = bidderRequest.refererInfo.page;
      Severity: Minor
      Found in modules/brightcomBidAdapter.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 interpretResponse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function interpretResponse(serverResponse) {
        if (!serverResponse.body || typeof serverResponse.body != 'object') {
          logWarn('Brightcom server returned empty/non-json response: ' + JSON.stringify(serverResponse.body));
          return [];
        }
      Severity: Minor
      Found in modules/brightcomBidAdapter.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if (id &&
              seatbid &&
              seatbid.length > 0 &&
              seatbid[0].bid &&
              seatbid[0].bid.length > 0) {
        Severity: Major
        Found in modules/brightcomBidAdapter.js - About 1 hr to fix

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

          function interpretResponse(serverResponse) {
            if (!serverResponse.body || typeof serverResponse.body != 'object') {
              logWarn('Brightcom server returned empty/non-json response: ' + JSON.stringify(serverResponse.body));
              return [];
            }
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 1 other location - About 1 day to fix
          modules/onomagicBidAdapter.js on lines 107..142

          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 349.

          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 2 locations. Consider refactoring.
          Open

              _each(bidReqs, function (bid) {
                let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes;
                bidSizes = ((isArray(bidSizes) && isArray(bidSizes[0])) ? bidSizes : [bidSizes]);
                bidSizes = bidSizes.filter(size => isArray(size));
                const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)}));
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 1 other location - About 1 day to fix
          modules/onomagicBidAdapter.js on lines 36..64

          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 336.

          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 7 locations. Consider refactoring.
          Open

          function _getIntersectionOfRects(rects) {
            const bbox = {
              left: rects[0].left,
              right: rects[0].right,
              top: rects[0].top,
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 6 other locations - About 1 day to fix
          libraries/percentInView/percentInView.js on lines 15..40
          modules/33acrossBidAdapter.js on lines 587..615
          modules/brightcomSSPBidAdapter.js on lines 257..282
          modules/marsmediaBidAdapter.js on lines 412..440
          modules/onomagicBidAdapter.js on lines 204..232
          modules/underdogmediaBidAdapter.js on lines 335..363

          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 317.

          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 4 locations. Consider refactoring.
          Open

          function _getPercentInView(element, topWin, {w, h} = {}) {
            const elementBoundingBox = _getBoundingBox(element, {w, h});
          
            // Obtain the intersection of the element and the viewport
            const elementInViewBoundingBox = _getIntersectionOfRects([{
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 3 other locations - About 7 hrs to fix
          modules/brightcomSSPBidAdapter.js on lines 284..305
          modules/onomagicBidAdapter.js on lines 234..258
          modules/underdogmediaBidAdapter.js on lines 272..303

          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 176.

          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 7 locations. Consider refactoring.
          Open

          function _getBoundingBox(element, {w, h} = {}) {
            let {width, height, left, top, right, bottom} = element.getBoundingClientRect();
          
            if ((width === 0 || height === 0) && w && h) {
              width = w;
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 6 other locations - About 6 hrs to fix
          libraries/percentInView/percentInView.js on lines 2..13
          modules/33acrossBidAdapter.js on lines 574..585
          modules/brightcomSSPBidAdapter.js on lines 244..255
          modules/marsmediaBidAdapter.js on lines 399..410
          modules/onomagicBidAdapter.js on lines 191..202
          modules/underdogmediaBidAdapter.js on lines 305..333

          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 168.

          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 11 locations. Consider refactoring.
          Open

          function _getBidFloor(bid) {
            if (!isFn(bid.getFloor)) {
              return bid.params.bidFloor ? bid.params.bidFloor : null;
            }
          
          
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 10 other locations - About 4 hrs to fix
          modules/brightcomSSPBidAdapter.js on lines 307..319
          modules/goldbachBidAdapter.js on lines 1117..1131
          modules/mediafuseBidAdapter.js on lines 1105..1119
          modules/nextrollBidAdapter.js on lines 197..212
          modules/omsBidAdapter.js on lines 269..281
          modules/onomagicBidAdapter.js on lines 260..274
          modules/pixfutureBidAdapter.js on lines 342..356
          modules/proxistoreBidAdapter.js on lines 161..175
          modules/pstudioBidAdapter.js on lines 419..433
          modules/winrBidAdapter.js on lines 577..591

          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 129.

          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 2 locations. Consider refactoring.
          Open

              const brightcomBidReq = {
                id: getUniqueIdentifierStr(),
                imp: brightcomImps,
                site: {
                  domain: bidderRequest?.refererInfo?.domain || '',
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 1 other location - About 3 hrs to fix
          modules/brightcomSSPBidAdapter.js on lines 71..87

          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 101.

          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 2 locations. Consider refactoring.
          Open

          function isBidRequestValid(bid) {
            if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') {
              return false;
            }
          
          
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 1 other location - About 1 hr to fix
          modules/onomagicBidAdapter.js on lines 95..105

          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 68.

          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 4 locations. Consider refactoring.
          Open

          function _getViewability(element, topWin, {w, h} = {}) {
            return getWindowTop().document.visibilityState === 'visible'
              ? _getPercentInView(element, topWin, {w, h})
              : 0;
          }
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 3 other locations - About 1 hr to fix
          modules/brightcomSSPBidAdapter.js on lines 228..230
          modules/omsBidAdapter.js on lines 244..246
          modules/onomagicBidAdapter.js on lines 173..177

          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 68.

          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 8 locations. Consider refactoring.
          Open

          function _getMinSize(sizes) {
            return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min);
          }
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 7 other locations - About 1 hr to fix
          modules/33acrossBidAdapter.js on lines 570..572
          modules/brightcomSSPBidAdapter.js on lines 240..242
          modules/marsmediaBidAdapter.js on lines 354..356
          modules/medianetBidAdapter.js on lines 293..295
          modules/omsBidAdapter.js on lines 265..267
          modules/onomagicBidAdapter.js on lines 187..189
          modules/underdogmediaBidAdapter.js on lines 217..219

          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 59.

          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 4 locations. Consider refactoring.
          Open

          function _getAdMarkup(bid) {
            let adm = bid.adm;
            if ('nurl' in bid) {
              adm += createTrackPixelHtml(bid.nurl);
            }
          Severity: Major
          Found in modules/brightcomBidAdapter.js and 3 other locations - About 40 mins to fix
          modules/brightcomSSPBidAdapter.js on lines 216..222
          modules/omsBidAdapter.js on lines 232..238
          modules/onomagicBidAdapter.js on lines 161..167

          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 49.

          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 2 locations. Consider refactoring.
          Open

              if (bidReqs[0] && bidReqs[0].userId) {
                deepSetValue(brightcomBidReq, 'user.ext.ids', bidReqs[0].userId || [])
              }
          Severity: Minor
          Found in modules/brightcomBidAdapter.js and 1 other location - About 30 mins to fix
          modules/brightcomBidAdapter.js on lines 104..106

          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 45.

          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 2 locations. Consider refactoring.
          Open

              if (bidReqs[0] && bidReqs[0].userIdAsEids) {
                deepSetValue(brightcomBidReq, 'user.ext.eids', bidReqs[0].userIdAsEids || [])
              }
          Severity: Minor
          Found in modules/brightcomBidAdapter.js and 1 other location - About 30 mins to fix
          modules/brightcomBidAdapter.js on lines 108..110

          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 45.

          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