prebid/Prebid.js

View on GitHub
modules/beachfrontBidAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

File beachfrontBidAdapter.js has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  deepAccess,
  deepClone,
  deepSetValue,
  getUniqueIdentifierStr,
Severity: Minor
Found in modules/beachfrontBidAdapter.js - About 6 hrs to fix

    Function createVideoRequestData has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createVideoRequestData(bid, bidderRequest) {
      let sizes = getVideoSizes(bid);
      let firstSize = getFirstSize(sizes);
      let video = getVideoTargetingParams(bid);
      let appId = getVideoBidParam(bid, 'appId');
    Severity: Major
    Found in modules/beachfrontBidAdapter.js - About 2 hrs to fix

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

        interpretResponse(response, { bidRequest }) {
          response = response.body;
      
          if (isVideoBid(bidRequest)) {
            if (!response || !response.bidPrice) {
      Severity: Major
      Found in modules/beachfrontBidAdapter.js - About 2 hrs to fix

        Function createBannerRequestData has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function createBannerRequestData(bids, bidderRequest) {
          let topLocation = getTopWindowLocation(bidderRequest);
          let topReferrer = bidderRequest.refererInfo?.ref;
          let slots = bids.map(bid => {
            return {
        Severity: Minor
        Found in modules/beachfrontBidAdapter.js - About 2 hrs to fix

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

          function createVideoRequestData(bid, bidderRequest) {
            let sizes = getVideoSizes(bid);
            let firstSize = getFirstSize(sizes);
            let video = getVideoTargetingParams(bid);
            let appId = getVideoBidParam(bid, 'appId');
          Severity: Minor
          Found in modules/beachfrontBidAdapter.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            interpretResponse(response, { bidRequest }) {
              response = response.body;
          
              if (isVideoBid(bidRequest)) {
                if (!response || !response.bidPrice) {
          Severity: Minor
          Found in modules/beachfrontBidAdapter.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 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = {}) {
              let { gdprApplies, consentString = '' } = gdprConsent;
              let { gppString = '', applicableSections = [] } = gppConsent;
              let bannerResponse = find(serverResponses, (res) => isArray(res.body));
          
          
          Severity: Minor
          Found in modules/beachfrontBidAdapter.js - About 1 hr to fix

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

              isBidRequestValid(bid) {
                if (isVideoBid(bid)) {
                  if (!getVideoBidParam(bid, 'appId')) {
                    logWarn('Beachfront: appId param is required for video bids.');
                    return false;
            Severity: Minor
            Found in modules/beachfrontBidAdapter.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 createBannerRequestData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function createBannerRequestData(bids, bidderRequest) {
              let topLocation = getTopWindowLocation(bidderRequest);
              let topReferrer = bidderRequest.refererInfo?.ref;
              let slots = bids.map(bid => {
                return {
            Severity: Minor
            Found in modules/beachfrontBidAdapter.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 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = {}) {
            Severity: Minor
            Found in modules/beachfrontBidAdapter.js - About 35 mins to fix

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

                getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = {}) {
                  let { gdprApplies, consentString = '' } = gdprConsent;
                  let { gppString = '', applicableSections = [] } = gppConsent;
                  let bannerResponse = find(serverResponses, (res) => isArray(res.body));
              
              
              Severity: Minor
              Found in modules/beachfrontBidAdapter.js - About 35 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Avoid too many return statements within this function.
              Open

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

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

                function getOsVersion() {
                  let clientStrings = [
                    { s: 'Android', r: /Android/ },
                    { s: 'iOS', r: /(iPhone|iPad|iPod)/ },
                    { s: 'Mac OS X', r: /Mac OS X/ },
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 2 other locations - About 1 day to fix
                modules/advangelistsBidAdapter.js on lines 158..177
                modules/saambaaBidAdapter.js on lines 162..181

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

                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 getVideoTargetingParams(bid) {
                  const result = {};
                  const excludeProps = ['playerSize', 'context', 'w', 'h'];
                  Object.keys(Object(bid.mediaTypes.video))
                    .filter(key => !includes(excludeProps, key))
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 2 other locations - About 7 hrs to fix
                modules/advangelistsBidAdapter.js on lines 205..219
                modules/saambaaBidAdapter.js on lines 213..227

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

                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 parseSizes(sizes) {
                  return parseSizesInput(sizes).map(size => {
                    let [ width, height ] = size.split('x');
                    return {
                      w: parseInt(width, 10) || undefined,
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 2 other locations - About 2 hrs to fix
                modules/advangelistsBidAdapter.js on lines 183..191
                modules/saambaaBidAdapter.js on lines 187..195

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

                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 getVideoBidFloor(bid) {
                  let floorInfo = isFn(bid.getFloor) ? bid.getFloor({ currency: CURRENCY, mediaType: 'video', size: '*' }) : {};
                  return floorInfo.floor || getVideoBidParam(bid, 'bidfloor');
                }
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 1 other location - About 1 hr to fix
                modules/beachfrontBidAdapter.js on lines 301..304

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

                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 getBannerBidFloor(bid) {
                  let floorInfo = isFn(bid.getFloor) ? bid.getFloor({ currency: CURRENCY, mediaType: 'banner', size: '*' }) : {};
                  return floorInfo.floor || getBannerBidParam(bid, 'bidfloor');
                }
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 1 other location - About 1 hr to fix
                modules/beachfrontBidAdapter.js on lines 306..309

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

                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 (isVideoBid(bid)) {
                      if (!getVideoBidParam(bid, 'appId')) {
                        logWarn('Beachfront: appId param is required for video bids.');
                        return false;
                      }
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 1 other location - About 1 hr to fix
                modules/beachfrontBidAdapter.js on lines 56..65

                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

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

                    if (isBannerBid(bid)) {
                      if (!getBannerBidParam(bid, 'appId')) {
                        logWarn('Beachfront: appId param is required for banner bids.');
                        return false;
                      }
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 1 other location - About 1 hr to fix
                modules/beachfrontBidAdapter.js on lines 46..55

                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

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

                function getDoNotTrack() {
                  return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNoTrack === '1' || navigator.doNotTrack === 'yes';
                }
                Severity: Major
                Found in modules/beachfrontBidAdapter.js and 3 other locations - About 1 hr to fix
                modules/advangelistsBidAdapter.js on lines 144..146
                modules/saambaaBidAdapter.js on lines 148..150
                src/utils.js on lines 771..773

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

                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