prebid/Prebid.js

View on GitHub
modules/riseBidAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

File riseBidAdapter.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  logWarn,
  logInfo,
  isArray,
  isFn,
Severity: Minor
Found in modules/riseBidAdapter.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);
      // fix floor price in case of NAN
    Severity: Minor
    Found in modules/riseBidAdapter.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);
      // fix floor price in case of NAN
    Severity: Major
    Found in modules/riseBidAdapter.js - About 3 hrs to fix

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

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

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

        function generateGeneralParams(generalObject, bidderRequest) {
          const domain = window.location.hostname;
          const {syncEnabled, filterSettings} = config.getConfig('userSync') || {};
          const {bidderCode} = bidderRequest;
          const generalBidParams = generalObject.params;
        Severity: Minor
        Found in modules/riseBidAdapter.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 getUserSyncs has a Cognitive Complexity of 7 (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/riseBidAdapter.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

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

          interpretResponse: function ({body}) {
            const bidResponses = [];
        
            if (body.bids) {
              body.bids.forEach(adUnit => {
        Severity: Major
        Found in modules/riseBidAdapter.js and 3 other locations - About 1 day to fix
        modules/minutemediaBidAdapter.js on lines 67..103
        modules/shinezBidAdapter.js on lines 66..102
        modules/stnBidAdapter.js on lines 66..102

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

        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/riseBidAdapter.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/openwebBidAdapter.js on lines 178..193
        modules/publirBidAdapter.js on lines 184..199
        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/riseBidAdapter.js and 3 other locations - About 7 hrs to fix
        modules/minutemediaBidAdapter.js on lines 104..124
        modules/openwebBidAdapter.js on lines 104..124
        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/riseBidAdapter.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/openwebBidAdapter.js on lines 161..171
        modules/publirBidAdapter.js on lines 167..177
        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/riseBidAdapter.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/openwebBidAdapter.js on lines 209..218
        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 2 locations. Consider refactoring.
        Open

          const bidObject = {
            mediaType,
            adUnitCode: getBidIdParameter('adUnitCode', bid),
            sizes: sizesArray,
            floorPrice: Math.max(getFloor(bid, mediaType), params.floorPrice),
        Severity: Major
        Found in modules/riseBidAdapter.js and 1 other location - About 3 hrs to fix
        modules/publirBidAdapter.js on lines 281..291

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

        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/riseBidAdapter.js and 5 other locations - About 2 hrs to fix
        modules/minutemediaBidAdapter.js on lines 144..154
        modules/openwebBidAdapter.js on lines 144..154
        modules/publirBidAdapter.js on lines 150..160
        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/riseBidAdapter.js and 5 other locations - About 2 hrs to fix
        modules/minutemediaBidAdapter.js on lines 251..265
        modules/openwebBidAdapter.js on lines 251..265
        modules/publirBidAdapter.js on lines 241..252
        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/riseBidAdapter.js and 5 other locations - About 2 hrs to fix
        modules/minutemediaBidAdapter.js on lines 226..233
        modules/openwebBidAdapter.js on lines 226..233
        modules/publirBidAdapter.js on lines 227..234
        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/riseBidAdapter.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/openwebBidAdapter.js on lines 125..134
        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/riseBidAdapter.js and 5 other locations - About 1 hr to fix
        modules/minutemediaBidAdapter.js on lines 267..277
        modules/openwebBidAdapter.js on lines 267..277
        modules/publirBidAdapter.js on lines 254..263
        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 Rise adapter');
              return false;
            }
        Severity: Major
        Found in modules/riseBidAdapter.js and 4 other locations - About 1 hr to fix
        modules/minutemediaBidAdapter.js on lines 38..50
        modules/openwebBidAdapter.js on lines 38..50
        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