prebid/Prebid.js

View on GitHub
modules/pstudioBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

File pstudioBidAdapter.js has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import {
  deepAccess,
  isArray,
Severity: Minor
Found in modules/pstudioBidAdapter.js - About 5 hrs to fix

    Consider simplifying this complex logical expression.
    Open

      if (bidRequest.mediaTypes.video) {
        const { w, h, playerSize, mimes, protocols } = deepAccess(
          bidRequest,
          'mediaTypes.video',
          {}
    Severity: Critical
    Found in modules/pstudioBidAdapter.js - About 1 hr to fix

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

      function buildBaseObject(bid, bidderRequest) {
        const firstPartyData = prepareFirstPartyData(bidderRequest.ortb2);
        const { pubid, bcat, badv, bapp } = bid.params;
        const { userId } = bid;
        const uid2Token = userId?.uid2?.id;
      Severity: Minor
      Found in modules/pstudioBidAdapter.js - About 1 hr to fix

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

          interpretResponse: function (serverResponse, bidRequest) {
            const bidResponses = [];
        
            if (!serverResponse.body.bids) return [];
            const { id } = JSON.parse(bidRequest.data);
        Severity: Minor
        Found in modules/pstudioBidAdapter.js - About 1 hr to fix

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

          function cleanObject(data) {
            for (let key in data) {
              if (typeof data[key] == 'object') {
                cleanObject(data[key]);
          
          
          Severity: Minor
          Found in modules/pstudioBidAdapter.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 buildBaseObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function buildBaseObject(bid, bidderRequest) {
            const firstPartyData = prepareFirstPartyData(bidderRequest.ortb2);
            const { pubid, bcat, badv, bapp } = bid.params;
            const { userId } = bid;
            const uid2Token = userId?.uid2?.id;
          Severity: Minor
          Found in modules/pstudioBidAdapter.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 prepareFirstPartyData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function prepareFirstPartyData({ user, device, site, app, regs }) {
            let userData;
            let deviceData;
            let siteData;
            let appData;
          Severity: Minor
          Found in modules/pstudioBidAdapter.js - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

                ...(device.geo && {
                  geo: {
                    lat: device.geo.lat,
                    lon: device.geo.lon,
                    country: device.geo.country,
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 2 other locations - About 5 hrs to fix
          modules/pstudioBidAdapter.js on lines 308..320
          modules/pstudioBidAdapter.js on lines 346..358

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

          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

                ...(app.content && {
                  content: {
                    id: app.content.id,
                    episode: app.content.episode,
                    title: app.content.title,
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 2 other locations - About 5 hrs to fix
          modules/pstudioBidAdapter.js on lines 270..282
          modules/pstudioBidAdapter.js on lines 308..320

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

          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

                ...(site.content && {
                  content: {
                    id: site.content.id,
                    episode: site.content.episode,
                    title: site.content.title,
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 2 other locations - About 5 hrs to fix
          modules/pstudioBidAdapter.js on lines 270..282
          modules/pstudioBidAdapter.js on lines 346..358

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

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

          function getBidFloor(bid) {
            if (!isFn(bid.getFloor)) {
              return bid.params.floorPrice ? bid.params.floorPrice : null;
            }
          
          
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 10 other locations - About 4 hrs to fix
          modules/brightcomBidAdapter.js on lines 287..301
          modules/brightcomSSPBidAdapter.js on lines 307..319
          modules/goldbachBidAdapter.js on lines 1117..1131
          modules/mediafuseBidAdapter.js on lines 1105..1119
          modules/nextrollBidAdapter.js on lines 197..212
          modules/omsBidAdapter.js on lines 269..281
          modules/onomagicBidAdapter.js on lines 260..274
          modules/pixfutureBidAdapter.js on lines 342..356
          modules/proxistoreBidAdapter.js on lines 161..175
          modules/winrBidAdapter.js on lines 577..591

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

          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

                ...(site.publisher && {
                  publisher: {
                    name: site.publisher.name,
                    cat: site.publisher.cat,
                    domain: site.publisher.domain,
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 1 other location - About 1 hr to fix
          modules/pstudioBidAdapter.js on lines 338..344

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

          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

                ...(app.publisher && {
                  publisher: {
                    name: app.publisher.name,
                    cat: app.publisher.cat,
                    domain: app.publisher.domain,
          Severity: Major
          Found in modules/pstudioBidAdapter.js and 1 other location - About 1 hr to fix
          modules/pstudioBidAdapter.js on lines 301..307

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

          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 (uid2Token) {
              if (firstPartyData.user) {
                firstPartyData.user.uid2_token = uid2Token;
              } else {
                firstPartyData.user = { uid2_token: uid2Token };
          Severity: Minor
          Found in modules/pstudioBidAdapter.js and 1 other location - About 55 mins to fix
          modules/pstudioBidAdapter.js on lines 159..165

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

            if (userCookieId) {
              if (firstPartyData.user) {
                firstPartyData.user.id = userCookieId;
              } else {
                firstPartyData.user = { id: userCookieId };
          Severity: Minor
          Found in modules/pstudioBidAdapter.js and 1 other location - About 55 mins to fix
          modules/pstudioBidAdapter.js on lines 151..157

          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

          There are no issues that match your filters.

          Category
          Status