prebid/Prebid.js

View on GitHub
modules/insticatorBidAdapter.js

Summary

Maintainability
F
5 days
Test Coverage

File insticatorBidAdapter.js has 576 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {deepAccess, generateUUID, logError, isArray, isInteger, isArrayOfNums, deepSetValue, isFn, logWarn} from '../src/utils.js';
import {getStorageManager} from '../src/storageManager.js';
Severity: Major
Found in modules/insticatorBidAdapter.js - About 1 day to fix

    Function buildImpression has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    function buildImpression(bidRequest) {
      const imp = {
        id: bidRequest.bidId,
        tagid: bidRequest.adUnitCode,
        instl: deepAccess(bidRequest, 'ortb2Imp.instl'),
    Severity: Minor
    Found in modules/insticatorBidAdapter.js - About 5 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 buildImpression has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function buildImpression(bidRequest) {
      const imp = {
        id: bidRequest.bidId,
        tagid: bidRequest.adUnitCode,
        instl: deepAccess(bidRequest, 'ortb2Imp.instl'),
    Severity: Major
    Found in modules/insticatorBidAdapter.js - About 2 hrs to fix

      Function buildRequest has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function buildRequest(validBidRequests, bidderRequest) {
        const req = {
          id: bidderRequest.bidderRequestId,
          tmax: bidderRequest.timeout,
          source: {
      Severity: Major
      Found in modules/insticatorBidAdapter.js - About 2 hrs to fix

        Function validateVideo has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function validateVideo(bid) {
          const videoParams = deepAccess(bid, 'mediaTypes.video');
          const videoBidderParams = deepAccess(bid, 'params.video');
          let video = {
            ...videoParams,
        Severity: Minor
        Found in modules/insticatorBidAdapter.js - About 1 hr to fix

          Function validateVideo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function validateVideo(bid) {
            const videoParams = deepAccess(bid, 'mediaTypes.video');
            const videoBidderParams = deepAccess(bid, 'params.video');
            let video = {
              ...videoParams,
          Severity: Minor
          Found in modules/insticatorBidAdapter.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 buildBid has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function buildBid(bid, bidderRequest) {
            const originalBid = find(bidderRequest.bids, (b) => b.bidId === bid.impid);
            let meta = {}
          
            if (bid.ext && bid.ext.meta) {
          Severity: Minor
          Found in modules/insticatorBidAdapter.js - About 1 hr to fix

            Function buildVideo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function buildVideo(bidRequest) {
              let w = deepAccess(bidRequest, 'mediaTypes.video.w');
              let h = deepAccess(bidRequest, 'mediaTypes.video.h');
              const mimes = deepAccess(bidRequest, 'mediaTypes.video.mimes');
              const placement = deepAccess(bidRequest, 'mediaTypes.video.placement');
            Severity: Minor
            Found in modules/insticatorBidAdapter.js - About 1 hr to fix

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

              function buildRequest(validBidRequests, bidderRequest) {
                const req = {
                  id: bidderRequest.bidderRequestId,
                  tmax: bidderRequest.timeout,
                  source: {
              Severity: Minor
              Found in modules/insticatorBidAdapter.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 buildVideo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function buildVideo(bidRequest) {
                let w = deepAccess(bidRequest, 'mediaTypes.video.w');
                let h = deepAccess(bidRequest, 'mediaTypes.video.h');
                const mimes = deepAccess(bidRequest, 'mediaTypes.video.mimes');
                const placement = deepAccess(bidRequest, 'mediaTypes.video.placement');
              Severity: Minor
              Found in modules/insticatorBidAdapter.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 buildUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function buildUser(bid) {
                const userId = getUserId() || generateUUID();
                const yob = deepAccess(bid, 'params.user.yob')
                const gender = deepAccess(bid, 'params.user.gender')
                const keywords = deepAccess(bid, 'params.user.keywords')
              Severity: Minor
              Found in modules/insticatorBidAdapter.js - About 1 hr to fix

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

                function buildBid(bid, bidderRequest) {
                  const originalBid = find(bidderRequest.bids, (b) => b.bidId === bid.impid);
                  let meta = {}
                
                  if (bid.ext && bid.ext.meta) {
                Severity: Minor
                Found in modules/insticatorBidAdapter.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 (sizes && sizes.length > 0) {
                            const {w: width, h: height} = sizes[0];
                            _size = [width, height];
                          }
                Severity: Major
                Found in modules/insticatorBidAdapter.js - About 45 mins to fix

                  Function parsePlayerSizeToWidthHeight has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function parsePlayerSizeToWidthHeight(playerSize, w, h) {
                    if (!w && playerSize) {
                      if (Array.isArray(playerSize[0])) {
                        w = parseInt(playerSize[0][0], 10);
                      } else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
                  Severity: Minor
                  Found in modules/insticatorBidAdapter.js - About 45 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 buildRegs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function buildRegs(bidderRequest) {
                    let regs = {
                      ext: {},
                    };
                    if (bidderRequest.gdprConsent) {
                  Severity: Minor
                  Found in modules/insticatorBidAdapter.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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

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

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

                        if (!w && playerSize) {
                          if (Array.isArray(playerSize[0])) {
                            w = parseInt(playerSize[0][0], 10);
                          } else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
                            w = parseInt(playerSize[0], 10);
                      Severity: Major
                      Found in modules/insticatorBidAdapter.js and 1 other location - About 3 hrs to fix
                      modules/insticatorBidAdapter.js on lines 621..627

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

                      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 (!h && playerSize) {
                          if (Array.isArray(playerSize[0])) {
                            h = parseInt(playerSize[0][1], 10);
                          } else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
                            h = parseInt(playerSize[1], 10);
                      Severity: Major
                      Found in modules/insticatorBidAdapter.js and 1 other location - About 3 hrs to fix
                      modules/insticatorBidAdapter.js on lines 614..620

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

                      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 (!bidResponse.vastUrl && bidResponse.vastXml) {
                          bidResponse.vastUrl = 'data:text/xml;charset=utf-8;base64,' + window.btoa(bidResponse.vastXml.replace(/\\"/g, '"'));
                        }
                      Severity: Major
                      Found in modules/insticatorBidAdapter.js and 1 other location - About 1 hr to fix
                      modules/adagioBidAdapter.js on lines 746..748

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

                      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 (storage.cookiesAreEnabled()) {
                          const expires = new Date(Date.now() + USER_ID_COOKIE_EXP).toUTCString();
                          storage.setCookie(USER_ID_KEY, userId, expires);
                        }
                      Severity: Major
                      Found in modules/insticatorBidAdapter.js and 1 other location - About 1 hr to fix
                      modules/adplusBidAdapter.js on lines 36..40

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

                      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