prebid/Prebid.js

View on GitHub
modules/zmaticooBidAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

Function buildRequests has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  buildRequests: function (validBidRequests, bidderRequest) {
    const secure = 1;
    const request = validBidRequests[0];
    const params = request.params;
    const imps = validBidRequests.map(request => {
Severity: Minor
Found in modules/zmaticooBidAdapter.js - About 6 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 buildRequests has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  buildRequests: function (validBidRequests, bidderRequest) {
    const secure = 1;
    const request = validBidRequests[0];
    const params = request.params;
    const imps = validBidRequests.map(request => {
Severity: Major
Found in modules/zmaticooBidAdapter.js - About 3 hrs to fix

    File zmaticooBidAdapter.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {deepAccess, isArray, isBoolean, isNumber, isStr, logWarn, triggerPixel} from '../src/utils.js';
    import {registerBidder} from '../src/adapters/bidderFactory.js';
    import {BANNER, VIDEO} from '../src/mediaTypes.js';
    
    /**
    Severity: Minor
    Found in modules/zmaticooBidAdapter.js - About 2 hrs to fix

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

          const imps = validBidRequests.map(request => {
            const impData = {
              id: request.bidId,
              secure: secure,
              ext: {
      Severity: Minor
      Found in modules/zmaticooBidAdapter.js - About 1 hr to fix

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

          interpretResponse: function (serverResponse, bidRequest) {
            let bidResponses = [];
            const response = (serverResponse || {}).body;
            if (response && response.seatbid && response.seatbid.length && response.seatbid[0].bid && response.seatbid[0].bid.length) {
              response.seatbid.forEach(zmSeatbid => {
        Severity: Minor
        Found in modules/zmaticooBidAdapter.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (response && response.seatbid && response.seatbid.length && response.seatbid[0].bid && response.seatbid[0].bid.length) {
                response.seatbid.forEach(zmSeatbid => {
                  zmSeatbid.bid.forEach(zmBid => {
                    let bid = {
                      requestId: zmBid.impid,
          Severity: Major
          Found in modules/zmaticooBidAdapter.js - About 40 mins to fix

            Function buildVideo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function buildVideo(request) {
              let video = {};
              const videoParams = deepAccess(request, 'mediaTypes.video', {});
              for (const key in VIDEO_CUSTOM_PARAMS) {
                if (videoParams.hasOwnProperty(key)) {
            Severity: Minor
            Found in modules/zmaticooBidAdapter.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

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

            function buildVideo(request) {
              let video = {};
              const videoParams = deepAccess(request, 'mediaTypes.video', {});
              for (const key in VIDEO_CUSTOM_PARAMS) {
                if (videoParams.hasOwnProperty(key)) {
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 1 day to fix
            modules/zeta_global_sspBidAdapter.js on lines 311..329

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

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

            const VIDEO_CUSTOM_PARAMS = {
              'mimes': DATA_TYPES.ARRAY,
              'minduration': DATA_TYPES.NUMBER,
              'maxduration': DATA_TYPES.NUMBER,
              'startdelay': DATA_TYPES.NUMBER,
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 2 other locations - About 5 hrs to fix
            modules/pubmaticBidAdapter.js on lines 47..64
            modules/zeta_global_sspBidAdapter.js on lines 30..47

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

            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 (typeof bidderRequest.getFloor === 'function') {
                    const floorInfo = bidderRequest.getFloor({
                      currency: 'USD',
                      mediaType: impData.video ? 'video' : 'banner',
                      size: [impData.video ? impData.video.w : impData.banner.w, impData.video ? impData.video.h : impData.banner.h]
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 5 hrs to fix
            modules/zeta_global_sspBidAdapter.js on lines 107..116

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

            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

            export function checkParamDataType(key, value, datatype) {
              let functionToExecute;
              switch (datatype) {
                case DATA_TYPES.BOOLEAN:
                  functionToExecute = isBoolean;
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 4 hrs to fix
            modules/zeta_global_sspBidAdapter.js on lines 331..352

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

            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

            function buildBanner(request) {
              let sizes = request.sizes;
              if (request.mediaTypes && request.mediaTypes.banner && request.mediaTypes.banner.sizes) {
                sizes = request.mediaTypes.banner.sizes;
              }
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 3 hrs to fix
            modules/zetaBidAdapter.js on lines 182..193

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

            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

                  if (request.mediaTypes) {
                    for (const mediaType in request.mediaTypes) {
                      switch (mediaType) {
                        case BANNER:
                          impData.banner = buildBanner(request);
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 1 hr to fix
            modules/zeta_global_sspBidAdapter.js on lines 91..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 72.

            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 (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
                  payload.user.ext = Object.assign(payload.user.ext, {consent: bidderRequest.gdprConsent.consentString});
                }
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 1 hr to fix
            modules/zetaBidAdapter.js on lines 115..120

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

            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 winUrl = bid.nurl.replace(
                  /\$\{AUCTION_PRICE\}/,
                  winCpm
                ).replace(
                  /\$\{AUCTION_IMP_ID\}/,
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 1 hr to fix
            modules/automatadBidAdapter.js on lines 123..138

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

            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 (bidderRequest.gdprConsent) {
                  payload.regs.ext = Object.assign(payload.regs.ext, {gdpr: bidderRequest.gdprConsent.gdprApplies == true ? 1 : 0});
                }
            Severity: Major
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 1 hr to fix
            modules/zetaBidAdapter.js on lines 109..114

            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

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

            export function _getDomainFromURL(url) {
              let anchor = document.createElement('a');
              anchor.href = url;
              return anchor.hostname;
            }
            Severity: Minor
            Found in modules/zmaticooBidAdapter.js and 1 other location - About 30 mins to fix
            modules/pubmaticBidAdapter.js on lines 144..148

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

            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