prebid/Prebid.js

View on GitHub
modules/craftBidAdapter.js

Summary

Maintainability
C
1 day
Test Coverage

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

  buildRequests: function(bidRequests, bidderRequest) {
    // convert Native ORTB definition to old-style prebid native definition
    bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
    const bidRequest = bidRequests[0];
    const tags = bidRequests.map(bidToTag);
Severity: Minor
Found in modules/craftBidAdapter.js - About 1 hr to fix

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

      buildRequests: function(bidRequests, bidderRequest) {
        // convert Native ORTB definition to old-style prebid native definition
        bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
        const bidRequest = bidRequests[0];
        const tags = bidRequests.map(bidToTag);
    Severity: Minor
    Found in modules/craftBidAdapter.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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      interpretResponse: function(serverResponse, {bidderRequest}) {
        try {
          serverResponse = serverResponse.body;
          const bids = [];
          if (!serverResponse) {
    Severity: Minor
    Found in modules/craftBidAdapter.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 bidToTag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function bidToTag(bid) {
      const tag = {};
      for (var k in bid.params) {
        tag[k] = bid.params[k];
      }
    Severity: Minor
    Found in modules/craftBidAdapter.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

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

          if (serverResponse.tags) {
            serverResponse.tags.forEach(serverBid => {
              const rtbBid = getRtbBid(serverBid);
              if (rtbBid) {
                if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) {
    Severity: Major
    Found in modules/craftBidAdapter.js and 3 other locations - About 4 hrs to fix
    modules/adrelevantisBidAdapter.js on lines 174..185
    modules/goldbachBidAdapter.js on lines 349..360
    modules/winrBidAdapter.js on lines 285..299

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

    function parseMediaType(rtbBid) {
      const adType = rtbBid.ad_type;
      if (adType === VIDEO) {
        return VIDEO;
      } else if (adType === NATIVE) {
    Severity: Major
    Found in modules/craftBidAdapter.js and 4 other locations - About 1 hr to fix
    modules/adrelevantisBidAdapter.js on lines 577..586
    modules/appnexusBidAdapter.js on lines 1232..1241
    modules/goldbachBidAdapter.js on lines 1069..1078
    modules/mediafuseBidAdapter.js on lines 1056..1065

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

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

    function getRtbBid(tag) {
      return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb);
    }
    Severity: Major
    Found in modules/craftBidAdapter.js and 6 other locations - About 55 mins to fix
    modules/adrelevantisBidAdapter.js on lines 537..539
    modules/appnexusBidAdapter.js on lines 1144..1146
    modules/goldbachBidAdapter.js on lines 986..988
    modules/mediafuseBidAdapter.js on lines 973..975
    modules/targetVideoBidAdapter.js on lines 192..194
    modules/winrBidAdapter.js on lines 520..522

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

    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 (bidderRequest.gdprConsent) {
            payload.gdpr_consent = {
              consent_string: bidderRequest.gdprConsent.consentString,
              consent_required: bidderRequest.gdprConsent.gdprApplies
            };
    Severity: Minor
    Found in modules/craftBidAdapter.js and 1 other location - About 40 mins to fix
    modules/lockerdomeBidAdapter.js on lines 34..39

    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

    There are no issues that match your filters.

    Category
    Status