prebid/Prebid.js

View on GitHub
modules/underdogmediaBidAdapter.js

Summary

Maintainability
F
5 days
Test Coverage

File underdogmediaBidAdapter.js has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  deepAccess,
  flatten,
  getWindowSelf,
  getWindowTop,
Severity: Minor
Found in modules/underdogmediaBidAdapter.js - About 4 hrs to fix

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

      buildRequests: function (validBidRequests, bidderRequest) {
        var sizes = [];
        var siteId = 0;
    
        let data = {
    Severity: Major
    Found in modules/underdogmediaBidAdapter.js - About 2 hrs to fix

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

        buildRequests: function (validBidRequests, bidderRequest) {
          var sizes = [];
          var siteId = 0;
      
          let data = {
      Severity: Minor
      Found in modules/underdogmediaBidAdapter.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        interpretResponse: function (serverResponse, bidRequest) {
          const bidResponses = [];
          const mids = serverResponse.body.mids
          mids.forEach(mid => {
            const bidParam = bidRequest.bidParams.find((bidParam) => {
      Severity: Minor
      Found in modules/underdogmediaBidAdapter.js - About 1 hr to fix

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

          isBidRequestValid: function (bid) {
            if (!bid.params) {
              logWarn('[Underdog Media] bid params are missing')
              return false;
            }
        Severity: Minor
        Found in modules/underdogmediaBidAdapter.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, serverResponses) {
            if (!USER_SYNCED && serverResponses.length > 0 && serverResponses[0].body && serverResponses[0].body.userSyncs && serverResponses[0].body.userSyncs.length > 0) {
              USER_SYNCED = true;
              const userSyncs = serverResponses[0].body.userSyncs;
              const syncs = userSyncs.filter(sync => {
        Severity: Minor
        Found in modules/underdogmediaBidAdapter.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

        Avoid too many return statements within this function.
        Open

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

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

          function _mapAdUnitPathToElementId(adUnitCode) {
            if (isGptPubadsDefined()) {
              // eslint-disable-next-line no-undef
              const adSlots = googletag.pubads().getSlots();
              const isMatchingAdSlot = isSlotMatchingAdUnitCode(adUnitCode);
          Severity: Minor
          Found in modules/underdogmediaBidAdapter.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 4 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/underdogmediaBidAdapter.js and 3 other locations - About 1 day to fix
          libraries/percentInView/percentInView.js on lines 15..40
          modules/marsmediaBidAdapter.js on lines 412..440
          modules/onomagicBidAdapter.js on lines 204..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 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

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

          function _getPercentInView(element, topWin, {
            w,
            h
          } = {}) {
            const elementBoundingBox = _getBoundingBox(element, {
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 1 other location - About 7 hrs to fix
          modules/onomagicBidAdapter.js on lines 234..258

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

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

          function _getBoundingBox(element, {
            w,
            h
          } = {}) {
            let {
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 3 other locations - About 6 hrs to fix
          libraries/percentInView/percentInView.js on lines 2..13
          modules/marsmediaBidAdapter.js on lines 399..410
          modules/onomagicBidAdapter.js on lines 191..202

          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

          function _getViewability(element, topWin, {
            w,
            h
          } = {}) {
            return topWin.document.visibilityState === 'visible'
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 1 other location - About 1 hr to fix
          modules/marsmediaBidAdapter.js on lines 370..374

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

                let bidParamSizes = bidParam.mediaTypes && bidParam.mediaTypes.banner && bidParam.mediaTypes.banner.sizes ? bidParam.mediaTypes.banner.sizes : bidParam.sizes;
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 1 other location - About 1 hr to fix
          modules/underdogmediaBidAdapter.js on lines 58..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 61.

          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

              const bidSizes = bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? bid.mediaTypes.banner.sizes : bid.sizes;
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 1 other location - About 1 hr to fix
          modules/underdogmediaBidAdapter.js on lines 89..89

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

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

          function _getMinSize(bidParamSizes) {
            return bidParamSizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min)
          }
          Severity: Major
          Found in modules/underdogmediaBidAdapter.js and 4 other locations - About 1 hr to fix
          modules/marsmediaBidAdapter.js on lines 354..356
          modules/medianetBidAdapter.js on lines 291..293
          modules/omsBidAdapter.js on lines 265..267
          modules/onomagicBidAdapter.js on lines 187..189

          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

          There are no issues that match your filters.

          Category
          Status