prebid/Prebid.js

View on GitHub
modules/adtrgtmeBidAdapter.js

Summary

Maintainability
F
3 days
Test Coverage

File adtrgtmeBidAdapter.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { deepAccess, isFn, isStr, isNumber, isArray, isEmpty, isPlainObject, generateUUID, logWarn } from '../src/utils.js';
import { config } from '../src/config.js';
import { hasPurpose1Consent } from '../src/utils/gpdr.js';
Severity: Minor
Found in modules/adtrgtmeBidAdapter.js - About 2 hrs to fix

    Function generateOpenRtbObject has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function generateOpenRtbObject(bidderRequest, bid) {
      if (bidderRequest) {
        let outBoundBidRequest = {
          id: generateUUID(),
          cur: [getFloorModuleData(bidderRequest).currency || deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY],
    Severity: Minor
    Found in modules/adtrgtmeBidAdapter.js - About 1 hr to fix

      Function appendImpObject has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function appendImpObject(bid, openRtbObject) {
        const mediaTypeMode = getMediaType(bid);
      
        if (openRtbObject && bid) {
          const impObject = {
      Severity: Minor
      Found in modules/adtrgtmeBidAdapter.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 generateOpenRtbObject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function generateOpenRtbObject(bidderRequest, bid) {
        if (bidderRequest) {
          let outBoundBidRequest = {
            id: generateUUID(),
            cur: [getFloorModuleData(bidderRequest).currency || deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY],
      Severity: Minor
      Found in modules/adtrgtmeBidAdapter.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 appendImpObject has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function appendImpObject(bid, openRtbObject) {
        const mediaTypeMode = getMediaType(bid);
      
        if (openRtbObject && bid) {
          const impObject = {
      Severity: Minor
      Found in modules/adtrgtmeBidAdapter.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

          if (bidderRequest) {
            let outBoundBidRequest = {
              id: generateUUID(),
              cur: [getFloorModuleData(bidderRequest).currency || deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY],
              imp: [],
        Severity: Major
        Found in modules/adtrgtmeBidAdapter.js - About 1 hr to fix

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

          function validateAppendObject(validationFunction, allowedKeys, inputObject, appendToObject) {
            const outputObject = {
              ...appendToObject
            };
            if (allowedKeys.length > 0 && typeof validationFunction === 'function') {
          Severity: Minor
          Found in modules/adtrgtmeBidAdapter.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

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

          function extractUserSyncUrls(syncOptions, pixels) {
            let itemsRegExp = /(img|iframe)[\s\S]*?src\s*=\s*("|')(.*?)\2/gi;
            let tagNameRegExp = /\w*(?=\s)/;
            let srcRegExp = /src=("|')(.*?)\1/;
            let userSyncObjects = [];
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 1 day to fix
          modules/yahoosspBidAdapter.js on lines 78..107

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

          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 (mediaTypeMode === BANNER) {
                impObject.banner = {
                  mimes: bid.mediaTypes.banner.mimes || ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'],
                  format: transformSizes(bid.sizes)
                };
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 3 hrs to fix
          modules/yahoosspBidAdapter.js on lines 350..358

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

          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 (deepAccess(bid, 'ortb2Imp.instl') && isNumber(bid.ortb2Imp.instl) && (bid.ortb2Imp.instl === 1)) {
                impObject.instl = bid.ortb2Imp.instl;
              };
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 1 hr to fix
          modules/yahoosspBidAdapter.js on lines 403..405

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

          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 (deepAccess(bid, 'schain')) {
                outBoundBidRequest.source.ext.schain = bid.schain;
                outBoundBidRequest.source.ext.schain.nodes[0].rid = outBoundBidRequest.id;
              };
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 1 hr to fix
          modules/yahoosspBidAdapter.js on lines 331..334

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

          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

              return validBidRequests.map(bid => {
                const payloadClone = generateOpenRtbObject(bidderRequest, bid);
                appendImpObject(bid, payloadClone);
          
                return generateServerRequest({payload: payloadClone, requestOptions, bidderRequest: bid});
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 1 hr to fix
          modules/yahoosspBidAdapter.js on lines 611..615

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

          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 (deepAccess(bid, 'ortb2Imp.ext.data') && isPlainObject(bid.ortb2Imp.ext.data)) {
                impObject.ext.data = bid.ortb2Imp.ext.data;
              };
          Severity: Major
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 1 hr to fix
          modules/yahoosspBidAdapter.js on lines 399..401

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

          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

                source: {
                  ext: {
                    hb: 1,
                    adapterver: ADAPTER_VERSION,
                    prebidver: PREBID_VERSION,
          Severity: Minor
          Found in modules/adtrgtmeBidAdapter.js and 1 other location - About 40 mins to fix
          modules/yahoosspBidAdapter.js on lines 289..300

          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

          There are no issues that match your filters.

          Category
          Status