prebid/Prebid.js

View on GitHub
modules/adyoulikeBidAdapter.js

Summary

Maintainability
F
5 days
Test Coverage

File adyoulikeBidAdapter.js has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {buildUrl, deepAccess, parseSizesInput} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import {find} from '../src/polyfill.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
Severity: Minor
Found in modules/adyoulikeBidAdapter.js - About 6 hrs to fix

    Function getNativeAssets has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getNativeAssets(response, nativeConfig) {
      if (typeof response.Native === 'object') {
        return response.Native;
      }
      const native = {};
    Severity: Major
    Found in modules/adyoulikeBidAdapter.js - About 3 hrs to fix

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

        buildRequests: function (bidRequests, bidderRequest) {
          // convert Native ORTB definition to old-style prebid native definition
          bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
          let hasVideo = false;
          let eids;
      Severity: Minor
      Found in modules/adyoulikeBidAdapter.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 72 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);
          let hasVideo = false;
          let eids;
      Severity: Major
      Found in modules/adyoulikeBidAdapter.js - About 2 hrs to fix

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

        function getImageUrl(config, resource, width, height) {
          let url = '';
          if (resource && resource.Kind) {
            switch (resource.Kind) {
              case 'INTERNAL':
        Severity: Minor
        Found in modules/adyoulikeBidAdapter.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 createEndpointQS has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function createEndpointQS(bidderRequest) {
          const qs = {};
          if (bidderRequest) {
            const ref = bidderRequest.refererInfo;
            if (ref) {
        Severity: Minor
        Found in modules/adyoulikeBidAdapter.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 Bids has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              Bids: bidRequests.reduce((accumulator, bidReq) => {
                let mediatype = getMediatype(bidReq);
                let sizesArray = getSizeArray(bidReq);
                let size = getSize(sizesArray);
                accumulator[bidReq.bidId] = {};
        Severity: Minor
        Found in modules/adyoulikeBidAdapter.js - About 1 hr to fix

          Function createBid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createBid(response, bidRequests) {
            if (!response || (!response.Ad && !response.Native && !response.Vast)) {
              return;
            }
          
          
          Severity: Minor
          Found in modules/adyoulikeBidAdapter.js - About 1 hr to fix

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

            function createBid(response, bidRequests) {
              if (!response || (!response.Ad && !response.Native && !response.Vast)) {
                return;
              }
            
            
            Severity: Minor
            Found in modules/adyoulikeBidAdapter.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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
                if (!syncOptions.iframeEnabled) {
                  return [];
                }
            
            
            Severity: Minor
            Found in modules/adyoulikeBidAdapter.js - About 45 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 getUserSyncs has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

              function getSizeArray(bid) {
                let inputSize = bid.sizes || [];
              
                if (bid.mediaTypes && bid.mediaTypes.banner) {
                  inputSize = bid.mediaTypes.banner.sizes || [];
              Severity: Minor
              Found in modules/adyoulikeBidAdapter.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 getNativeAssets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function getNativeAssets(response, nativeConfig) {
                if (typeof response.Native === 'object') {
                  return response.Native;
                }
                const native = {};
              Severity: Minor
              Found in modules/adyoulikeBidAdapter.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

              function getSizeArray(bid) {
                let inputSize = bid.sizes || [];
              
                if (bid.mediaTypes && bid.mediaTypes.banner) {
                  inputSize = bid.mediaTypes.banner.sizes || [];
              Severity: Major
              Found in modules/adyoulikeBidAdapter.js and 1 other location - About 6 hrs to fix
              modules/retailspotBidAdapter.js on lines 99..115

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

              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

              function getSize(sizesArray) {
                const parsed = {};
                // the main requested size is the first one
                const size = sizesArray[0];
              
              
              Severity: Major
              Found in modules/adyoulikeBidAdapter.js and 1 other location - About 5 hrs to fix
              modules/retailspotBidAdapter.js on lines 118..139

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

              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 (request) {
                  if (!response.Width || response.Width === '0') {
                    response.Width = request.Width;
                  }
              
              
              Severity: Major
              Found in modules/adyoulikeBidAdapter.js and 1 other location - About 2 hrs to fix
              modules/retailspotBidAdapter.js on lines 151..159

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

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

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

                  if (gdprConsent) {
                    params += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
                    params += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
                  }
              Severity: Major
              Found in modules/adyoulikeBidAdapter.js and 2 other locations - About 1 hr to fix
              modules/pubmaticBidAdapter.js on lines 1451..1454
              modules/zeta_global_sspBidAdapter.js on lines 255..258

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

              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

                  serverResponse.body.forEach(response => {
                    const bid = createBid(response, bidRequests);
                    if (bid) {
                      bidResponses.push(bid);
                    }
              Severity: Minor
              Found in modules/adyoulikeBidAdapter.js and 1 other location - About 55 mins to fix
              modules/retailspotBidAdapter.js on lines 88..93

              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

              There are no issues that match your filters.

              Category
              Status