prebid/Prebid.js

View on GitHub
modules/richaudienceBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

File richaudienceBidAdapter.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {deepAccess, isStr, triggerPixel} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
Severity: Minor
Found in modules/richaudienceBidAdapter.js - About 3 hrs to fix

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

      buildRequests: function (validBidRequests, bidderRequest) {
        return validBidRequests.map(bid => {
          var payload = {
            bidfloor: raiGetFloor(bid, config),
            ifa: bid.params.ifa,
    Severity: Minor
    Found in modules/richaudienceBidAdapter.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 buildRequests has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      buildRequests: function (validBidRequests, bidderRequest) {
        return validBidRequests.map(bid => {
          var payload = {
            bidfloor: raiGetFloor(bid, config),
            ifa: bid.params.ifa,
    Severity: Major
    Found in modules/richaudienceBidAdapter.js - About 2 hrs to fix

      Function raiGetSyncInclude has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function raiGetSyncInclude(config) {
        try {
          let raConfig = null;
          let raiSync = {};
          if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') {
      Severity: Minor
      Found in modules/richaudienceBidAdapter.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 15 (exceeds 5 allowed). Consider refactoring.
      Open

        interpretResponse: function (serverResponse, bidRequest) {
          const bidResponses = [];
          // try catch
          var response = serverResponse.body;
          if (response) {
      Severity: Minor
      Found in modules/richaudienceBidAdapter.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 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
          const syncs = [];
      
          var rand = Math.floor(Math.random() * 9999999999);
          var syncUrl = '';
      Severity: Minor
      Found in modules/richaudienceBidAdapter.js - About 1 hr to fix

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

          interpretResponse: function (serverResponse, bidRequest) {
            const bidResponses = [];
            // try catch
            var response = serverResponse.body;
            if (response) {
        Severity: Minor
        Found in modules/richaudienceBidAdapter.js - About 1 hr to fix

          Function getUserSyncs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
              const syncs = [];
          
              var rand = Math.floor(Math.random() * 9999999999);
              var syncUrl = '';
          Severity: Minor
          Found in modules/richaudienceBidAdapter.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 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
          Severity: Minor
          Found in modules/richaudienceBidAdapter.js - About 35 mins to fix

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

            function raiGetFloor(bid, config) {
              try {
                let raiFloor;
                if (bid.params.bidfloor != null) {
                  raiFloor = bid.params.bidfloor;
            Severity: Minor
            Found in modules/richaudienceBidAdapter.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 renderAd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function renderAd(bid) {
              let raOutstreamHBPassback = `${bid.vastXml}`;
              let raPlayerHB = {
                config: bid.params[0].player != undefined ? {
                  end: bid.params[0].player.end != null ? bid.params[0].player.end : 'close',
            Severity: Minor
            Found in modules/richaudienceBidAdapter.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

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

                  if (bidderRequest?.gppConsent) {
                    payload.privacy = {
                      gpp: bidderRequest.gppConsent.gppString,
                      gpp_sid: bidderRequest.gppConsent.applicableSections
                    }
            Severity: Major
            Found in modules/richaudienceBidAdapter.js and 1 other location - About 4 hrs to fix
            modules/appnexusBidAdapter.js on lines 316..326

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

            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 (raConfig.iframe != null && typeof raConfig.iframe != 'undefined') {
                    raiSync.raiIframe = raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raConfig.iframe.filter : 'exclude';
                  }
            Severity: Major
            Found in modules/richaudienceBidAdapter.js and 1 other location - About 2 hrs to fix
            modules/richaudienceBidAdapter.js on lines 337..339

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

            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 (raConfig.image != null && typeof raConfig.image != 'undefined') {
                    raiSync.raiImage = raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raConfig.image.filter : 'exclude';
                  }
            Severity: Major
            Found in modules/richaudienceBidAdapter.js and 1 other location - About 2 hrs to fix
            modules/richaudienceBidAdapter.js on lines 334..336

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

            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 (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
                  consentGPP = 'gpp=' + encodeURIComponent(gppConsent.gppString);
                  consentGPP += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(','));
                }
            Severity: Major
            Found in modules/richaudienceBidAdapter.js and 1 other location - About 1 hr to fix
            modules/adyoulikeBidAdapter.js on lines 216..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 71.

            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

              isBidRequestValid: function (bid) {
                return !!(bid.params && bid.params.pid && bid.params.supplyType);
              },
            Severity: Minor
            Found in modules/richaudienceBidAdapter.js and 1 other location - About 40 mins to fix
            modules/integr8BidAdapter.js on lines 31..33

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

            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

                  end: bid.params[0].player.end != null ? bid.params[0].player.end : 'close',
            Severity: Minor
            Found in modules/richaudienceBidAdapter.js and 2 other locations - About 35 mins to fix
            modules/richaudienceBidAdapter.js on lines 302..302
            modules/richaudienceBidAdapter.js on lines 303..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 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

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

                  init: bid.params[0].player.init != null ? bid.params[0].player.init : 'close',
            Severity: Minor
            Found in modules/richaudienceBidAdapter.js and 2 other locations - About 35 mins to fix
            modules/richaudienceBidAdapter.js on lines 301..301
            modules/richaudienceBidAdapter.js on lines 303..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 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

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

                  skin: bid.params[0].player.skin != null ? bid.params[0].player.skin : 'light',
            Severity: Minor
            Found in modules/richaudienceBidAdapter.js and 2 other locations - About 35 mins to fix
            modules/richaudienceBidAdapter.js on lines 301..301
            modules/richaudienceBidAdapter.js on lines 302..302

            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