prebid/Prebid.js

View on GitHub
libraries/userAgentUtils/index.js

Summary

Maintainability
B
4 hrs
Test Coverage

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

export const getBrowser = () => {
  if (/Edg/.test(navigator.userAgent)) return browserTypes.EDGE;
  else if (
    /Chrome/.test(navigator.userAgent) &&
    /Google Inc/.test(navigator.vendor)
Severity: Minor
Found in libraries/userAgentUtils/index.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

Avoid too many return statements within this function.
Open

  if (navigator.appVersion.indexOf('X11') != -1) return osTypes.UNIX;
Severity: Major
Found in libraries/userAgentUtils/index.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      return osTypes.OTHER;
    Severity: Major
    Found in libraries/userAgentUtils/index.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        if (navigator.userAgent.indexOf('Linux') != -1) return osTypes.LINUX;
      Severity: Major
      Found in libraries/userAgentUtils/index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          ) return browserTypes.INTERNET_EXPLORER;
        Severity: Major
        Found in libraries/userAgentUtils/index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            else return browserTypes.OTHER;
          Severity: Major
          Found in libraries/userAgentUtils/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              ) return browserTypes.SAFARI;
            Severity: Major
            Found in libraries/userAgentUtils/index.js - About 30 mins to fix

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

              export const getOS = () => {
                if (navigator.userAgent.indexOf('Android') != -1) return osTypes.ANDROID;
                if (navigator.userAgent.indexOf('like Mac') != -1) return osTypes.IOS;
                if (navigator.userAgent.indexOf('Win') != -1) return osTypes.WINDOWS;
                if (navigator.userAgent.indexOf('Mac') != -1) return osTypes.MAC;
              Severity: Minor
              Found in libraries/userAgentUtils/index.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

              There are no issues that match your filters.

              Category
              Status