luckyadam/jsonp-retry

View on GitHub

Showing 11 of 11 total issues

Function fetchData has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function fetchData (url, opts, cb) {
  const originalUrl = opts.originalUrl
  const charset = opts.charset
  const jsonpUrlQueryParam = getUrlQueryParamByName(url, opts.jsonp)
  const funcId = (jsonpUrlQueryParam === '?' ? false : jsonpUrlQueryParam) || opts.name || `__jsonp${timestamp++}`
Severity: Minor
Found in src/jsonp.js - About 3 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 exports has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',
Severity: Major
Found in karma.conf.js - About 3 hrs to fix

    Function fetchData has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function fetchData (url, opts, cb) {
      const originalUrl = opts.originalUrl
      const charset = opts.charset
      const jsonpUrlQueryParam = getUrlQueryParamByName(url, opts.jsonp)
      const funcId = (jsonpUrlQueryParam === '?' ? false : jsonpUrlQueryParam) || opts.name || `__jsonp${timestamp++}`
    Severity: Major
    Found in src/jsonp.js - About 2 hrs to fix

      Function jsonp has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function jsonp (url, opts, cb) {
        if (isFunction(url)) {
          cb = url
          opts = {}
        } else if (url && typeof url === 'object') {
      Severity: Major
      Found in src/jsonp.js - About 2 hrs to fix

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

        function jsonp (url, opts, cb) {
          if (isFunction(url)) {
            cb = url
            opts = {}
          } else if (url && typeof url === 'object') {
        Severity: Minor
        Found in src/jsonp.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 fallback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function fallback (url, opts, cb) {
          const backup = opts.backup
          let backupWithParams
          if (backup) {
            if (typeof backup === 'string') {
        Severity: Minor
        Found in src/jsonp.js - About 1 hr to fix

          Function getDataFromStore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function getDataFromStore ({ useStore, storeKey, storeCheck, storeCheckKey, storeSign, dataCheck }) {
            useStore = useStore ? store.enabled : false
            if (useStore) {
              const storeData = store.get(storeKey)
              storeCheck = storeCheck || storeCheckFn
          Severity: Minor
          Found in src/jsonp.js - About 55 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 fallback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function fallback (url, opts, cb) {
            const backup = opts.backup
            let backupWithParams
            if (backup) {
              if (typeof backup === 'string') {
          Severity: Minor
          Found in src/jsonp.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

              return new Promise((resolve, reject) => {
                fetchData(urlWithParams, opts, (err, data) => {
                  if (err) {
                    cb(err)
                    return reject(err)
          Severity: Major
          Found in src/jsonp.js - About 30 mins to fix

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

            module.exports = function (config) {
              config.set({
            
                // base path that will be used to resolve all patterns (eg. files, exclude)
                basePath: '',
            Severity: Minor
            Found in karma.conf.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

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

            function getDataFromStoreWithoutCheck ({ useStore, storeKey, dataCheck }) {
              useStore = useStore ? store.enabled : false
              if (useStore) {
                const storeData = store.get(storeKey)
                if (!dataCheck || (storeData && dataCheck && dataCheck(storeData) !== false)) {
            Severity: Minor
            Found in src/jsonp.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

            Severity
            Category
            Status
            Source
            Language