prebid/Prebid.js

View on GitHub
modules/tappxBidAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

Function buildOneRequest has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

function buildOneRequest(validBidRequests, bidderRequest) {
  let hostInfo = _getHostInfo(validBidRequests);
  const ENDPOINT = hostInfo.endpoint;
  hostDomain = hostInfo.domain;

Severity: Minor
Found in modules/tappxBidAdapter.js - About 1 day 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 buildOneRequest has 204 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function buildOneRequest(validBidRequests, bidderRequest) {
  let hostInfo = _getHostInfo(validBidRequests);
  const ENDPOINT = hostInfo.endpoint;
  hostDomain = hostInfo.domain;

Severity: Major
Found in modules/tappxBidAdapter.js - About 1 day to fix

    File tappxBidAdapter.js has 466 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    import { logWarn, deepAccess, isFn, isPlainObject, getDNT, isBoolean, isNumber, isStr, isArray } from '../src/utils.js';
    import { registerBidder } from '../src/adapters/bidderFactory.js';
    import { BANNER, VIDEO } from '../src/mediaTypes.js';
    Severity: Minor
    Found in modules/tappxBidAdapter.js - About 7 hrs to fix

      Consider simplifying this complex logical expression.
      Open

        if (deepAccess(validBidRequests, 'params.app')) {
          let app = {};
          app.name = deepAccess(validBidRequests, 'params.app.name');
          app.bundle = deepAccess(validBidRequests, 'params.app.bundle');
          app.domain = deepAccess(validBidRequests, 'params.app.domain');
      Severity: Critical
      Found in modules/tappxBidAdapter.js - About 3 hrs to fix

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

        function interpretBid(serverBid, request) {
          let bidReturned = {
            requestId: request.bids?.bidId,
            cpm: serverBid.price,
            currency: serverBid.cur ? serverBid.cur : CUR,
        Severity: Minor
        Found in modules/tappxBidAdapter.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 interpretBid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function interpretBid(serverBid, request) {
          let bidReturned = {
            requestId: request.bids?.bidId,
            cpm: serverBid.price,
            currency: serverBid.cur ? serverBid.cur : CUR,
        Severity: Minor
        Found in modules/tappxBidAdapter.js - About 1 hr to fix

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

            isBidRequestValid: function(bid) {
              // bid.params.host
              if ((new RegExp(`^(vz.*|zz.*)\\.*$`, 'i')).test(bid.params.host)) { // New endpoint
                if ((new RegExp(`^(zz.*)\\.*$`, 'i')).test(bid.params.host)) return validBasic(bid)
                else return validBasic(bid) && validMediaType(bid)
          Severity: Minor
          Found in modules/tappxBidAdapter.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

          Consider simplifying this complex logical expression.
          Open

              if ((video.w === undefined || video.w == null || video.w <= 0) ||
                (video.h === undefined || video.h == null || video.h <= 0)) {
                if (!Array.isArray(videoMediaType.playerSize)) { logWarn(LOG_PREFIX, 'Video playerSize array not found.'); }
          
                w = videoMediaType.playerSize[0][0];
          Severity: Major
          Found in modules/tappxBidAdapter.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

              if (typeof eidsArr !== 'undefined') {
                eidsArr = eidsArr.filter(
                  uuid =>
                    (typeof uuid !== 'undefined' && uuid !== null) &&
                    (typeof uuid.source == 'string' && uuid.source !== null) &&
            Severity: Major
            Found in modules/tappxBidAdapter.js - About 40 mins to fix

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

                getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
                  let url = `https://${hostDomain}/cs/usersync.php?`;
              
                  // GDPR & CCPA
                  if (gdprConsent) {
              Severity: Minor
              Found in modules/tappxBidAdapter.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 getVendor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function getVendor() {
                let ua = navigator.userAgent;
                if (ua.indexOf('Chrome') != -1) { return 'Google'; } else if (ua.indexOf('Firefox') != -1) { return 'Mozilla'; } else if (ua.indexOf('Safari') != -1) { return 'Apple'; } else if (ua.indexOf('Edge') != -1) { return 'Microsoft'; } else if (ua.indexOf('MSIE') != -1 || ua.indexOf('Trident') != -1) { return 'Microsoft'; } else { return ''; }
              }
              Severity: Minor
              Found in modules/tappxBidAdapter.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

              Avoid too many return statements within this function.
              Open

                if (ua.indexOf('Chrome') != -1) { return 'Google'; } else if (ua.indexOf('Firefox') != -1) { return 'Mozilla'; } else if (ua.indexOf('Safari') != -1) { return 'Apple'; } else if (ua.indexOf('Edge') != -1) { return 'Microsoft'; } else if (ua.indexOf('MSIE') != -1 || ua.indexOf('Trident') != -1) { return 'Microsoft'; } else { return ''; }
              Severity: Major
              Found in modules/tappxBidAdapter.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  if (ua.match(/Android/)) { return 'Android'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'iOS'; } else if (ua.indexOf('Mac OS X') != -1) { return 'macOS'; } else if (ua.indexOf('Windows') != -1) { return 'Windows'; } else if (ua.indexOf('Linux') != -1) { return 'Linux'; } else { return 'Unknown'; }
                Severity: Major
                Found in modules/tappxBidAdapter.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

                      if (ua.indexOf('Chrome') != -1) { return 'Google'; } else if (ua.indexOf('Firefox') != -1) { return 'Mozilla'; } else if (ua.indexOf('Safari') != -1) { return 'Apple'; } else if (ua.indexOf('Edge') != -1) { return 'Microsoft'; } else if (ua.indexOf('MSIE') != -1 || ua.indexOf('Trident') != -1) { return 'Microsoft'; } else { return ''; }
                    Severity: Major
                    Found in modules/tappxBidAdapter.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        if (ua.match(/Android/)) { return 'Android'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'iOS'; } else if (ua.indexOf('Mac OS X') != -1) { return 'macOS'; } else if (ua.indexOf('Windows') != -1) { return 'Windows'; } else if (ua.indexOf('Linux') != -1) { return 'Linux'; } else { return 'Unknown'; }
                      Severity: Major
                      Found in modules/tappxBidAdapter.js - About 30 mins to fix

                        Function validBasic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function validBasic(bid) {
                          if (bid.params == null) {
                            logWarn(LOG_PREFIX, 'Please review the mandatory Tappx parameters.');
                            return false;
                          }
                        Severity: Minor
                        Found in modules/tappxBidAdapter.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

                        Function getOs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function getOs() {
                          let ua = navigator.userAgent;
                          if (ua.match(/Android/)) { return 'Android'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'iOS'; } else if (ua.indexOf('Mac OS X') != -1) { return 'macOS'; } else if (ua.indexOf('Windows') != -1) { return 'Windows'; } else if (ua.indexOf('Linux') != -1) { return 'Linux'; } else { return 'Unknown'; }
                        }
                        Severity: Minor
                        Found in modules/tappxBidAdapter.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

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

                        const VIDEO_CUSTOM_PARAMS = {
                          'minduration': DATA_TYPES.NUMBER,
                          'maxduration': DATA_TYPES.NUMBER,
                          'startdelay': DATA_TYPES.NUMBER,
                          'playbackmethod': DATA_TYPES.ARRAY,
                        Severity: Major
                        Found in modules/tappxBidAdapter.js and 1 other location - About 4 hrs to fix
                        modules/adtrueBidAdapter.js on lines 33..48

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

                        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

                        export function _checkParamDataType(key, value, datatype) {
                          var errMsg = 'Ignoring param key: ' + key + ', expects ' + datatype + ', found ' + typeof value;
                          var functionToExecute;
                          switch (datatype) {
                            case DATA_TYPES.BOOLEAN:
                        Severity: Major
                        Found in modules/tappxBidAdapter.js and 1 other location - About 4 hrs to fix
                        modules/pubwiseBidAdapter.js on lines 954..976

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

                        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 ((new RegExp(`^(vz.*|zz.*)\\.*$`, 'i')).test(bid.params.host)) { // New endpoint
                              if ((new RegExp(`^(zz.*)\\.*$`, 'i')).test(bid.params.host)) return validBasic(bid)
                              else return validBasic(bid) && validMediaType(bid)
                            } else { // This is backward compatible feature. It will be remove in the future
                        Severity: Major
                        Found in modules/tappxBidAdapter.js and 1 other location - About 1 hr to fix
                        modules/tappxBidAdapter.js on lines 66..69

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

                        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

                            } else { // This is backward compatible feature. It will be remove in the future
                              if ((new RegExp(`^(ZZ.*)\\.*$`, 'i')).test(bid.params.endpoint)) return validBasic(bid)
                              else return validBasic(bid) && validMediaType(bid)
                            }
                        Severity: Major
                        Found in modules/tappxBidAdapter.js and 1 other location - About 1 hr to fix
                        modules/tappxBidAdapter.js on lines 63..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 58.

                        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) {
                              url += '&gdpr_optin=' + (gdprConsent.gdprApplies ? 1 : 0);
                              url += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
                            }
                        Severity: Major
                        Found in modules/tappxBidAdapter.js and 2 other locations - About 55 mins to fix
                        modules/optidigitalBidAdapter.js on lines 172..175
                        modules/sparteoBidAdapter.js on lines 136..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 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

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

                              ((bannerMediaType.sizes[0].indexOf(480) >= 0) && (bannerMediaType.sizes[0].indexOf(320) >= 0)) ||
                        Severity: Minor
                        Found in modules/tappxBidAdapter.js and 1 other location - About 30 mins to fix
                        modules/tappxBidAdapter.js on lines 324..324

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

                        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

                              ((bannerMediaType.sizes[0].indexOf(768) >= 0) && (bannerMediaType.sizes[0].indexOf(1024) >= 0))) {
                        Severity: Minor
                        Found in modules/tappxBidAdapter.js and 1 other location - About 30 mins to fix
                        modules/tappxBidAdapter.js on lines 323..323

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

                        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