prebid/Prebid.js

View on GitHub
modules/sonobiBidAdapter.js

Summary

Maintainability
D
2 days
Test Coverage

File sonobiBidAdapter.js has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { registerBidder } from '../src/adapters/bidderFactory.js';
import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, isFn, isPlainObject } from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
Severity: Minor
Found in modules/sonobiBidAdapter.js - About 6 hrs to fix

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

      buildRequests: (validBidRequests, bidderRequest) => {
        const bids = validBidRequests.map(bid => {
          let slotIdentifier = _validateSlot(bid);
          if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) {
            slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier;
    Severity: Minor
    Found in modules/sonobiBidAdapter.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 buildRequests has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      buildRequests: (validBidRequests, bidderRequest) => {
        const bids = validBidRequests.map(bid => {
          let slotIdentifier = _validateSlot(bid);
          if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) {
            slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier;
    Severity: Major
    Found in modules/sonobiBidAdapter.js - About 3 hrs to fix

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

        interpretResponse: (serverResponse, bidderRequest) => {
          const bidResponse = serverResponse.body;
          const bidsReturned = [];
          const referrer = bidderRequest.data.ref;
          if (Object.keys(bidResponse.slots).length === 0) {
      Severity: Major
      Found in modules/sonobiBidAdapter.js - About 2 hrs to fix

        Function loadOrCreateFirstPartyData has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadOrCreateFirstPartyData() {
          var FIRST_PARTY_KEY = '_iiq_fdata';
          var tryParse = function (data) {
            try {
              return JSON.parse(data);
        Severity: Minor
        Found in modules/sonobiBidAdapter.js - About 1 hr to fix

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

            isBidRequestValid: (bid) => {
              if (!bid.params) {
                return false;
              }
              if (!bid.params.ad_unit && !bid.params.placement_id) {
          Severity: Minor
          Found in modules/sonobiBidAdapter.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 loadOrCreateFirstPartyData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function loadOrCreateFirstPartyData() {
            var FIRST_PARTY_KEY = '_iiq_fdata';
            var tryParse = function (data) {
              try {
                return JSON.parse(data);
          Severity: Minor
          Found in modules/sonobiBidAdapter.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 _validateMediaType has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function _validateMediaType(bidRequest) {
            let mediaType;
            if (deepAccess(bidRequest, 'mediaTypes.video')) {
              mediaType = 'video';
            } else if (deepAccess(bidRequest, 'mediaTypes.banner')) {
          Severity: Minor
          Found in modules/sonobiBidAdapter.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 too many return statements within this function.
          Open

              return true;
          Severity: Major
          Found in modules/sonobiBidAdapter.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return false;
            Severity: Major
            Found in modules/sonobiBidAdapter.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return false;
              Severity: Major
              Found in modules/sonobiBidAdapter.js - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status