prebid/Prebid.js

View on GitHub
modules/smartxBidAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

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

  buildRequests: function (bidRequests, bidderRequest) {
    const page = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
    const isPageSecure = !!page.match(/^https:/)

    const smartxRequests = bidRequests.map(function (bid) {
Severity: Major
Found in modules/smartxBidAdapter.js - About 6 hrs to fix

    Function smartxRequests has 161 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const smartxRequests = bidRequests.map(function (bid) {
          const tagId = getBidIdParameter('tagId', bid.params);
          const publisherId = getBidIdParameter('publisherId', bid.params);
          const bidfloor = getBidFloor(bid) || 0;
          const bidfloorcur = getBidIdParameter('bidfloorcur', bid.params) || 'EUR';
    Severity: Major
    Found in modules/smartxBidAdapter.js - About 6 hrs to fix

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

        buildRequests: function (bidRequests, bidderRequest) {
          const page = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
          const isPageSecure = !!page.match(/^https:/)
      
          const smartxRequests = bidRequests.map(function (bid) {
      Severity: Minor
      Found in modules/smartxBidAdapter.js - About 6 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      File smartxBidAdapter.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {
        logError,
        deepAccess,
        isArray,
        getDNT,
      Severity: Minor
      Found in modules/smartxBidAdapter.js - About 5 hrs to fix

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

          interpretResponse: function (serverResponse, bidderRequest) {
            const bidResponses = [];
            const serverResponseBody = serverResponse.body;
            if (serverResponseBody && isArray(serverResponseBody.seatbid)) {
              _each(serverResponseBody.seatbid, function (bids) {
        Severity: Major
        Found in modules/smartxBidAdapter.js - About 2 hrs to fix

          Function createOutstreamConfig has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          function createOutstreamConfig(bid) {
            let confMinAdWidth = getBidIdParameter('minAdWidth', bid.renderer.config.outstream_options) || 290;
            let confMaxAdWidth = getBidIdParameter('maxAdWidth', bid.renderer.config.outstream_options) || 900;
            let confStartOpen = getBidIdParameter('startOpen', bid.renderer.config.outstream_options)
            let confEndingScreen = getBidIdParameter('endingScreen', bid.renderer.config.outstream_options)
          Severity: Minor
          Found in modules/smartxBidAdapter.js - About 2 hrs to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function createOutstreamConfig has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createOutstreamConfig(bid) {
            let confMinAdWidth = getBidIdParameter('minAdWidth', bid.renderer.config.outstream_options) || 290;
            let confMaxAdWidth = getBidIdParameter('maxAdWidth', bid.renderer.config.outstream_options) || 900;
            let confStartOpen = getBidIdParameter('startOpen', bid.renderer.config.outstream_options)
            let confEndingScreen = getBidIdParameter('endingScreen', bid.renderer.config.outstream_options)
          Severity: Major
          Found in modules/smartxBidAdapter.js - About 2 hrs to fix

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

              isBidRequestValid: function (bid) {
                if (bid && typeof bid.params !== 'object') {
                  logError(BIDDER_CODE + ': params is not defined or is incorrect in the bidder settings.');
                  return false;
                }
            Severity: Minor
            Found in modules/smartxBidAdapter.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 isBidRequestValid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              isBidRequestValid: function (bid) {
                if (bid && typeof bid.params !== 'object') {
                  logError(BIDDER_CODE + ': params is not defined or is incorrect in the bidder settings.');
                  return false;
                }
            Severity: Minor
            Found in modules/smartxBidAdapter.js - About 1 hr to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

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

                      Avoid too many return statements within this function.
                      Open

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

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

                              const device = {
                                h: screen.height,
                                w: screen.width,
                                dnt: getDNT() ? 1 : 0,
                                language: navigator[language].split('-')[0],
                        Severity: Major
                        Found in modules/smartxBidAdapter.js and 1 other location - About 2 hrs to fix
                        modules/spotxBidAdapter.js on lines 231..238

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

                        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

                                  _each(currentBidRequest.params.pre_market_bids, function (pmb) {
                                    if (pmb.deal_id == smartxBid.id) {
                                      smartxBid.price = pmb.price;
                                      serverResponseBody.cur = pmb.currency;
                                    }
                        Severity: Major
                        Found in modules/smartxBidAdapter.js and 1 other location - About 1 hr to fix
                        modules/spotxBidAdapter.js on lines 350..355

                        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

                                  for (let i in bidderRequest.bidRequest.bids) {
                                    if (smartxBid.impid == bidderRequest.bidRequest.bids[i].bidId) {
                                      currentBidRequest = bidderRequest.bidRequest.bids[i];
                                    }
                                  }
                        Severity: Major
                        Found in modules/smartxBidAdapter.js and 1 other location - About 1 hr to fix
                        modules/spotxBidAdapter.js on lines 340..344

                        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

                            if (deepAccess(bid, 'mediaTypes.video.context') === 'outstream') {
                              if (!getBidIdParameter('outstream_options', bid.params)) {
                                logError(BIDDER_CODE + ': outstream_options parameter is not defined');
                                return false;
                              }
                        Severity: Major
                        Found in modules/smartxBidAdapter.js and 1 other location - About 1 hr to fix
                        modules/spotxBidAdapter.js on lines 70..79

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

                        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 (smartxBid && smartxBid.adomain && smartxBid.adomain.length > 0) {
                                    bid.meta.advertiserDomains = smartxBid.adomain;
                                  }
                        Severity: Minor
                        Found in modules/smartxBidAdapter.js and 1 other location - About 45 mins to fix
                        modules/spotxBidAdapter.js on lines 380..382

                        Duplicated Code

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

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

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

                        Tuning

                        This issue has a mass of 50.

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

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

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

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

                        Refactorings

                        Further Reading

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

                              if (bid && bid.schain) {
                                requestPayload['source'] = {
                                  ext: {
                                    schain: bid.schain
                                  }
                        Severity: Minor
                        Found in modules/smartxBidAdapter.js and 1 other location - About 35 mins to fix
                        modules/spotxBidAdapter.js on lines 302..308

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

                        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 (confEndingScreen == 'true') {
                            playerConfig.endingScreen = true;
                          } else if (confEndingScreen == 'false') {
                            playerConfig.endingScreen = false;
                          }
                        Severity: Minor
                        Found in modules/smartxBidAdapter.js and 1 other location - About 30 mins to fix
                        modules/smartxBidAdapter.js on lines 398..402

                        Duplicated Code

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

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

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

                        Tuning

                        This issue has a mass of 45.

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

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

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

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

                        Refactorings

                        Further Reading

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

                          if (confStartOpen == 'true') {
                            playerConfig.startOpen = true;
                          } else if (confStartOpen == 'false') {
                            playerConfig.startOpen = false;
                          }
                        Severity: Minor
                        Found in modules/smartxBidAdapter.js and 1 other location - About 30 mins to fix
                        modules/smartxBidAdapter.js on lines 404..408

                        Duplicated Code

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

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

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

                        Tuning

                        This issue has a mass of 45.

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

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

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

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

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status