prebid/Prebid.js

View on GitHub
modules/nextMillenniumBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

File nextMillenniumBidAdapter.js has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  _each,
  createTrackPixelHtml,
  deepAccess,
  deepSetValue,
Severity: Minor
Found in modules/nextMillenniumBidAdapter.js - About 6 hrs to fix

    Function setConsentStrings has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    export function setConsentStrings(postBody = {}, bidderRequest) {
      const gdprConsent = bidderRequest?.gdprConsent;
      const uspConsent = bidderRequest?.uspConsent;
      let gppConsent = bidderRequest?.gppConsent?.gppString && bidderRequest?.gppConsent;
      if (!gppConsent && bidderRequest?.ortb2?.regs?.gpp) gppConsent = bidderRequest?.ortb2?.regs;
    Severity: Minor
    Found in modules/nextMillenniumBidAdapter.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 buildRequests has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      buildRequests: function(validBidRequests, bidderRequest) {
        const requests = [];
        window.nmmRefreshCounts = window.nmmRefreshCounts || {};
    
        _each(validBidRequests, (bid) => {
    Severity: Major
    Found in modules/nextMillenniumBidAdapter.js - About 2 hrs to fix

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

        _getUrlPixelMetric(eventName, bid) {
          const bidder = bid.bidder || bid.bidderCode;
          if (bidder != BIDDER_CODE) return;
      
          let params;
      Severity: Minor
      Found in modules/nextMillenniumBidAdapter.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 interpretResponse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        interpretResponse: function(serverResponse, bidRequest) {
          const response = serverResponse.body;
          const bidResponses = [];
      
          _each(response.seatbid, (resp) => {
      Severity: Minor
      Found in modules/nextMillenniumBidAdapter.js - About 1 hr to fix

        Function getCurrency has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function getCurrency(bid = {}) {
          const currency = config?.getConfig('currency')?.adServerCurrency || DEFAULT_CURRENCY;
          const cur = [];
          const types = ['banner', 'video'];
          const mediaTypes = {};
        Severity: Minor
        Found in modules/nextMillenniumBidAdapter.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 getAd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        function getAd(bid) {
          let ad, adUrl, vastXml, vastUrl;
        
          switch (deepAccess(bid, 'ext.prebid.type')) {
            case VIDEO:
        Severity: Minor
        Found in modules/nextMillenniumBidAdapter.js - About 55 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
            if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) return [];
        
            const pixels = [];
            const getSetPixelFunc = type => url => { pixels.push({type, url: replaceUsersyncMacros(url, gdprConsent, uspConsent, gppConsent, type)}) };
        Severity: Minor
        Found in modules/nextMillenniumBidAdapter.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 replaceUsersyncMacros has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export function replaceUsersyncMacros(url, gdprConsent = {}, uspConsent = '', gppConsent = {}, type = '') {
        Severity: Minor
        Found in modules/nextMillenniumBidAdapter.js - About 35 mins to fix

          Function getUserSyncs has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

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

            export function getImpVideo(imp, video) {
              if (!video) return;
            
              if (video.bidfloorcur) imp.bidfloorcur = video.bidfloorcur;
              if (video.bidfloor) imp.bidfloor = video.bidfloor;
            Severity: Minor
            Found in modules/nextMillenniumBidAdapter.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 getPlacementId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function getPlacementId(bid) {
              const groupId = getBidIdParameter('group_id', bid.params);
              const placementId = getBidIdParameter('placement_id', bid.params);
              if (!groupId) return placementId;
            
            
            Severity: Minor
            Found in modules/nextMillenniumBidAdapter.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

              switch (deepAccess(bid, 'ext.prebid.type')) {
                case VIDEO:
                  if (bid.adm.substr(0, 4) === 'http') {
                    vastUrl = bid.adm;
                  } else {
            Severity: Major
            Found in modules/nextMillenniumBidAdapter.js and 1 other location - About 6 hrs to fix
            modules/bridBidAdapter.js on lines 192..209

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

            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 (gdprConsent) {
                  if (typeof gdprConsent.gdprApplies !== 'undefined') {
                    postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0;
                  };
            
            
            Severity: Major
            Found in modules/nextMillenniumBidAdapter.js and 1 other location - About 3 hrs to fix
            modules/bridBidAdapter.js on lines 99..109

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

            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 (vastUrl || vastXml) {
                      bidResponse.mediaType = VIDEO;
            
                      if (vastUrl) bidResponse.vastUrl = vastUrl;
                      if (vastXml) bidResponse.vastXml = vastXml;
            Severity: Major
            Found in modules/nextMillenniumBidAdapter.js and 1 other location - About 2 hrs to fix
            modules/bridBidAdapter.js on lines 165..172

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

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

              } else if (video.data.w && video.data.h) {
                imp.video.w = video.data.w;
                imp.video.h = video.data.h;
              };
            Severity: Major
            Found in modules/nextMillenniumBidAdapter.js and 6 other locations - About 45 mins to fix
            modules/dspxBidAdapter.js on lines 75..78
            modules/exadsBidAdapter.js on lines 131..134
            modules/pubmaticBidAdapter.js on lines 998..1001
            modules/radsBidAdapter.js on lines 178..186
            modules/sharethroughBidAdapter.js on lines 87..93
            modules/trafficgateBidAdapter.js on lines 55..58

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

            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

                w: window.innerWidth || window.document.documentElement.clientWidth || window.document.body.clientWidth || 0,
            Severity: Minor
            Found in modules/nextMillenniumBidAdapter.js and 1 other location - About 30 mins to fix
            modules/nextMillenniumBidAdapter.js on lines 508..508

            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

                h: window.innerHeight || window.document.documentElement.clientHeight || window.document.body.clientHeight || 0,
            Severity: Minor
            Found in modules/nextMillenniumBidAdapter.js and 1 other location - About 30 mins to fix
            modules/nextMillenniumBidAdapter.js on lines 507..507

            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