prebid/Prebid.js

View on GitHub
modules/freewheel-sspBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

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

  buildRequests: function(bidRequests, bidderRequest) {
    // var currency = config.getConfig(currency);

    let buildRequest = (currentBidRequest, bidderRequest) => {
      var zone = currentBidRequest.params.zoneId;
Severity: Minor
Found in modules/freewheel-sspBidAdapter.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

File freewheel-sspBidAdapter.js has 453 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { logWarn, isArray, isFn, deepAccess, formatQS } from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';

Severity: Minor
Found in modules/freewheel-sspBidAdapter.js - About 6 hrs to fix

    Function buildRequests has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      buildRequests: function(bidRequests, bidderRequest) {
        // var currency = config.getConfig(currency);
    
        let buildRequest = (currentBidRequest, bidderRequest) => {
          var zone = currentBidRequest.params.zoneId;
    Severity: Major
    Found in modules/freewheel-sspBidAdapter.js - About 4 hrs to fix

      Function buildRequest has 103 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          let buildRequest = (currentBidRequest, bidderRequest) => {
            var zone = currentBidRequest.params.zoneId;
            var timeInMillis = new Date().getTime();
            var keyCode = hashcode(zone + '' + timeInMillis);
            var bidfloor = getBidFloor(currentBidRequest, config);
      Severity: Major
      Found in modules/freewheel-sspBidAdapter.js - About 4 hrs to fix

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

          interpretResponse: function(serverResponse, request) {
            var bidrequest = request.bidRequest;
            var playerSize = [];
            if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) {
              // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3
        Severity: Major
        Found in modules/freewheel-sspBidAdapter.js - About 2 hrs to fix

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

            interpretResponse: function(serverResponse, request) {
              var bidrequest = request.bidRequest;
              var playerSize = [];
              if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) {
                // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3
          Severity: Minor
          Found in modules/freewheel-sspBidAdapter.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 12 (exceeds 5 allowed). Consider refactoring.
          Open

            getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy, gppConsent) {
              const params = {};
          
              if (gdprConsent) {
                if (typeof gdprConsent.gdprApplies === 'boolean') {
          Severity: Minor
          Found in modules/freewheel-sspBidAdapter.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 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy, gppConsent) {
              const params = {};
          
              if (gdprConsent) {
                if (typeof gdprConsent.gdprApplies === 'boolean') {
          Severity: Minor
          Found in modules/freewheel-sspBidAdapter.js - About 1 hr to fix

            Function getValueFromKeyInImpressionNode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getValueFromKeyInImpressionNode(xmlNode, key) {
              var value = '';
              var impNodes = xmlNode.querySelectorAll('Impression'); // Nodelist.forEach is not supported in IE and Edge
              var isRootViewKeyPresent = false;
              var isAdsDisplayStartedPresent = false;
            Severity: Minor
            Found in modules/freewheel-sspBidAdapter.js - About 1 hr to fix

              Function formatAdHTML has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function formatAdHTML(bid, size) {
                var integrationType = bid.params.format;
              
                var divHtml = '<div id="freewheelssp_prebid_target" style="width:' + size[0] + 'px;height:' + size[1] + 'px;"></div>';
              
              
              Severity: Minor
              Found in modules/freewheel-sspBidAdapter.js - About 1 hr to fix

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

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

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

                  var getOutstreamScript = function(bid) {
                    var config = bid.params;
                  
                    // default placement if no placement is set
                    if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) {
                  Severity: Minor
                  Found in modules/freewheel-sspBidAdapter.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 getBiggerSizeWithLimit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getBiggerSizeWithLimit(array, minSizeLimit, maxSizeLimit) {
                    var minSize = minSizeLimit || [0, 0];
                    var maxSize = maxSizeLimit || [Number.MAX_VALUE, Number.MAX_VALUE];
                    var candidates = [];
                  
                  
                  Severity: Minor
                  Found in modules/freewheel-sspBidAdapter.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

                      if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) {
                        // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3
                        if (isArray(bidrequest.mediaTypes.video.playerSize[0])) {
                          playerSize = bidrequest.mediaTypes.video.playerSize[0];
                        } else {
                  Severity: Major
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 1 day to fix
                  modules/freewheel-sspBidAdapter.js on lines 434..447

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

                  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 (currentBidRequest.mediaTypes.video && currentBidRequest.mediaTypes.video.playerSize) {
                          // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3
                          if (isArray(currentBidRequest.mediaTypes.video.playerSize[0])) {
                            playerSize = currentBidRequest.mediaTypes.video.playerSize[0];
                          } else {
                  Severity: Major
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 1 day to fix
                  modules/freewheel-sspBidAdapter.js on lines 491..504

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

                  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

                  function getBiggerSize(array) {
                    var result = [0, 0];
                    for (var i = 0; i < array.length; i++) {
                      if (array[i][0] * array[i][1] > result[0] * result[1]) {
                        result = array[i];
                  Severity: Major
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 3 hrs to fix
                  modules/invibesBidAdapter.js on lines 457..465

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

                  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 (gdprConsent) {
                        if (typeof gdprConsent.gdprApplies === 'boolean') {
                          params.gdpr = Number(gdprConsent.gdprApplies);
                          params.gdpr_consent = gdprConsent.consentString;
                        } else {
                  Severity: Major
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/datablocksBidAdapter.js on lines 438..445

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

                  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

                  function getTopMostWindow() {
                    var res = window;
                  
                    try {
                      while (top !== res) {
                  Severity: Major
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/invibesBidAdapter.js on lines 467..480

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

                  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

                    Array.prototype.forEach.call(extensions, function(node) {
                      if (node.getAttribute('type') === 'StickyPricing') {
                        pricingExtNode = node;
                      }
                    });
                  Severity: Minor
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 50 mins to fix
                  modules/freewheel-sspBidAdapter.js on lines 104..108

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

                  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

                    Array.prototype.forEach.call(extensions, function(node) {
                      if (node.getAttribute('type') === 'StickyBrand') {
                        brandExtNode = node;
                      }
                    });
                  Severity: Minor
                  Found in modules/freewheel-sspBidAdapter.js and 1 other location - About 50 mins to fix
                  modules/freewheel-sspBidAdapter.js on lines 69..73

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

                  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