prebid/Prebid.js

View on GitHub
modules/openwebBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

File openwebBidAdapter.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  logWarn,
  logInfo,
  isArray,
  isFn,
Severity: Minor
Found in modules/openwebBidAdapter.js - About 4 hrs to fix

    Function generateBidParameters has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    function generateBidParameters(bid, bidderRequest) {
      const {params} = bid;
      const mediaType = isBanner(bid) ? BANNER : VIDEO;
      const sizesArray = getSizesArray(bid, mediaType);
    
    
    Severity: Minor
    Found in modules/openwebBidAdapter.js - About 4 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 generateBidParameters has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function generateBidParameters(bid, bidderRequest) {
      const {params} = bid;
      const mediaType = isBanner(bid) ? BANNER : VIDEO;
      const sizesArray = getSizesArray(bid, mediaType);
    
    
    Severity: Major
    Found in modules/openwebBidAdapter.js - About 3 hrs to fix

      Function generateGeneralParams has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function generateGeneralParams(generalObject, bidderRequest) {
        const domain = deepAccess(bidderRequest, 'refererInfo.domain') || window.location.hostname;
        const {syncEnabled, filterSettings} = config.getConfig('userSync') || {};
        const {bidderCode, timeout} = bidderRequest;
        const generalBidParams = generalObject.params;
      Severity: Major
      Found in modules/openwebBidAdapter.js - About 2 hrs to fix

        Function generateGeneralParams has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function generateGeneralParams(generalObject, bidderRequest) {
          const domain = deepAccess(bidderRequest, 'refererInfo.domain') || window.location.hostname;
          const {syncEnabled, filterSettings} = config.getConfig('userSync') || {};
          const {bidderCode, timeout} = bidderRequest;
          const generalBidParams = generalObject.params;
        Severity: Minor
        Found in modules/openwebBidAdapter.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

        Consider simplifying this complex logical expression.
        Open

            if (body && body.bids && body.bids.length) {
              body.bids.forEach(adUnit => {
                const bidResponse = {
                  requestId: adUnit.requestId,
                  cpm: adUnit.cpm,
        Severity: Major
        Found in modules/openwebBidAdapter.js - About 40 mins to fix

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

            getUserSyncs: function (syncOptions, serverResponses) {
              const syncs = [];
              for (const response of serverResponses) {
                if (syncOptions.iframeEnabled && response.body.params.userSyncURL) {
                  syncs.push({
          Severity: Minor
          Found in modules/openwebBidAdapter.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

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

          function generateBidParameters(bid, bidderRequest) {
            const {params} = bid;
            const mediaType = isBanner(bid) ? BANNER : VIDEO;
            const sizesArray = getSizesArray(bid, mediaType);
          
          
          Severity: Major
          Found in modules/openwebBidAdapter.js and 2 other locations - About 4 days to fix
          modules/minutemediaBidAdapter.js on lines 285..394
          modules/stnBidAdapter.js on lines 287..396

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

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

          function getSupplyChain(schainObject) {
            if (isEmpty(schainObject)) {
              return '';
            }
            let scStr = `${schainObject.ver},${schainObject.complete}`;
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 1 day to fix
          modules/kueezBidAdapter.js on lines 97..112
          modules/minutemediaBidAdapter.js on lines 178..193
          modules/publirBidAdapter.js on lines 184..199
          modules/riseBidAdapter.js on lines 185..200
          modules/shinezBidAdapter.js on lines 177..192

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

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

            getUserSyncs: function (syncOptions, serverResponses) {
              const syncs = [];
              for (const response of serverResponses) {
                if (syncOptions.iframeEnabled && response.body.params.userSyncURL) {
                  syncs.push({
          Severity: Major
          Found in modules/openwebBidAdapter.js and 3 other locations - About 7 hrs to fix
          modules/minutemediaBidAdapter.js on lines 104..124
          modules/riseBidAdapter.js on lines 110..130
          modules/shinezBidAdapter.js on lines 103..123

          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

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

          function getSizesArray(bid, mediaType) {
            let sizesArray = []
          
            if (deepAccess(bid, `mediaTypes.${mediaType}.sizes`)) {
              sizesArray = bid.mediaTypes[mediaType].sizes;
          Severity: Major
          Found in modules/openwebBidAdapter.js and 6 other locations - About 3 hrs to fix
          modules/kueezBidAdapter.js on lines 171..181
          modules/minutemediaBidAdapter.js on lines 161..171
          modules/publirBidAdapter.js on lines 167..177
          modules/riseBidAdapter.js on lines 168..178
          modules/shinezBidAdapter.js on lines 160..170
          modules/stnBidAdapter.js on lines 162..172

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

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

          function getAllowedSyncMethod(filterSettings, bidderCode) {
            const iframeConfigsToCheck = ['all', 'iframe'];
            const pixelConfigToCheck = 'image';
            if (filterSettings && iframeConfigsToCheck.some(config => isSyncMethodAllowed(filterSettings[config], bidderCode))) {
              return SUPPORTED_SYNC_METHODS.IFRAME;
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 3 hrs to fix
          modules/kueezBidAdapter.js on lines 189..198
          modules/minutemediaBidAdapter.js on lines 209..218
          modules/riseBidAdapter.js on lines 216..225
          modules/shinezBidAdapter.js on lines 208..217
          modules/stnBidAdapter.js on lines 211..220

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

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

            buildRequests: function (validBidRequests, bidderRequest) {
              const combinedRequestsObject = {};
          
              // use data from the first bid, to create the general params for all bids
              const generalObject = validBidRequests[0];
          Severity: Major
          Found in modules/openwebBidAdapter.js and 3 other locations - About 3 hrs to fix
          modules/minutemediaBidAdapter.js on lines 51..66
          modules/shinezBidAdapter.js on lines 50..65
          modules/stnBidAdapter.js on lines 50..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 105.

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

          function getFloor(bid, mediaType) {
            if (!isFn(bid.getFloor)) {
              return 0;
            }
            let floorResult = bid.getFloor({
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 2 hrs to fix
          modules/minutemediaBidAdapter.js on lines 144..154
          modules/publirBidAdapter.js on lines 150..160
          modules/riseBidAdapter.js on lines 151..161
          modules/shinezBidAdapter.js on lines 143..153
          modules/stnBidAdapter.js on lines 144..154

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

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

          function getDeviceType(ua) {
            if (/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i
              .test(ua.toLowerCase())) {
              return '5';
            }
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 2 hrs to fix
          modules/minutemediaBidAdapter.js on lines 251..265
          modules/publirBidAdapter.js on lines 241..252
          modules/riseBidAdapter.js on lines 260..274
          modules/shinezBidAdapter.js on lines 250..264
          modules/stnBidAdapter.js on lines 253..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 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 6 locations. Consider refactoring.
          Open

          function isSyncMethodAllowed(syncRule, bidderCode) {
            if (!syncRule) {
              return false;
            }
            const isInclude = syncRule.filter === 'include';
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 2 hrs to fix
          modules/minutemediaBidAdapter.js on lines 226..233
          modules/publirBidAdapter.js on lines 227..234
          modules/riseBidAdapter.js on lines 233..240
          modules/shinezBidAdapter.js on lines 225..232
          modules/stnBidAdapter.js on lines 228..235

          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

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

            onBidWon: function (bid) {
              if (bid == null) {
                return;
              }
          
          
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 1 hr to fix
          modules/kueezBidAdapter.js on lines 78..87
          modules/minutemediaBidAdapter.js on lines 125..134
          modules/riseBidAdapter.js on lines 131..140
          modules/shinezBidAdapter.js on lines 124..133
          modules/stnBidAdapter.js on lines 124..133

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

          function generateBidsParams(validBidRequests, bidderRequest) {
            const bidsArray = [];
          
            if (validBidRequests.length) {
              validBidRequests.forEach(bid => {
          Severity: Major
          Found in modules/openwebBidAdapter.js and 5 other locations - About 1 hr to fix
          modules/minutemediaBidAdapter.js on lines 267..277
          modules/publirBidAdapter.js on lines 254..263
          modules/riseBidAdapter.js on lines 276..286
          modules/shinezBidAdapter.js on lines 266..276
          modules/stnBidAdapter.js on lines 269..279

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

          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

            isBidRequestValid: function (bidRequest) {
              if (!bidRequest.params) {
                logWarn('no params have been set to OpenWeb adapter');
                return false;
              }
          Severity: Major
          Found in modules/openwebBidAdapter.js and 4 other locations - About 1 hr to fix
          modules/minutemediaBidAdapter.js on lines 38..50
          modules/riseBidAdapter.js on lines 43..55
          modules/shinezBidAdapter.js on lines 37..49
          modules/stnBidAdapter.js on lines 37..49

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

          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