prebid/Prebid.js

View on GitHub
modules/gumgumBidAdapter.js

Summary

Maintainability
F
5 days
Test Coverage

File gumgumBidAdapter.js has 522 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {_each, deepAccess, logError, logWarn, parseSizesInput} from '../src/utils.js';

import {config} from '../src/config.js';
import {getStorageManager} from '../src/storageManager.js';
Severity: Major
Found in modules/gumgumBidAdapter.js - About 1 day to fix

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

    function buildRequests(validBidRequests, bidderRequest) {
      const bids = [];
      const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
      const uspConsent = bidderRequest && bidderRequest.uspConsent;
      const gppConsent = bidderRequest && bidderRequest.gppConsent;
    Severity: Major
    Found in modules/gumgumBidAdapter.js - About 5 hrs to fix

      Function interpretResponse has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      function interpretResponse(serverResponse, bidRequest) {
        const bidResponses = []
        const serverResponseBody = serverResponse.body
      
        if (!serverResponseBody || serverResponseBody.err) {
      Severity: Minor
      Found in modules/gumgumBidAdapter.js - About 3 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 interpretResponse has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function interpretResponse(serverResponse, bidRequest) {
        const bidResponses = []
        const serverResponseBody = serverResponse.body
      
        if (!serverResponseBody || serverResponseBody.err) {
      Severity: Major
      Found in modules/gumgumBidAdapter.js - About 3 hrs to fix

        Function _getBrowserParams has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function _getBrowserParams(topWindowUrl) {
          const paramRegex = paramName => new RegExp(`[?#&](${paramName}=(.*?))($|&)`, 'i');
        
          let browserParams = {};
          let topWindow;
        Severity: Major
        Found in modules/gumgumBidAdapter.js - About 2 hrs to fix

          Function _getBrowserParams has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function _getBrowserParams(topWindowUrl) {
            const paramRegex = paramName => new RegExp(`[?#&](${paramName}=(.*?))($|&)`, 'i');
          
            let browserParams = {};
            let topWindow;
          Severity: Minor
          Found in modules/gumgumBidAdapter.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 handleLegacyParams has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function handleLegacyParams(params, sizes) {
            const data = {};
            if (params.inScreenPubID) {
              data.pubId = params.inScreenPubID;
              data.pi = 2;
          Severity: Minor
          Found in modules/gumgumBidAdapter.js - About 1 hr to fix

            Function _getVidParams has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function _getVidParams(attributes) {
              const {
                minduration: mind,
                maxduration: maxd,
                linearity: li,
            Severity: Minor
            Found in modules/gumgumBidAdapter.js - About 1 hr to fix

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

              function isBidRequestValid(bid) {
                const {
                  params,
                  adUnitCode
                } = bid;
              Severity: Minor
              Found in modules/gumgumBidAdapter.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                  if (!serverResponseBody || serverResponseBody.err) {
                    const data = bidRequest.data || {};
                    const id = data.si || data.ni || data.t || data.pubId;
                    const delayTime = serverResponseBody ? serverResponseBody.err.drt : DELAY_REQUEST_TIME;
                    invalidRequestIds[id] = { productId: data.pi, timestamp: new Date().getTime() };
                Severity: Major
                Found in modules/gumgumBidAdapter.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (userId && userId.id5id && userId.id5id.uid && userId.id5id.ext) {
                        data.id5Id = userId.id5id.uid || null
                        data.id5IdLinkType = userId.id5id.ext.linkType || null
                      }
                  Severity: Major
                  Found in modules/gumgumBidAdapter.js - About 40 mins to fix

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

                    function handleLegacyParams(params, sizes) {
                      const data = {};
                      if (params.inScreenPubID) {
                        data.pubId = params.inScreenPubID;
                        data.pi = 2;
                    Severity: Minor
                    Found in modules/gumgumBidAdapter.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

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

                    export function getCids(site) {
                      if (site.content && Array.isArray(site.content.data)) {
                        for (const dataItem of site.content.data) {
                          if (dataItem.name.includes('iris.com') || dataItem.name.includes('iris.tv')) {
                            return dataItem.ext.cids.join(',');
                    Severity: Minor
                    Found in modules/gumgumBidAdapter.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

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

                    function _getFloor(mediaTypes, staticBidFloor, bid) {
                      const curMediaType = Object.keys(mediaTypes)[0] || 'banner';
                      const bidFloor = { floor: 0, currency: 'USD' };
                    
                      if (typeof bid.getFloor === 'function') {
                    Severity: Minor
                    Found in modules/gumgumBidAdapter.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 2 locations. Consider refactoring.
                    Open

                          if (params.slot) {
                            const [maxw, maxh] = getGreatestDimensions(sizes);
                            data.maxw = maxw;
                            data.maxh = maxh;
                            data.si = params.slot;
                    Severity: Major
                    Found in modules/gumgumBidAdapter.js and 1 other location - About 4 hrs to fix
                    modules/gumgumBidAdapter.js on lines 479..486

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

                    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 (params.inSlot) {
                        const [maxw, maxh] = getGreatestDimensions(sizes);
                        data.maxw = maxw;
                        data.maxh = maxh;
                        data.si = params.inSlot;
                    Severity: Major
                    Found in modules/gumgumBidAdapter.js and 1 other location - About 4 hrs to fix
                    modules/gumgumBidAdapter.js on lines 387..401

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

                    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 result = {
                        mind,
                        maxd,
                        li,
                        sd,
                    Severity: Minor
                    Found in modules/gumgumBidAdapter.js and 1 other location - About 35 mins to fix
                    modules/bliinkBidAdapter.js on lines 344..353

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

                    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 connection = window.navigator && (window.navigator.connection || window.navigator.mozConnection || window.navigator.webkitConnection);
                    Severity: Minor
                    Found in modules/gumgumBidAdapter.js and 1 other location - About 35 mins to fix
                    modules/pubmaticBidAdapter.js on lines 267..267

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

                    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