prebid/Prebid.js

View on GitHub
modules/onetagBidAdapter.js

Summary

Maintainability
F
3 days
Test Coverage

File onetagBidAdapter.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { INSTREAM, OUTSTREAM } from '../src/video.js';
import { Renderer } from '../src/Renderer.js';
Severity: Minor
Found in modules/onetagBidAdapter.js - About 5 hrs to fix

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

    function interpretResponse(serverResponse, bidderRequest) {
      const body = serverResponse.body;
      const bids = [];
      const requestData = JSON.parse(bidderRequest.data);
      if (!body || (body.nobid && body.nobid === true)) {
    Severity: Major
    Found in modules/onetagBidAdapter.js - About 2 hrs to fix

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

      function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
        let syncs = [];
        let params = '';
        if (gdprConsent) {
          if (typeof gdprConsent.gdprApplies === 'boolean') {
      Severity: Minor
      Found in modules/onetagBidAdapter.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 buildRequests has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function buildRequests(validBidRequests, bidderRequest) {
        const payload = {
          bids: requestsToBids(validBidRequests),
          ...getPageInfo(bidderRequest)
        };
      Severity: Minor
      Found in modules/onetagBidAdapter.js - About 1 hr to fix

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

        function buildRequests(validBidRequests, bidderRequest) {
          const payload = {
            bids: requestsToBids(validBidRequests),
            ...getPageInfo(bidderRequest)
          };
        Severity: Minor
        Found in modules/onetagBidAdapter.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 getUserSyncs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
          let syncs = [];
          let params = '';
          if (gdprConsent) {
            if (typeof gdprConsent.gdprApplies === 'boolean') {
        Severity: Minor
        Found in modules/onetagBidAdapter.js - About 1 hr to fix

          Function getPageInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getPageInfo(bidderRequest) {
            const topmostFrame = getFrameNesting();
            return {
              location: deepAccess(bidderRequest, 'refererInfo.page', null),
              referrer: deepAccess(bidderRequest, 'refererInfo.ref', null),
          Severity: Minor
          Found in modules/onetagBidAdapter.js - About 1 hr to fix

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

            function interpretResponse(serverResponse, bidderRequest) {
              const body = serverResponse.body;
              const bids = [];
              const requestData = JSON.parse(bidderRequest.data);
              if (!body || (body.nobid && body.nobid === true)) {
            Severity: Minor
            Found in modules/onetagBidAdapter.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 getUserSyncs has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) {
            Severity: Minor
            Found in modules/onetagBidAdapter.js - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

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

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

                function createRenderer(bid, rendererOptions = {}) {
                  const renderer = Renderer.install({
                    id: bid.requestId,
                    url: bid.rendererUrl,
                    config: rendererOptions,
                Severity: Major
                Found in modules/onetagBidAdapter.js and 1 other location - About 1 day to fix
                modules/incrxBidAdapter.js on lines 132..156

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

                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

                  isValid = schain.nodes.reduce((status, node) => {
                    if (!status) return status;
                    return requiredFields.every(field => node.hasOwnProperty(field));
                  }, true);
                Severity: Major
                Found in modules/onetagBidAdapter.js and 1 other location - About 1 hr to fix
                modules/rubiconBidAdapter.js on lines 1263..1266

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

                  if (bidderRequest && bidderRequest.gdprConsent) {
                    payload.gdprConsent = {
                      consentString: bidderRequest.gdprConsent.consentString,
                      consentRequired: bidderRequest.gdprConsent.gdprApplies,
                      addtlConsent: bidderRequest.gdprConsent.addtlConsent
                Severity: Major
                Found in modules/onetagBidAdapter.js and 2 other locations - About 1 hr to fix
                modules/audiencerunBidAdapter.js on lines 148..158
                modules/yandexBidAdapter.js on lines 432..442

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

                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

                  if (bidderRequest && bidderRequest.gppConsent) {
                    payload.gppConsent = {
                      consentString: bidderRequest.gppConsent.gppString,
                      applicableSections: bidderRequest.gppConsent.applicableSections
                    }
                Severity: Major
                Found in modules/onetagBidAdapter.js and 5 other locations - About 55 mins to fix
                modules/a4gBidAdapter.js on lines 53..58
                modules/adrinoBidAdapter.js on lines 54..59
                modules/resetdigitalBidAdapter.js on lines 45..50
                modules/videoreachBidAdapter.js on lines 36..41
                modules/waardexBidAdapter.js on lines 80..85

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

                  if (typeof bid.mediaTypes !== 'undefined' && typeof bid.mediaTypes.banner !== 'undefined' && typeof bid.mediaTypes.banner.sizes !== 'undefined' && Array.isArray(bid.mediaTypes.banner.sizes) && bid.mediaTypes.banner.sizes.length > 0) {
                Severity: Minor
                Found in modules/onetagBidAdapter.js and 1 other location - About 50 mins to fix
                modules/vrtcalBidAdapter.js on lines 94..94

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

                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

                export const spec = {
                  code: BIDDER_CODE,
                  gvlid: GVLID,
                  supportedMediaTypes: [BANNER, VIDEO],
                  isBidRequestValid: isBidRequestValid,
                Severity: Major
                Found in modules/onetagBidAdapter.js and 2 other locations - About 40 mins to fix
                modules/shinezRtbBidAdapter.js on lines 28..36
                modules/tagorasBidAdapter.js on lines 29..37

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

                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