prebid/Prebid.js

View on GitHub
modules/marsmediaBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

Function MarsmediaAdapter has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring.
Open

function MarsmediaAdapter() {
  this.code = 'marsmedia';
  this.aliases = ['mars'];
  this.supportedMediaTypes = [VIDEO, BANNER];

Severity: Minor
Found in modules/marsmediaBidAdapter.js - About 2 days 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 MarsmediaAdapter has 360 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function MarsmediaAdapter() {
  this.code = 'marsmedia';
  this.aliases = ['mars'];
  this.supportedMediaTypes = [VIDEO, BANNER];

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

    File marsmediaBidAdapter.js has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    'use strict';
    import { deepAccess, getDNT, parseSizesInput, isArray, getWindowTop, deepSetValue, triggerPixel, getWindowSelf } from '../src/utils.js';
    import {registerBidder} from '../src/adapters/bidderFactory.js';
    import { BANNER, VIDEO } from '../src/mediaTypes.js';
    Severity: Minor
    Found in modules/marsmediaBidAdapter.js - About 4 hrs to fix

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

        this.interpretResponse = function (serverResponse) {
          let responses = serverResponse.body || [];
          let bids = [];
          let i = 0;
      
      
      Severity: Minor
      Found in modules/marsmediaBidAdapter.js - About 1 hr to fix

        Function frameImp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function frameImp(BRs, bidderRequest) {
            var impList = [];
            var isSecure = 0;
            if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.stack.length) {
              // clever trick to get the protocol
        Severity: Minor
        Found in modules/marsmediaBidAdapter.js - About 1 hr to fix

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

            function frameBid(BRs, bidderRequest) {
              let bid = {
                id: BRs[0].bidderRequestId,
                imp: frameImp(BRs, bidderRequest),
                site: frameSite(bidderRequest),
          Severity: Minor
          Found in modules/marsmediaBidAdapter.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if ((bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes)) {
                  let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes;
                  bidSizes = ((isArray(bidSizes) && isArray(bidSizes[0])) ? bidSizes : [bidSizes]);
                  bidSizes = bidSizes.filter(size => isArray(size));
                  const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)}));
            Severity: Major
            Found in modules/marsmediaBidAdapter.js - About 1 hr to fix

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

                function _getIntersectionOfRects(rects) {
                  const bbox = {
                    left: rects[0].left,
                    right: rects[0].right,
                    top: rects[0].top,
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 6 other locations - About 1 day to fix
              libraries/percentInView/percentInView.js on lines 15..40
              modules/33acrossBidAdapter.js on lines 587..615
              modules/brightcomBidAdapter.js on lines 231..259
              modules/brightcomSSPBidAdapter.js on lines 257..282
              modules/onomagicBidAdapter.js on lines 204..232
              modules/underdogmediaBidAdapter.js on lines 335..363

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

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                function frameVideo(bid) {
                  var size = [];
                  if (deepAccess(bid, 'mediaTypes.video.playerSize')) {
                    var dimensionSet = bid.mediaTypes.video.playerSize;
                    if (isArray(bid.mediaTypes.video.playerSize[0])) {
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 1 day to fix
              modules/rhythmoneBidAdapter.js on lines 117..140

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

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                function frameBanner(adUnit) {
                  // adUnit.sizes is scheduled to be deprecated, continue its support but prefer adUnit.mediaTypes.banner
                  var sizeList = adUnit.sizes;
                  if (adUnit.mediaTypes && adUnit.mediaTypes.banner) {
                    sizeList = adUnit.mediaTypes.banner.sizes;
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 7 hrs to fix
              modules/rhythmoneBidAdapter.js on lines 89..115

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 186.

              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

                function _getBoundingBox(element, { w, h } = {}) {
                  let { width, height, left, top, right, bottom } = element.getBoundingClientRect();
              
                  if ((width === 0 || height === 0) && w && h) {
                    width = w;
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 6 other locations - About 6 hrs to fix
              libraries/percentInView/percentInView.js on lines 2..13
              modules/33acrossBidAdapter.js on lines 574..585
              modules/brightcomBidAdapter.js on lines 218..229
              modules/brightcomSSPBidAdapter.js on lines 244..255
              modules/onomagicBidAdapter.js on lines 191..202
              modules/underdogmediaBidAdapter.js on lines 305..333

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

              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 (responses.seatbid) {
                    let temp = [];
                    for (i = 0; i < responses.seatbid.length; i++) {
                      for (let j = 0; j < responses.seatbid[i].bid.length; j++) {
                        temp.push(responses.seatbid[i].bid[j]);
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 4 hrs to fix
              modules/rhythmoneBidAdapter.js on lines 224..232

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

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                function getFirstParam(key, validBidRequests) {
                  for (let i = 0; i < validBidRequests.length; i++) {
                    if (validBidRequests[i].params && validBidRequests[i].params[key]) {
                      return validBidRequests[i].params[key];
                    }
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 2 hrs to fix
              modules/rhythmoneBidAdapter.js on lines 181..187

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

              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 getValidSizeSet(dimensionList) {
                  let w = parseInt(dimensionList[0]);
                  let h = parseInt(dimensionList[1]);
                  // clever check for NaN
                  if (! (w !== w || h !== h)) {  // eslint-disable-line
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 2 hrs to fix
              modules/rhythmoneBidAdapter.js on lines 79..87

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

              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(BRs[i], 'mediaTypes.banner') || deepAccess(BRs[i], 'mediaType') === 'banner') {
                      let banner = frameBanner(BRs[i]);
                      if (banner) {
                        impObj.banner = banner;
                      }
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 1 hr to fix
              modules/rhythmoneBidAdapter.js on lines 45..50

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

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

                function _getViewability(element, topWin, { w, h } = {}) {
                  return topWin.document.visibilityState === 'visible'
                    ? _getPercentInView(element, topWin, { w, h })
                    : 0;
                }
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 2 other locations - About 1 hr to fix
              modules/33acrossBidAdapter.js on lines 537..541
              modules/underdogmediaBidAdapter.js on lines 260..270

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

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

                function _getMinSize(sizes) {
                  return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min);
                }
              Severity: Major
              Found in modules/marsmediaBidAdapter.js and 7 other locations - About 1 hr to fix
              modules/33acrossBidAdapter.js on lines 570..572
              modules/brightcomBidAdapter.js on lines 214..216
              modules/brightcomSSPBidAdapter.js on lines 240..242
              modules/medianetBidAdapter.js on lines 293..295
              modules/omsBidAdapter.js on lines 265..267
              modules/onomagicBidAdapter.js on lines 187..189
              modules/underdogmediaBidAdapter.js on lines 217..219

              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

                    if (deepAccess(BRs[i], 'mediaTypes.video') || deepAccess(BRs[i], 'mediaType') === 'video') {
                      impObj.video = frameVideo(BRs[i]);
                    }
              Severity: Minor
              Found in modules/marsmediaBidAdapter.js and 1 other location - About 50 mins to fix
              modules/rhythmoneBidAdapter.js on lines 51..53

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

              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