prebid/Prebid.js

View on GitHub
modules/luponmediaBidAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

File luponmediaBidAdapter.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  _each,
  deepAccess,
  deepSetValue,
  generateUUID,
Severity: Major
Found in modules/luponmediaBidAdapter.js - About 1 day to fix

    Function newOrtbBidRequest has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
      bidRequest.startTime = new Date().getTime();
    
      const bannerParams = deepAccess(bidRequest, 'mediaTypes.banner');
    
    
    Severity: Minor
    Found in modules/luponmediaBidAdapter.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

    Function newOrtbBidRequest has 156 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
      bidRequest.startTime = new Date().getTime();
    
      const bannerParams = deepAccess(bidRequest, 'mediaTypes.banner');
    
    
    Severity: Major
    Found in modules/luponmediaBidAdapter.js - About 6 hrs to fix

      Function getUserSyncs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
          let allUserSyncs = [];
          if (!hasSynced && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) {
            responses.forEach(csResp => {
              if (csResp.body && csResp.body.ext && csResp.body.ext.usersyncs) {
      Severity: Minor
      Found in modules/luponmediaBidAdapter.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

              if (response.body && response.body.seatbid && isArray(response.body.seatbid)) {
                // Supporting multiple bid responses for same adSize
                respCur = response.body.cur || respCur;
                response.body.seatbid.forEach(seatbidder => {
                  seatbidder.bid &&
        Severity: Critical
        Found in modules/luponmediaBidAdapter.js - About 1 hr to fix

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

            interpretResponse: (response, request) => {
              const bidResponses = [];
              var respCur = 'USD';
              let parsedRequest = JSON.parse(request.data);
              let parsedReferrer = parsedRequest.site && parsedRequest.site.ref ? parsedRequest.site.ref : '';
          Severity: Minor
          Found in modules/luponmediaBidAdapter.js - About 1 hr to fix

            Function _getDigiTrustQueryParams has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function _getDigiTrustQueryParams(bidRequest = {}, endpointName) {
              if (!endpointName || !DIGITRUST_PROP_NAMES[endpointName]) {
                return null;
              }
              const propNames = DIGITRUST_PROP_NAMES[endpointName];
            Severity: Minor
            Found in modules/luponmediaBidAdapter.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 parseSizes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function parseSizes(bid, mediaType) {
              let params = bid.params;
              if (mediaType === 'video') {
                let size = [];
                if (params.video && params.video.playerWidth && params.video.playerHeight) {
            Severity: Minor
            Found in modules/luponmediaBidAdapter.js - About 1 hr to fix

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

              function parseSizes(bid, mediaType) {
                let params = bid.params;
                if (mediaType === 'video') {
                  let size = [];
                  if (params.video && params.video.playerWidth && params.video.playerHeight) {
              Severity: Minor
              Found in modules/luponmediaBidAdapter.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

              Avoid deeply nested control flow statements.
              Open

                              if (!url) {
                                logError(`No sync url for bidder luponmedia.`);
                              } else if ((type === 'image' || type === 'redirect') && syncOptions.pixelEnabled) {
                                logMessage(`Invoking image pixel user sync for luponmedia`);
                                allUserSyncs.push({type: 'image', url: url});
              Severity: Major
              Found in modules/luponmediaBidAdapter.js - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (bidRequest.userId && typeof bidRequest.userId === 'object' &&
                        (bidRequest.userId.tdid || bidRequest.userId.pubcid || bidRequest.userId.lipb || bidRequest.userId.idl_env)) {
                    deepSetValue(data, 'user.ext.eids', []);
                
                    if (bidRequest.userId.tdid) {
                Severity: Major
                Found in modules/luponmediaBidAdapter.js - About 40 mins to fix

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

                    if (mediaType === 'video') {
                      let size = [];
                      if (params.video && params.video.playerWidth && params.video.playerHeight) {
                        size = [
                          params.video.playerWidth,
                  Severity: Major
                  Found in modules/luponmediaBidAdapter.js and 2 other locations - About 1 day to fix
                  modules/gothamadsBidAdapter.js on lines 307..320
                  modules/rubiconBidAdapter.js on lines 876..889

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

                  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

                  export function masSizeOrdering(sizes) {
                    const MAS_SIZE_PRIORITY = [15, 2, 9];
                  
                    return sizes.sort((first, second) => {
                      // sort by MAS_SIZE_PRIORITY priority order
                  Severity: Major
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 5 hrs to fix
                  modules/rubiconBidAdapter.js on lines 1173..1194

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

                  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 (Array.isArray(params.sizes)) {
                      sizes = params.sizes;
                    } else if (typeof deepAccess(bid, 'mediaTypes.banner.sizes') !== 'undefined') {
                      sizes = mapSizes(bid.mediaTypes.banner.sizes);
                    } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) {
                  Severity: Major
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 4 hrs to fix
                  modules/rubiconBidAdapter.js on lines 893..901

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

                  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 mapSizes(sizes) {
                    return parseSizesInput(sizes)
                      // map sizes while excluding non-matches
                      .reduce((result, size) => {
                        let mappedSize = parseInt(sizeMap[size], 10);
                  Severity: Major
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/rubiconBidAdapter.js on lines 1078..1088

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

                  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 (bidRequest.userId.pubcid) {
                        data.user.ext.eids.push({
                          source: 'pubcommon',
                          uids: [{
                            id: bidRequest.userId.pubcid,
                  Severity: Minor
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 55 mins to fix
                  modules/luponmediaBidAdapter.js on lines 428..435

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

                  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 (bidRequest.userId.idl_env) {
                        data.user.ext.eids.push({
                          source: 'liveramp.com',
                          uids: [{
                            id: bidRequest.userId.idl_env
                  Severity: Minor
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 55 mins to fix
                  modules/luponmediaBidAdapter.js on lines 399..406

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

                  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

                          (bidRequest.userId.tdid || bidRequest.userId.pubcid || bidRequest.userId.lipb || bidRequest.userId.idl_env)) {
                  Severity: Minor
                  Found in modules/luponmediaBidAdapter.js and 1 other location - About 30 mins to fix
                  modules/consumableBidAdapter.js on lines 30..30

                  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