prebid/Prebid.js

View on GitHub
modules/nobidBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

Function nobidBuildRequests has a Cognitive Complexity of 144 (exceeds 5 allowed). Consider refactoring.
Open

function nobidBuildRequests(bids, bidderRequest) {
  var serializeState = function(divIds, siteId, adunits) {
    var filterAdUnitsByIds = function(divIds, adUnits) {
      var filtered = [];
      if (!divIds.length) {
Severity: Minor
Found in modules/nobidBidAdapter.js - About 2 days 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 nobidBuildRequests has 242 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function nobidBuildRequests(bids, bidderRequest) {
  var serializeState = function(divIds, siteId, adunits) {
    var filterAdUnitsByIds = function(divIds, adUnits) {
      var filtered = [];
      if (!divIds.length) {
Severity: Major
Found in modules/nobidBidAdapter.js - About 1 day to fix

    File nobidBidAdapter.js has 461 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { logInfo, deepAccess, logWarn, isArray, getParameterByName } from '../src/utils.js';
    import { config } from '../src/config.js';
    import { registerBidder } from '../src/adapters/bidderFactory.js';
    import { BANNER, VIDEO } from '../src/mediaTypes.js';
    import { getStorageManager } from '../src/storageManager.js';
    Severity: Minor
    Found in modules/nobidBidAdapter.js - About 7 hrs to fix

      Function serializeState has 134 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var serializeState = function(divIds, siteId, adunits) {
          var filterAdUnitsByIds = function(divIds, adUnits) {
            var filtered = [];
            if (!divIds.length) {
              filtered = adUnits;
      Severity: Major
      Found in modules/nobidBidAdapter.js - About 5 hrs to fix

        Function nobidInterpretResponse has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        function nobidInterpretResponse(response, bidRequest) {
          var findBid = function(divid, bids) {
            for (var i = 0; i < bids.length; i++) {
              if (bids[i].adUnitCode == divid) {
                return bids[i];
        Severity: Minor
        Found in modules/nobidBidAdapter.js - About 4 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 getUserSyncs has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy, gppConsent) {
            if (syncOptions.iframeEnabled) {
              let params = '';
              if (gdprConsent && typeof gdprConsent.consentString === 'string') {
                // add 'gdpr' only if 'gdprApplies' is defined
        Severity: Minor
        Found in modules/nobidBidAdapter.js - About 3 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 newAdunit has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function newAdunit(adunitObject, adunits) {
            var getAdUnit = function(divid, adunits) {
              for (var i = 0; i < adunits.length; i++) {
                if (adunits[i].d === divid) {
                  return adunits[i];
        Severity: Major
        Found in modules/nobidBidAdapter.js - About 2 hrs to fix

          Function nobidInterpretResponse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function nobidInterpretResponse(response, bidRequest) {
            var findBid = function(divid, bids) {
              for (var i = 0; i < bids.length; i++) {
                if (bids[i].adUnitCode == divid) {
                  return bids[i];
          Severity: Major
          Found in modules/nobidBidAdapter.js - About 2 hrs to fix

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

              getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy, gppConsent) {
                if (syncOptions.iframeEnabled) {
                  let params = '';
                  if (gdprConsent && typeof gdprConsent.consentString === 'string') {
                    // add 'gdpr' only if 'gdprApplies' is defined
            Severity: Minor
            Found in modules/nobidBidAdapter.js - About 1 hr to fix

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

                buildRequests: function(validBidRequests, bidderRequest) {
                  function resolveEndpoint() {
                    var ret = 'https://ads.servenobid.com/';
                    var env = (typeof getParameterByName === 'function') && (getParameterByName('nobid-env'));
                    env = window.location.href.indexOf('nobid-env=dev') > 0 ? 'dev' : env;
              Severity: Minor
              Found in modules/nobidBidAdapter.js - About 1 hr to fix

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

                  buildRequests: function(validBidRequests, bidderRequest) {
                    function resolveEndpoint() {
                      var ret = 'https://ads.servenobid.com/';
                      var env = (typeof getParameterByName === 'function') && (getParameterByName('nobid-env'));
                      env = window.location.href.indexOf('nobid-env=dev') > 0 ? 'dev' : env;
                Severity: Minor
                Found in modules/nobidBidAdapter.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, serverResponses, gdprConsent, usPrivacy, gppConsent) {
                Severity: Minor
                Found in modules/nobidBidAdapter.js - About 35 mins to fix

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

                        if (gdprConsent && typeof gdprConsent.consentString === 'string') {
                          // add 'gdpr' only if 'gdprApplies' is defined
                          if (typeof gdprConsent.gdprApplies === 'boolean') {
                            params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
                          } else {
                  Severity: Major
                  Found in modules/nobidBidAdapter.js and 2 other locations - About 3 hrs to fix
                  modules/apacdexBidAdapter.js on lines 205..212
                  modules/smilewantedBidAdapter.js on lines 215..222

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

                  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

                      var getAdUnit = function(divid, adunits) {
                        for (var i = 0; i < adunits.length; i++) {
                          if (adunits[i].d === divid) {
                            return adunits[i];
                          }
                  Severity: Major
                  Found in modules/nobidBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/nobidBidAdapter.js on lines 288..295

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

                  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

                    var findBid = function(divid, bids) {
                      for (var i = 0; i < bids.length; i++) {
                        if (bids[i].adUnitCode == divid) {
                          return bids[i];
                        }
                  Severity: Major
                  Found in modules/nobidBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/nobidBidAdapter.js on lines 178..185

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

                  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

                    onTimeout: function(data) {
                      window.nobid.timeoutTotal++;
                      log('Timeout total: ' + window.nobid.timeoutTotal, data);
                      return window.nobid.timeoutTotal;
                    },
                  Severity: Minor
                  Found in modules/nobidBidAdapter.js and 1 other location - About 50 mins to fix
                  modules/nobidBidAdapter.js on lines 505..509

                  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

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

                    onBidWon: function(data) {
                      window.nobid.bidWonTotal++;
                      log('BidWon total: ' + window.nobid.bidWonTotal, data);
                      return window.nobid.bidWonTotal;
                    }
                  Severity: Minor
                  Found in modules/nobidBidAdapter.js and 1 other location - About 50 mins to fix
                  modules/nobidBidAdapter.js on lines 500..504

                  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

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

                          gdprConsent = {
                            consentString: bidderRequest.gdprConsent.consentString,
                            // will check if the gdprApplies field was populated with a boolean value (ie from page config).  If it's undefined, then default to true
                            consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : false
                          }
                  Severity: Minor
                  Found in modules/nobidBidAdapter.js and 1 other location - About 50 mins to fix
                  modules/admixerBidAdapter.js on lines 62..66

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

                  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