prebid/Prebid.js

View on GitHub
modules/adagioRtdProvider.js

Summary

Maintainability
F
4 days
Test Coverage

File adagioRtdProvider.js has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * This module adds the adagio provider to the Real Time Data module (rtdModule).
 * The {@link module:modules/realTimeData} module is required.
 * @module modules/adagioRtdProvider
 * @requires module:modules/realTimeData
Severity: Minor
Found in modules/adagioRtdProvider.js - About 7 hrs to fix

    Function registerEventsForAdServers has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function registerEventsForAdServers(config) {
      const GPT_EVENTS = new Set([
        'impressionViewable',
        'slotRenderEnded',
        'slotVisibilityChanged',
    Severity: Major
    Found in modules/adagioRtdProvider.js - About 3 hrs to fix

      Function onGetBidRequestData has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function onGetBidRequestData(bidReqConfig, callback, config) {
        const configParams = deepAccess(config, 'params', {});
        const { site: ortb2Site } = bidReqConfig.ortb2Fragments.global;
        const features = _internal.getFeatures().get();
        const ext = {
      Severity: Major
      Found in modules/adagioRtdProvider.js - About 2 hrs to fix

        Function getSlotPosition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function getSlotPosition(divId) {
          if (!isSafeFrameWindow() && !canAccessWindowTop()) {
            return '';
          }
        
        
        Severity: Minor
        Found in modules/adagioRtdProvider.js - About 2 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

        Consider simplifying this complex logical expression.
        Open

          if (isSafeFrameWindow()) {
            const { self } = getSafeframeGeometry() || {};
        
            if (!self) {
              return '';
        Severity: Critical
        Found in modules/adagioRtdProvider.js - About 2 hrs to fix

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

          function getSlotPosition(divId) {
            if (!isSafeFrameWindow() && !canAccessWindowTop()) {
              return '';
            }
          
          
          Severity: Minor
          Found in modules/adagioRtdProvider.js - About 1 hr to fix

            Function _SESSION has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const _SESSION = (function() {
              /**
               * @type {SessionData}
               */
              const data = {
            Severity: Minor
            Found in modules/adagioRtdProvider.js - About 1 hr to fix

              Function init has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  init: () => {
                    // helper function to determine if the session is new.
                    const isNewSession = (lastActivity) => {
                      const now = Date.now();
                      return (!isNumber(lastActivity) || (now - lastActivity) > SESS_DURATION);
              Severity: Minor
              Found in modules/adagioRtdProvider.js - About 1 hr to fix

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

                function storeRequestInAdagioNS(bid, config) {
                  try {
                    const { bidder, adUnitCode, mediaTypes, params, auctionId, bidderRequestsCount, ortb2, ortb2Imp } = bid;
                
                    const { organizationId, site } = config.params;
                Severity: Minor
                Found in modules/adagioRtdProvider.js - About 1 hr to fix

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

                  function getElementFromTopWindow(element, currentWindow) {
                    try {
                      if (getWindowTop() === currentWindow) {
                        if (!element.getAttribute('id')) {
                          element.setAttribute('id', `adg-${getUniqueIdentifierStr()}`);
                  Severity: Minor
                  Found in modules/adagioRtdProvider.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 getViewPortDimensions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getViewPortDimensions() {
                    if (!isSafeFrameWindow() && !canAccessWindowTop()) {
                      return '';
                    }
                  
                  
                  Severity: Minor
                  Found in modules/adagioRtdProvider.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 `${position.x}x${position.y}`;
                  Severity: Major
                  Found in modules/adagioRtdProvider.js - About 30 mins to fix

                    Function registerEventsForAdServers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function registerEventsForAdServers(config) {
                      const GPT_EVENTS = new Set([
                        'impressionViewable',
                        'slotRenderEnded',
                        'slotVisibilityChanged',
                    Severity: Minor
                    Found in modules/adagioRtdProvider.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 2 locations. Consider refactoring.
                    Open

                      if (isSafeFrameWindow()) {
                        const { win } = getSafeframeGeometry() || {};
                    
                        if (!win) {
                          return '';
                    Severity: Major
                    Found in modules/adagioRtdProvider.js and 1 other location - About 2 hrs to fix
                    modules/adagioRtdProvider.js on lines 457..508

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

                    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 (isSafeFrameWindow()) {
                        const { self } = getSafeframeGeometry() || {};
                    
                        if (!self) {
                          return '';
                    Severity: Major
                    Found in modules/adagioRtdProvider.js and 1 other location - About 2 hrs to fix
                    modules/adagioRtdProvider.js on lines 539..553

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

                    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

                            ws.googletag.pubads().addEventListener(eventName, (args) => {
                              _internal.getAdagioNs().queue.push({
                                action: 'gpt-event',
                                data: { eventName, args, _window: ws },
                                ts: Date.now(),
                    Severity: Major
                    Found in modules/adagioRtdProvider.js and 1 other location - About 1 hr to fix
                    modules/adagioRtdProvider.js on lines 633..639

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

                    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

                            ws.sas.events.on(eventName, (args) => {
                              _internal.getAdagioNs().queue.push({
                                action: 'sas-event',
                                data: { eventName, args, _window: ws },
                                ts: Date.now(),
                    Severity: Major
                    Found in modules/adagioRtdProvider.js and 1 other location - About 1 hr to fix
                    modules/adagioRtdProvider.js on lines 618..624

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

                    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 { bidder, adUnitCode, mediaTypes, params, auctionId, bidderRequestsCount, ortb2, ortb2Imp } = bid;
                    Severity: Minor
                    Found in modules/adagioRtdProvider.js and 2 other locations - About 40 mins to fix
                    modules/byDataAnalyticsAdapter.js on lines 321..321
                    modules/ooloAnalyticsAdapter.js on lines 27..36

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

                      isAdagioBidder: function (alias) {
                        if (!alias) {
                          return false;
                        }
                        return (alias + adapterManager.aliasRegistry[alias]).toLowerCase().includes(ADAGIO_BIDDER_CODE);
                    Severity: Minor
                    Found in modules/adagioRtdProvider.js and 1 other location - About 35 mins to fix
                    modules/adagioAnalyticsAdapter.js on lines 77..82

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

                    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