prebid/Prebid.js

View on GitHub
modules/visxBidAdapter.js

Summary

Maintainability
F
3 days
Test Coverage

File visxBidAdapter.js has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {deepAccess, logError, parseSizesInput, 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 {INSTREAM as VIDEO_INSTREAM} from '../src/video.js';
Severity: Minor
Found in modules/visxBidAdapter.js - About 6 hrs to fix

    Function _addBidResponse has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    function _addBidResponse(serverBid, bidsMap, currency, bidResponses) {
      if (!serverBid) return;
      let errorMessage;
      if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid);
      if (!serverBid.impid) errorMessage = LOG_ERROR_MESS.noImpId + JSON.stringify(serverBid);
    Severity: Minor
    Found in modules/visxBidAdapter.js - About 5 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 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      buildRequests: function(validBidRequests, bidderRequest) {
        const auids = [];
        const bidsMap = {};
        const bids = validBidRequests || [];
        const currency =
    Severity: Major
    Found in modules/visxBidAdapter.js - About 4 hrs to fix

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

        buildRequests: function(validBidRequests, bidderRequest) {
          const auids = [];
          const bidsMap = {};
          const bids = validBidRequests || [];
          const currency =
      Severity: Minor
      Found in modules/visxBidAdapter.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 _addBidResponse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _addBidResponse(serverBid, bidsMap, currency, bidResponses) {
        if (!serverBid) return;
        let errorMessage;
        if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid);
        if (!serverBid.impid) errorMessage = LOG_ERROR_MESS.noImpId + JSON.stringify(serverBid);
      Severity: Major
      Found in modules/visxBidAdapter.js - About 2 hrs to fix

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

          getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
            var query = [];
            if (gdprConsent) {
              if (gdprConsent.consentString) {
                query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString));
        Severity: Minor
        Found in modules/visxBidAdapter.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

        Avoid deeply nested control flow statements.
        Open

                  if (serverBid.ext.visx && serverBid.ext.visx.events) {
                    const prebidExtEvents = bidResponse.ext.events || {};
                    bidResponse.ext.events = Object.assign(prebidExtEvents, serverBid.ext.visx.events);
                  }
        Severity: Major
        Found in modules/visxBidAdapter.js - About 45 mins to fix

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

            isBidRequestValid: function(bid) {
              if (_isVideoBid(bid)) {
                if (!_isValidVideoBid(bid, true)) {
                  // in case if video bid configuration invalid will try to send bid request for banner
                  if (!_isBannerBid(bid)) {
          Severity: Minor
          Found in modules/visxBidAdapter.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 _isValidVideoBid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function _isValidVideoBid(bid, logErrors = false) {
            let result = true;
            const videoMediaType = deepAccess(bid, 'mediaTypes.video');
            if (!_isVideoInstreamBid(bid)) {
              if (logErrors) {
          Severity: Minor
          Found in modules/visxBidAdapter.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 onTimeout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            onTimeout: function(timeoutData) {
              // Call '/track/bid_timeout' with timeout data
              const dataToSend = timeoutData.map(({ params, timeout }) => {
                const data = { timeout };
                if (params) {
          Severity: Minor
          Found in modules/visxBidAdapter.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 2 locations. Consider refactoring.
          Open

          function _getBidFromResponse(respItem) {
            if (!respItem) {
              logError(LOG_ERROR_MESS.emptySeatbid);
            } else if (!respItem.bid) {
              logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem));
          Severity: Major
          Found in modules/visxBidAdapter.js and 1 other location - About 4 hrs to fix
          modules/gridBidAdapter.js on lines 515..524

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

          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 (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse;
              else if (serverResponse.seatbid && !serverResponse.seatbid.length) {
                errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray;
              }
          Severity: Minor
          Found in modules/visxBidAdapter.js and 1 other location - About 55 mins to fix
          modules/gridBidAdapter.js on lines 435..438

          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

          There are no issues that match your filters.

          Category
          Status