prebid/Prebid.js

View on GitHub
modules/omsBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

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

function buildRequests(bidReqs, bidderRequest) {
  try {
    const impressions = bidReqs.map(bid => {
      let bidSizes = bid?.mediaTypes?.banner?.sizes || bid.sizes;
      bidSizes = ((isArray(bidSizes) && isArray(bidSizes[0])) ? bidSizes : [bidSizes]);
Severity: Major
Found in modules/omsBidAdapter.js - About 3 hrs to fix

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

    function buildRequests(bidReqs, bidderRequest) {
      try {
        const impressions = bidReqs.map(bid => {
          let bidSizes = bid?.mediaTypes?.banner?.sizes || bid.sizes;
          bidSizes = ((isArray(bidSizes) && isArray(bidSizes[0])) ? bidSizes : [bidSizes]);
    Severity: Minor
    Found in modules/omsBidAdapter.js - About 2 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

    Function interpretResponse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function impressions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const impressions = bidReqs.map(bid => {
            let bidSizes = 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: Minor
      Found in modules/omsBidAdapter.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) {
              response = seatbid[0].bid.map(bid => {
                return {
                  requestId: bid.impid,
                  cpm: parseFloat(bid.price),
        Severity: Major
        Found in modules/omsBidAdapter.js - About 1 hr to fix

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

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

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

          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/omsBidAdapter.js and 10 other locations - About 4 hrs to fix
          modules/brightcomBidAdapter.js on lines 287..301
          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/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 4 locations. Consider refactoring.
          Open

          function _getViewability(element, topWin, {w, h} = {}) {
            return getWindowTop().document.visibilityState === 'visible' ? percentInView(element, topWin, {w, h}) : 0;
          }
          Severity: Major
          Found in modules/omsBidAdapter.js and 3 other locations - About 1 hr to fix
          modules/brightcomBidAdapter.js on lines 200..204
          modules/brightcomSSPBidAdapter.js on lines 228..230
          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 2 locations. Consider refactoring.
          Open

          function _getGpp(bidderRequest) {
            if (bidderRequest?.gppConsent != null) {
              return bidderRequest.gppConsent;
            }
          
          
          Severity: Major
          Found in modules/omsBidAdapter.js and 1 other location - About 1 hr to fix
          modules/amxBidAdapter.js on lines 275..283

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

          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/omsBidAdapter.js and 7 other locations - About 1 hr to fix
          modules/33acrossBidAdapter.js on lines 570..572
          modules/brightcomBidAdapter.js on lines 214..216
          modules/brightcomSSPBidAdapter.js on lines 240..242
          modules/marsmediaBidAdapter.js on lines 354..356
          modules/medianetBidAdapter.js on lines 293..295
          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 2 locations. Consider refactoring.
          Open

          function isBidRequestValid(bid) {
            if (bid.bidder !== BIDDER_CODE || !bid.params || !bid.params.publisherId) {
              return false;
            }
          
          
          Severity: Minor
          Found in modules/omsBidAdapter.js and 1 other location - About 55 mins to fix
          modules/brightcomSSPBidAdapter.js on lines 124..130

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

          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 _trackEvent(endpoint, data) {
            ajax(`${TRACK_EVENT_URL}/${endpoint}`, null, JSON.stringify(data), {
              method: 'POST',
              withCredentials: false
            });
          Severity: Minor
          Found in modules/omsBidAdapter.js and 1 other location - About 50 mins to fix
          modules/brightcomSSPBidAdapter.js on lines 197..202

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

          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/omsBidAdapter.js and 3 other locations - About 40 mins to fix
          modules/brightcomBidAdapter.js on lines 188..194
          modules/brightcomSSPBidAdapter.js on lines 216..222
          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

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

              if (bidderRequest?.gdprConsent) {
                deepSetValue(payload, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies);
                deepSetValue(payload, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
              }
          Severity: Minor
          Found in modules/omsBidAdapter.js and 1 other location - About 35 mins to fix
          modules/brightcomSSPBidAdapter.js on lines 89..92

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

          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