prebid/Prebid.js

View on GitHub
modules/sspBCBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

File sspBCBidAdapter.js has 665 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { deepAccess, getWindowTop, isArray, logWarn } from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
Severity: Major
Found in modules/sspBCBidAdapter.js - About 1 day to fix

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

      interpretResponse(serverResponse, request) {
        const { bidderRequest } = request;
        const response = serverResponse.body;
        const bids = [];
        let site = JSON.parse(request.data).site; // get page and referer data from request
    Severity: Major
    Found in modules/sspBCBidAdapter.js - About 3 hrs to fix

      Function mapAsset has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var mapAsset = function mapAsset(paramName, paramValue) {
        const { required, sizes, wmin, hmin, len } = paramValue;
        var id = nativeAssetMap[paramName];
        var assets = [];
      
      
      Severity: Major
      Found in modules/sspBCBidAdapter.js - About 2 hrs to fix

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

        const renderCreative = (site, auctionId, bid, seat, request) => {
          const { adLabel, id, slot, sn, page, publisherId, ref } = site;
          let gam;
        
          const mcad = {
        Severity: Major
        Found in modules/sspBCBidAdapter.js - About 2 hrs to fix

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

            buildRequests(validBidRequests, bidderRequest) {
              // convert Native ORTB definition to old-style prebid native definition
              validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
          
              if ((!validBidRequests) || (validBidRequests.length < 1)) {
          Severity: Minor
          Found in modules/sspBCBidAdapter.js - About 1 hr to fix

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

            const applyClientHints = ortbRequest => {
              const { location } = document;
              const { connection = {}, deviceMemory, userAgentData = {} } = navigator;
              const viewport = W.visualViewport || false;
              const segments = [];
            Severity: Minor
            Found in modules/sspBCBidAdapter.js - About 1 hr to fix

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

              const getNotificationPayload = bidData => {
                if (bidData) {
                  const bids = isArray(bidData) ? bidData : [bidData];
                  if (bids.length > 0) {
                    let result = {
              Severity: Minor
              Found in modules/sspBCBidAdapter.js - About 1 hr to fix

                Function parseNative has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const parseNative = (nativeData, adUnitCode) => {
                  const { link = {}, imptrackers: impressionTrackers, jstracker } = nativeData;
                  const { url: clickUrl, clicktrackers: clickTrackers = [] } = link;
                  const macroReplacer = tracker => tracker.replace(new RegExp('%native_dom_id%', 'g'), adUnitCode);
                  let javascriptTrackers = isArray(jstracker) ? jstracker : jstracker && [jstracker];
                Severity: Minor
                Found in modules/sspBCBidAdapter.js - About 1 hr to fix

                  Function mapAsset has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var mapAsset = function mapAsset(paramName, paramValue) {
                    const { required, sizes, wmin, hmin, len } = paramValue;
                    var id = nativeAssetMap[paramName];
                    var assets = [];
                  
                  
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.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 renderCreative has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const renderCreative = (site, auctionId, bid, seat, request) => {
                    const { adLabel, id, slot, sn, page, publisherId, ref } = site;
                    let gam;
                  
                    const mcad = {
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.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 mapVideo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var mapVideo = (slot, videoFromBid) => {
                    var videoFromSlot = deepAccess(slot, 'mediaTypes.video');
                    var videoParamsUsed = ['api', 'context', 'linearity', 'maxduration', 'mimes', 'protocols', 'playbackmethod'];
                    var videoAssets;
                  
                  
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.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

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

                  const mapImpression = slot => {
                    const { adUnitCode, bidderRequestId, bidId, params = {}, ortb2Imp = {} } = slot;
                    const { id, siteId, video } = params;
                    const { ext = {} } = ortb2Imp;
                  
                  
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.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

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

                        } else if (dataType === 2 || detectedType === 'body') {
                          result.body = dataValue;
                        } else if (dataType === 12 || detectedType === 'cta') {
                          result.cta = dataValue;
                        }
                  Severity: Major
                  Found in modules/sspBCBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/sspBCBidAdapter.js on lines 554..558

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

                  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 (imgType === 3 || detectedType === 'image') {
                          result.image = thisImage;
                        } else if (imgType === 1 || detectedType === 'icon') {
                          result.icon = thisImage;
                        }
                  Severity: Major
                  Found in modules/sspBCBidAdapter.js and 1 other location - About 1 hr to fix
                  modules/sspBCBidAdapter.js on lines 564..568

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

                  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 topicsData = userData.filter(dataObj => {
                      const segtax = dataObj.ext?.segtax;
                      return segtax >= 600 && segtax <= 609;
                    })[0];
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.js and 1 other location - About 55 mins to fix
                  modules/yieldmoBidAdapter.js on lines 452..455

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 54.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                          const { adUnitCode, cpm, creativeId, meta, mediaType, params: bidParams, bidderRequestId, requestId, timeout } = bid;
                  Severity: Major
                  Found in modules/sspBCBidAdapter.js and 2 other locations - About 55 mins to fix
                  modules/byDataAnalyticsAdapter.js on lines 141..141
                  modules/quantcastBidAdapter.js on lines 239..239

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

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

                    onBidViewable(bid) {
                      const payload = getNotificationPayload(bid);
                      if (payload) {
                        payload.event = 'bidViewable';
                        sendNotification(payload);
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.js and 2 other locations - About 40 mins to fix
                  modules/sspBCBidAdapter.js on lines 837..844
                  modules/sspBCBidAdapter.js on lines 855..862

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

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

                    onTimeout(timeoutData) {
                      const payload = getNotificationPayload(timeoutData);
                      if (payload) {
                        payload.event = 'timeout';
                        sendNotification(payload);
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.js and 2 other locations - About 40 mins to fix
                  modules/sspBCBidAdapter.js on lines 846..853
                  modules/sspBCBidAdapter.js on lines 855..862

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

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

                    onBidWon(bid) {
                      const payload = getNotificationPayload(bid);
                      if (payload) {
                        payload.event = 'bidWon';
                        sendNotification(payload);
                  Severity: Minor
                  Found in modules/sspBCBidAdapter.js and 2 other locations - About 40 mins to fix
                  modules/sspBCBidAdapter.js on lines 837..844
                  modules/sspBCBidAdapter.js on lines 846..853

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

                  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