prebid/Prebid.js

View on GitHub
modules/asteriobidAnalyticsAdapter.js

Summary

Maintainability
F
1 wk
Test Coverage

Function handleEvent has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function handleEvent(eventType, eventArgs) {
  if (!asteriobidAnalyticsEnabled) {
    return
  }

Severity: Major
Found in modules/asteriobidAnalyticsAdapter.js - About 4 hrs to fix

    File asteriobidAnalyticsAdapter.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { generateUUID, getParameterByName, logError, logInfo, parseUrl } from '../src/utils.js'
    import { ajaxBuilder } from '../src/ajax.js'
    import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'
    import adapterManager from '../src/adapterManager.js'
    import { getStorageManager } from '../src/storageManager.js'
    Severity: Minor
    Found in modules/asteriobidAnalyticsAdapter.js - About 3 hrs to fix

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

      function flush() {
        if (!asteriobidAnalyticsEnabled) {
          return
        }
      
      
      Severity: Minor
      Found in modules/asteriobidAnalyticsAdapter.js - About 1 hr to fix

        Function flush has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function flush() {
          if (!asteriobidAnalyticsEnabled) {
            return
          }
        
        
        Severity: Minor
        Found in modules/asteriobidAnalyticsAdapter.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 collectUtmTagData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function collectUtmTagData() {
          let newUtm = false
          let pmUtmTags = {}
          try {
            utmTags.forEach(function (utmKey) {
        Severity: Minor
        Found in modules/asteriobidAnalyticsAdapter.js - About 1 hr to fix

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

          function handleEvent(eventType, eventArgs) {
            if (!asteriobidAnalyticsEnabled) {
              return
            }
          
          
          Severity: Minor
          Found in modules/asteriobidAnalyticsAdapter.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

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

          function collectUtmTagData() {
            let newUtm = false
            let pmUtmTags = {}
            try {
              utmTags.forEach(function (utmKey) {
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 day to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 82..110

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

          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

              case EVENTS.BID_RESPONSE: {
                pmEvent.bidderCode = eventArgs.bidderCode
                pmEvent.width = eventArgs.width
                pmEvent.height = eventArgs.height
                pmEvent.adId = eventArgs.adId
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 day to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 250..268

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

          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

              case EVENTS.BID_WON: {
                pmEvent.auctionId = eventArgs.auctionId
                pmEvent.adId = eventArgs.adId
                pmEvent.adserverTargeting = eventArgs.adserverTargeting
                pmEvent.adUnitCode = eventArgs.adUnitCode
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 day to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 269..286

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

          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 trimBid(bid) {
            if (!bid) return bid
            const res = {}
            res.auctionId = bid.auctionId
            res.bidder = bid.bidder
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 day to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 171..188

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

          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

              case EVENTS.BIDDER_DONE: {
                pmEvent.auctionId = eventArgs.auctionId
                pmEvent.auctionStart = eventArgs.auctionStart
                pmEvent.bidderCode = eventArgs.bidderCode
                pmEvent.bidderRequestId = eventArgs.bidderRequestId
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 7 hrs to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 287..299

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

          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

              case EVENTS.BID_REQUESTED: {
                pmEvent.auctionId = eventArgs.auctionId
                pmEvent.bidderCode = eventArgs.bidderCode
                pmEvent.doneCbCallCount = eventArgs.doneCbCallCount
                pmEvent.start = eventArgs.start
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 5 hrs to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 239..249

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

          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 trimBidderRequest(bidderRequest) {
            if (!bidderRequest) return bidderRequest
            const res = {}
            res.auctionId = bidderRequest.auctionId
            res.auctionStart = bidderRequest.auctionStart
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 4 hrs to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 190..199

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

          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

          function sendEvent(event) {
            eventQueue.push(event)
            logInfo(`${analyticsName} Event ${event.eventType}:`, event)
          
            if (event.eventType === EVENTS.AUCTION_END) {
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 hr to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 325..332

          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

          let asteriobidAnalytics = Object.assign(adapter({ url: DEFAULT_EVENT_URL, analyticsType }), {
            track({ eventType, args }) {
              handleEvent(eventType, args)
            }
          })
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 hr to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 50..54

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

          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 trimAdUnit(adUnit) {
            if (!adUnit) return adUnit
            const res = {}
            res.code = adUnit.code
            res.sizes = adUnit.sizes
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 hr to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 163..169

          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

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

              case EVENTS.AD_RENDER_FAILED: {
                pmEvent.bid = eventArgs.bid
                pmEvent.message = eventArgs.message
                pmEvent.reason = eventArgs.reason
                break
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 1 hr to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 309..314

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

          asteriobidAnalytics.disableAnalytics = function () {
            if (!asteriobidAnalyticsEnabled) {
              return
            }
            flush()
          Severity: Major
          Found in modules/asteriobidAnalyticsAdapter.js and 2 other locations - About 40 mins to fix
          modules/invisiblyAnalyticsAdapter.js on lines 90..97
          modules/prebidmanagerAnalyticsAdapter.js on lines 73..80

          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

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

            try {
              eventArgs = eventArgs ? JSON.parse(JSON.stringify(eventArgs)) : {}
            } catch (e) {
              // keep eventArgs as is
            }
          Severity: Minor
          Found in modules/asteriobidAnalyticsAdapter.js and 1 other location - About 35 mins to fix
          modules/prebidmanagerAnalyticsAdapter.js on lines 202..206

          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